Constructor and Description |
---|
SegmentNodeState(@NotNull SegmentReader reader,
@NotNull SegmentWriter writer,
@Nullable BlobStore blobStore,
@NotNull RecordId id) |
SegmentNodeState(@NotNull SegmentReader reader,
@NotNull SegmentWriter writer,
@Nullable BlobStore blobStore,
@NotNull RecordId id,
MeterStats readStats) |
Modifier and Type | Method and Description |
---|---|
@NotNull SegmentNodeBuilder |
builder()
Returns a builder for constructing a new node state based on
this state, i.e.
|
boolean |
compareAgainstBaseState(NodeState base,
NodeStateDiff diff)
Compares this node state against the given base state.
|
boolean |
equals(java.lang.Object object) |
boolean |
exists()
Checks whether this node exists.
|
static boolean |
fastEquals(NodeState a,
NodeState b)
Indicates whether two
NodeState instances are equal to each
other. |
boolean |
getBoolean(@NotNull java.lang.String name)
Returns the boolean value of the named property.
|
@NotNull NodeState |
getChildNode(@NotNull java.lang.String name)
Returns the named, possibly non-existent, child node.
|
long |
getChildNodeCount(long max)
Returns the number of iterable child nodes of this node.
|
@NotNull java.lang.Iterable<? extends ChildNodeEntry> |
getChildNodeEntries()
Returns the iterable child node entries of this instance.
|
@NotNull java.lang.Iterable<java.lang.String> |
getChildNodeNames()
Returns the names of all iterable child nodes.
|
@NotNull GCGeneration |
getGcGeneration()
Get the underlying segment's gc generation.
|
long |
getLong(java.lang.String name)
Returns the long value of the named property.
|
@Nullable java.lang.String |
getName(@NotNull java.lang.String name)
Returns the name value of the named property.
|
@NotNull java.lang.Iterable<java.lang.String> |
getNames(@NotNull java.lang.String name)
Returns the name values of the named property.
|
@NotNull java.lang.Iterable<PropertyState> |
getProperties()
Returns an iterable of the properties of this node.
|
@Nullable PropertyState |
getProperty(@NotNull java.lang.String name)
Returns the named property, or
null if no such property exists. |
long |
getPropertyCount()
Returns the number of properties of this node.
|
RecordId |
getRecordId()
Returns the identifier of this record.
|
protected int |
getRecordNumber() |
protected Segment |
getSegment()
Returns the segment that contains this record.
|
java.lang.String |
getStableId()
Returns the stable id of this node.
|
Buffer |
getStableIdBytes()
Returns the stable ID of this node, non parsed.
|
@Nullable java.lang.String |
getString(java.lang.String name)
Returns the string value of the named property.
|
@NotNull java.lang.Iterable<java.lang.String> |
getStrings(@NotNull java.lang.String name)
Returns the string values of the named property.
|
boolean |
hasChildNode(@NotNull java.lang.String name)
Checks whether the named child node exists.
|
int |
hashCode() |
boolean |
hasProperty(@NotNull java.lang.String name)
Checks whether the named property exists.
|
java.lang.String |
toString() |
public SegmentNodeState(@NotNull @NotNull SegmentReader reader, @NotNull @NotNull SegmentWriter writer, @Nullable @Nullable BlobStore blobStore, @NotNull @NotNull RecordId id)
public SegmentNodeState(@NotNull @NotNull SegmentReader reader, @NotNull @NotNull SegmentWriter writer, @Nullable @Nullable BlobStore blobStore, @NotNull @NotNull RecordId id, MeterStats readStats)
public java.lang.String getStableId()
public Buffer getStableIdBytes()
public boolean exists()
NodeState
public long getPropertyCount()
NodeState
getPropertyCount
in interface NodeState
public boolean hasProperty(@NotNull @NotNull java.lang.String name)
NodeState
getProperty(name) != null
, but may be optimized
to avoid having to load the property value.hasProperty
in interface NodeState
name
- property nametrue
if the named property exists,
false
otherwise@Nullable public @Nullable PropertyState getProperty(@NotNull @NotNull java.lang.String name)
NodeState
null
if no such property exists.getProperty
in interface NodeState
name
- name of the property to returnnull
if not found@NotNull public @NotNull java.lang.Iterable<PropertyState> getProperties()
NodeState
getProperties
in interface NodeState
public boolean getBoolean(@NotNull @NotNull java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
return property != null
&& property.getType() == Type.BOOLEAN
&& property.getValue(Type.BOOLEAN);
getBoolean
in interface NodeState
name
- property namefalse
public long getLong(java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.LONG) {
return property.getValue(Type.LONG);
} else {
return 0;
}
@Nullable public @Nullable java.lang.String getString(java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.STRING) {
return property.getValue(Type.STRING);
} else {
return null;
}
@NotNull public @NotNull java.lang.Iterable<java.lang.String> getStrings(@NotNull @NotNull java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.STRINGS) {
return property.getValue(Type.STRINGS);
} else {
return Collections.emptyList();
}
getStrings
in interface NodeState
name
- property name@Nullable public @Nullable java.lang.String getName(@NotNull @NotNull java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.NAME) {
return property.getValue(Type.NAME);
} else {
return null;
}
@NotNull public @NotNull java.lang.Iterable<java.lang.String> getNames(@NotNull @NotNull java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.NAMES) {
return property.getValue(Type.NAMES);
} else {
return Collections.emptyList();
}
public long getChildNodeCount(long max)
NodeState
If an implementation knows the exact value, it returns it (even if the value is higher than max). If the implementation does not know the exact value, and the child node count is higher than max, it may return Long.MAX_VALUE. The cost of the operation is at most O(max).
getChildNodeCount
in interface NodeState
max
- the maximum number of entries to traversepublic boolean hasChildNode(@NotNull @NotNull java.lang.String name)
NodeState
getChildNode(name).exists()
, except that
passing an invalid name as argument will result in a false
return value instead of an IllegalArgumentException
.hasChildNode
in interface NodeState
name
- name of the child nodetrue
if the named child node exists,
false
otherwise@NotNull public @NotNull NodeState getChildNode(@NotNull @NotNull java.lang.String name)
NodeState
NodeState.exists()
method on the returned child node to determine
whether the node exists or not.getChildNode
in interface NodeState
name
- name of the child node to return@NotNull public @NotNull java.lang.Iterable<java.lang.String> getChildNodeNames()
NodeState
getChildNodeNames
in interface NodeState
@NotNull public @NotNull java.lang.Iterable<? extends ChildNodeEntry> getChildNodeEntries()
NodeState
Note on cost and performance: while it is possible to iterate over
all child NodeState
s with the two methods NodeState.getChildNodeNames()
and NodeState.getChildNode(String)
, this method is
considered more efficient because an implementation can potentially
perform the retrieval of the name and NodeState
in one call.
This results in O(n) vs. O(n log n) when iterating over the child node
names and then look up the NodeState
by name.
getChildNodeEntries
in interface NodeState
@NotNull public @NotNull SegmentNodeBuilder builder()
NodeState
public boolean compareAgainstBaseState(NodeState base, NodeStateDiff diff)
NodeState
TODO: Define the behavior of this method with regards to iterability/existence of child nodes.
compareAgainstBaseState
in interface NodeState
base
- base statediff
- handler of node state differencestrue
if the full diff was performed, or
false
if it was aborted as requested by the handler
(see the NodeStateDiff
contract for more details)public static boolean fastEquals(NodeState a, NodeState b)
NodeState
instances are equal to each
other. A return value of true
clearly means that the instances
are equal, while a return value of false
doesn't necessarily mean
the instances are not equal. These "false negatives" are an
implementation detail and callers cannot rely on them being stable.public int hashCode()
public boolean equals(java.lang.Object object)
public java.lang.String toString()
protected Segment getSegment()
protected int getRecordNumber()
public RecordId getRecordId()
@NotNull public @NotNull GCGeneration getGcGeneration()
Copyright © 2012–2022 The Apache Software Foundation. All rights reserved.