Class AbstractConstraintsTree<DS extends BoundedShape<NS>,DR extends DBTreeDataRecord<DS,NS,T>,NS extends BoundingShape<NS>,NR extends DBTreeNodeRecord<NS>,T,Q extends Query<DS,NS>>
- Direct Known Subclasses:
AbstractRStarConstraintsTree
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<Long, Collection<DR>> protected final Map<Long, Collection<NR>> protected final DBCachedObjectStore<DR> protected intprotected final DBCachedObjectStore<NR> protected NR -
Constructor Summary
ConstructorsConstructorDescriptionAbstractConstraintsTree(DBCachedObjectStoreFactory storeFactory, String tableName, Class<DR> dataType, Class<NR> nodeType, boolean upgradable) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCheck the integrity of a single data entry.voidAn integrity checker for use by tree developers and testers.protected voidCheck the integrity of a single node entry.protected voidprotected intprotected intprotected abstract DRcreateDataEntry(DBCachedObjectStore<DR> store, DBRecord record) protected abstract NRcreateNodeEntry(DBCachedObjectStore<NR> store, DBRecord record) protected voiddestroySubtree(NR node) protected <R> voiddoAddToCachedChildren(long parentKey, R child, Map<Long, Collection<R>> cache) protected voiddoDecrementDataCount(NR node) protected voiddoDeleteEntry(DR data) protected DRdoFindExact(DS shape, T value, Q query) protected abstract DRdoInsertData(DS shape, T value) protected voiddoRecomputeBounds(NR node) protected booleandoRemoveData(DS shape, T value, Q query) protected <R> voiddoRemoveFromCachedChildren(long parentKey, R child, Map<Long, Collection<R>> cache) protected <R extends DBTreeRecord<?,?>>
voiddoSetParentKey(R child, long key, Map<Long, Collection<R>> cache) protected voiddoUnparentEntry(DR data) Remove a data record from the tree, but keep the orphaned record in the tableprotected voiddoUpdateOrDeleteAlongPath(NR node) protected voidDump the tree to the console, for debugging and testing purposesprotected DRprotected Collection<? extends DBTreeRecord<?, ? extends NS>> getChildrenOf(NR parent) Get the children.getDataByKey(long key) protected abstract Collection<DR> getDataChildrenOf(long parentKey) For leaf nodes, get the children.protected Collection<DR> getDataChildrenOf(NR parent) For leaf nodes, get the children.protected abstract Comparator<NS> protected abstract Collection<NR> getNodeChildrenOf(long parentKey) For non-leaf nodes, get the children.protected Collection<NR> getNodeChildrenOf(NR parent) For non-leaf nodes, get the children.protected NRprotected NRgetParentOf(DBTreeRecord<?, ?> n) <K> DBCachedObjectIndex<K, DR> getUserIndex(Class<K> fieldClass, DBObjectColumn column) protected voidinit()voidprotected booleanorderedIterator(Q query) protected voidresyncMetadata(NR node) protected NSunionStream(Stream<NS> shapes) protected AbstractConstraintsTree.VisitResultvisit(NR parent, NR node, Q query, AbstractConstraintsTree<DS, DR, NS, NR, T, Q>.TreeRecordVisitor visitor, boolean ordered) protected AbstractConstraintsTree.VisitResultvisit(Q query, AbstractConstraintsTree<DS, DR, NS, NR, T, Q>.TreeRecordVisitor visitor, boolean ordered) protected voidvisitAllData(Q query, Consumer<DR> consumer, boolean ordered)
-
Field Details
-
dataStore
-
nodeStore
-
cachedDataChildren
-
cachedNodeChildren
-
root
-
leafLevel
protected int leafLevel
-
-
Constructor Details
-
AbstractConstraintsTree
public AbstractConstraintsTree(DBCachedObjectStoreFactory storeFactory, String tableName, Class<DR> dataType, Class<NR> nodeType, boolean upgradable) throws VersionException, IOException - Throws:
VersionExceptionIOException
-
-
Method Details
-
createDataEntry
-
createNodeEntry
-
init
protected void init() -
getDefaultBoundsComparator
-
getNodeChildrenOf
For non-leaf nodes, get the children.For leaf nodes, the behavior is undefined. Note that the query should not filter the children, only order them. Filtering is performed by
AbstractConstraintsTree<DS extends BoundedShape<NS>,.DR extends DBTreeDataRecord<DS, NS, T>, NS extends BoundingShape<NS>, NR extends DBTreeNodeRecord<NS>, T, Q extends Query<DS, NS>>.TreeRecordVisitor - Parameters:
parentKey- the key of the parent whose children to get- Returns:
- an iterable of the children
-
getNodeChildrenOf
For non-leaf nodes, get the children.For leaf nodes, the behavior is undefined. Note that the query should not filter the children, only order them, or else the collection will return an incorrect
Collection.size(). Filtering is performed byAbstractConstraintsTree<DS extends BoundedShape<NS>,.DR extends DBTreeDataRecord<DS, NS, T>, NS extends BoundingShape<NS>, NR extends DBTreeNodeRecord<NS>, T, Q extends Query<DS, NS>>.TreeRecordVisitor - Parameters:
parent- the parent node- Returns:
- a collection of the children
-
getDataChildrenOf
For leaf nodes, get the children.For non-leaf nodes, the behavior is undefined. Note that the query should not filter the children, only order them, or else the collection will return an incorrect
Collection.size(). Filtering is performed byAbstractConstraintsTree<DS extends BoundedShape<NS>,.DR extends DBTreeDataRecord<DS, NS, T>, NS extends BoundingShape<NS>, NR extends DBTreeNodeRecord<NS>, T, Q extends Query<DS, NS>>.TreeRecordVisitor - Parameters:
parentKey- the key of the parent whose children to get- Returns:
- an iterable of the children
-
getDataChildrenOf
For leaf nodes, get the children.For non-leaf nodes, the behavior is undefined. Note that the query should not filter the children, only order them, or else the collection will return an incorrect
Collection.size(). Filtering is performed byAbstractConstraintsTree<DS extends BoundedShape<NS>,.DR extends DBTreeDataRecord<DS, NS, T>, NS extends BoundingShape<NS>, NR extends DBTreeNodeRecord<NS>, T, Q extends Query<DS, NS>>.TreeRecordVisitor - Parameters:
parent- the parent node- Returns:
- a collection of the children
-
getChildrenOf
Get the children.Because the children may be either nodes or data, the exact type is not known. The only guarantee is that it is a tree record, which permits access to its bounds and parent. Note that the query should not filter the children, only order them, or else the collection will return an incorrect
Collection.size(). Filtering is performed byAbstractConstraintsTree<DS extends BoundedShape<NS>,.DR extends DBTreeDataRecord<DS, NS, T>, NS extends BoundingShape<NS>, NR extends DBTreeNodeRecord<NS>, T, Q extends Query<DS, NS>>.TreeRecordVisitor - Parameters:
parent- the parent node- Returns:
- a collection of the children
-
getParentOf
-
getOrCreateRoot
-
computeLeafLevel
protected int computeLeafLevel() -
doInsertData
-
visit
protected AbstractConstraintsTree.VisitResult visit(Q query, AbstractConstraintsTree<DS, DR, NS, NR, T, Q>.TreeRecordVisitor visitor, boolean ordered) -
visit
protected AbstractConstraintsTree.VisitResult visit(NR parent, NR node, Q query, AbstractConstraintsTree<DS, DR, NS, NR, T, Q>.TreeRecordVisitor visitor, boolean ordered) -
iterator
-
iterator
-
orderedIterator
-
count
-
isEmpty
-
first
-
visitAllData
-
doFindExact
-
doUpdateOrDeleteAlongPath
-
doDecrementDataCount
-
unionStream
-
doRecomputeBounds
-
doRemoveFromCachedChildren
protected <R> void doRemoveFromCachedChildren(long parentKey, R child, Map<Long, Collection<R>> cache) -
doAddToCachedChildren
-
doSetParentKey
protected <R extends DBTreeRecord<?,?>> void doSetParentKey(R child, long key, Map<Long, Collection<R>> cache) -
doUnparentEntry
Remove a data record from the tree, but keep the orphaned record in the tableNote that at most one orphaned record should be in the table at any time, otherwise behavior is undefined. It is up to the implementor to provide a means of inserting orphaned data records back into the tree. This is useful for implementations which allow a data record's shape to be mutated: Orphan the record, adjust its shape, re-insert the orphan.
- Parameters:
data- the data record
-
doDeleteEntry
-
doRemoveData
-
destroySubtree
-
resyncMetadata
-
clear
-
dump
Dump the tree to the console, for debugging and testing purposes- Parameters:
query- optionally include only those portions matching a query
-
checkNodeIntegrity
Check the integrity of a single node entry.This method is for tree developers and testers. Override this method if you have additional integrity checks.
- Parameters:
n- the entry to check
-
checkDataIntegrity
Check the integrity of a single data entry.This method is for tree developers and testers. Override this method if you have additional integrity checks.
- Parameters:
d- the entry to check
-
checkIntegrity
public void checkIntegrity()An integrity checker for use by tree developers and testers.To incorporate additional checks, please prefer to override
checkNodeIntegrity(DBTreeNodeRecord)and/orcheckDataIntegrity(DBTreeDataRecord)instead of this method. -
asSpatialMap
-
getDataByKey
-
getUserIndex
-
invalidateCache
public void invalidateCache()
-