public class DocumentOptimizer extends Object implements DocumentConstants
BLOCK_SIZE, BUCKET_ID_LENGTH, BUCKETS, CACHEABLE_FIELD, CHILDREN, CHILDREN_INFO, COUNT, EXTERNAL_BINARY_ID_FIELD, FEDERATED_SEGMENTS, KEY, LAST_BLOCK, LENGTH, LENGTH_FIELD, NAME, NEXT_BLOCK, PARENT, PROPERTIES, QUERYABLE_FIELD, REFERENCE_COUNT, REFERENCE_FIELD, REFERRERS, SHA1, SHA1_FIELD, SIMPLE_REFERENCE_FIELD, SIZE, SOURCE_NAME_FIELD, STRONG, WEAK, WEAK_REFERENCE_FIELD
Constructor and Description |
---|
DocumentOptimizer(DocumentStore documentStore) |
Modifier and Type | Method and Description |
---|---|
protected EditableDocument |
edit(String key) |
protected String |
mergeChildren(NodeKey key,
EditableDocument document,
EditableArray children,
boolean isFirst,
String nextBlock)
Modify the supplied document (with the given key) to merge in all of the children from the next block.
|
boolean |
optimizeChildrenBlocks(NodeKey key,
EditableDocument document,
int targetCountPerBlock,
int tolerance)
Optimize the children in the supplied node document
Note that this method changes the underlying db as well as the given document, so *it must* be called either from a
transactional context or it must be followed by a session.save call, otherwise there might be inconsistencies between what
a session sees as "persisted" state and the reality.
|
protected boolean |
splitChildren(NodeKey key,
EditableDocument document,
EditableArray children,
int targetCountPerBlock,
int tolerance,
boolean isFirst,
String nextBlock)
Split the children in the given document (with the given key) into two or more blocks, based upon the specified number of
desired children per block and a tolerance.
|
public DocumentOptimizer(DocumentStore documentStore)
public boolean optimizeChildrenBlocks(NodeKey key, EditableDocument document, int targetCountPerBlock, int tolerance)
Note that this method changes the underlying db as well as the given document, so *it must* be called either from a transactional context or it must be followed by a session.save call, otherwise there might be inconsistencies between what a session sees as "persisted" state and the reality.
key
- the key for the nodedocument
- the node's document representation that is to be optimizedtargetCountPerBlock
- the target number of children per blocktolerance
- the allowed tolerance between the target and actual number of children per blockprotected EditableDocument edit(String key)
protected boolean splitChildren(NodeKey key, EditableDocument document, EditableArray children, int targetCountPerBlock, int tolerance, boolean isFirst, String nextBlock)
Note this method returns very quickly if the method determines that there is no work to do.
Note that this method changes the underlying db as well as the given document, so *it must* be called either from a transactional context or it must be followed by a session.save call, otherwise there might be inconsistencies between what a session sees as "persisted" state and the reality.
key
- the key for the document whose children are to be split; may not be nulldocument
- the document whose children are to be split; may not be nullchildren
- the children that are to be split; may not be nulltargetCountPerBlock
- the goal for the number of children in each block; must be positivetolerance
- a tolerance that when added to and subtraced from the targetCountPerBlock
gives an acceptable
range for the number of children; must be positive but smaller than targetCountPerBlock
isFirst
- true if the supplied document is the first node document, or false if it is a block documentnextBlock
- the key for the next block of children; may be null if the supplied document is the last document and
there is no next blockprotected String mergeChildren(NodeKey key, EditableDocument document, EditableArray children, boolean isFirst, String nextBlock)
Note that this method changes the underlying db as well as the given document, so *it must* be called either from a transactional context or it must be followed by a session.save call, otherwise there might be inconsistencies between what a session sees as "persisted" state and the reality.
key
- the key for the document whose children are to be merged with the next block; may not be nulldocument
- the document to be modified with the next block's children; may not be nullchildren
- the children into which are to be merged the next block's children; may not be nullisFirst
- true if the supplied document is the first node document, or false if it is a block documentnextBlock
- the key for the next block of children; may be null if the supplied document is the last document and
there is no next blockCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.