@API.Public public abstract class BaseFieldProjector extends Object implements JsonString
Modifier and Type | Field and Description |
---|---|
protected org.ojai.util.impl.ProjectionTree |
currentSegment |
protected boolean |
includeAllChildren
This flag indicates that the current Field should be projected because its FieldPath
is a descendant of one of the projected fields.
|
protected boolean |
includeField
This flag indicates that the current Field should be projected because its FieldPath
is a "suffix" of the FieldPath of one of the projected fields.
|
protected org.ojai.util.impl.ProjectionTree |
lastSegment |
protected int |
level |
protected org.ojai.util.impl.MutableFieldSegment |
readerFieldSegment |
protected org.ojai.util.impl.ProjectionTree |
rootSegment |
Modifier | Constructor and Description |
---|---|
protected |
BaseFieldProjector(Collection<FieldPath> includedPaths) |
protected |
BaseFieldProjector(FieldPath... includedPaths) |
protected |
BaseFieldProjector(org.ojai.util.impl.ProjectionTree rootSegment) |
protected |
BaseFieldProjector(String... includedPaths) |
Modifier and Type | Method and Description |
---|---|
String |
asJsonString() |
String |
asJsonString(JsonOptions options) |
abstract BaseFieldProjector |
cloneWithSharedProjectionTree()
Creates a lightweight clone of this FieldProjector with shared ProjectionTree.
|
boolean |
done()
Returns
true if ProjectionTree has visited all nodes |
boolean |
isDone()
Returns
true if ProjectionTree has visited all nodes |
protected void |
moveTo(DocumentReader.EventType event)
This is the main algorithm that determine if the current
DocumentReader or
MutableFieldSegment node should be included or excluded based on the set
of projected fields. |
protected void |
moveTo(org.ojai.util.impl.MutableFieldSegment keySegment,
DocumentReader.EventType event)
To be used when input
Document is not from a DocumentReader
but provided externally as a MutableFieldSegment . |
BaseFieldProjector |
reset()
Resets the state of this projection tree to the root of the Document
when not using with a DocumentReader.
|
protected BaseFieldProjector |
reset(DocumentReader reader)
Resets the state of this projection tree to the root of the Document.
|
protected boolean |
shouldEmitEvent() |
String |
toString() |
protected final org.ojai.util.impl.ProjectionTree rootSegment
protected org.ojai.util.impl.ProjectionTree currentSegment
protected org.ojai.util.impl.ProjectionTree lastSegment
protected org.ojai.util.impl.MutableFieldSegment readerFieldSegment
protected int level
protected boolean includeField
protected boolean includeAllChildren
protected BaseFieldProjector(@API.NonNullable String... includedPaths)
protected BaseFieldProjector(@API.NonNullable FieldPath... includedPaths)
protected BaseFieldProjector(@API.NonNullable Collection<FieldPath> includedPaths)
protected BaseFieldProjector(org.ojai.util.impl.ProjectionTree rootSegment)
public abstract BaseFieldProjector cloneWithSharedProjectionTree()
protected boolean shouldEmitEvent()
protected void moveTo(DocumentReader.EventType event)
DocumentReader
or
MutableFieldSegment
node should be included or excluded based on the set
of projected fields.protected void moveTo(org.ojai.util.impl.MutableFieldSegment keySegment, DocumentReader.EventType event)
Document
is not from a DocumentReader
but provided externally as a MutableFieldSegment
.
A MutableFieldSegment
can represent an IndexSegment
or FieldSegment.NameSegment
with appropriate attributes set. A single MutableFieldSegment
should represent
on independent FieldSegment
which is part of a FieldPath
that has been
encountered while decoding or traversing a Document
.
When moveTo
is called with a MutableFieldSegment
keySegment input, the method
will try to search if the keySegment is a child of the currentSegment
. The outcome of the
search is captured in the BaseFieldProjector
state. The caller can subsequently call
shouldEmitEvent
in order to find out whether the child keySegment was found.
If the child keySegment is indeed found, the currentSegment
will be set to the
child keySegment.
Since moveTo
can cause a change to the currentSegment
being pointed to, in a hierarchical
tree traversal, the effect of walking 'down' the ProjectionTree
needs to be reversed when
walking back 'up' the ProjectionTree
. Therefore, moveTo
should be called twice for each
MutableFieldSegment
- once to traverse 'down' the tree and once to travrse back 'up'.public boolean isDone()
true
if ProjectionTree has visited all nodesprotected BaseFieldProjector reset(DocumentReader reader)
this
for chaining.public BaseFieldProjector reset()
this
for chaining;public boolean done()
true
if ProjectionTree has visited all nodespublic String asJsonString()
asJsonString
in interface JsonString
public String asJsonString(JsonOptions options)
asJsonString
in interface JsonString
Copyright © 2015–2018 MapR Technologies, Inc.. All rights reserved.