CachingDAGStorageProvider(ObjectStore source) { this.source = source; this.treeCache = new TreeCache(source); heap = new HeapDAGStorageProvider(this.source, this.treeCache); nodeStore = heap; heapTrees = (id) -> id.depthLength() <= HEAP_DEPTH_THRESHOLD; diskTrees = (id) -> id.depthLength() > HEAP_DEPTH_THRESHOLD; }
public @Override int bucket(Node node, int depth) { NodeId nodeId = computeId(node); TreeId bucketId = computeBucketId(nodeId, depth); int leafBucket = bucketId.leafBucket(); return leafBucket; }
public QuadTreeClusteringStrategy newStrategy(RevTree original) { QuadTreeClusteringStrategy quadStrategy = ClusteringStrategyBuilder// .quadTree(store)// .original(original)// .maxBounds(maxBoundsFloat64)// .maxDepth(maxDepth)// .build(); Assert.assertEquals(getMaxBounds(), quadStrategy.getMaxBounds()); return quadStrategy; }
/** * Returns the bucket index in the range 0-3 corresponding to this node at the specified depth * (i.e. the bucket index represents a quadrant), or {@code -1} if the spatial bounds of this * node don't fit on a single child quadrant and hence the node shall be kept at the current * tree node (hence creating a mixed {@link RevTree} with both direct children and buckets). */ public @Override int bucket(final NodeId nodeId, final int depthIndex) { final Envelope nodeBounds = nodeId.value(); final Quadrant quadrantAtDepth = computeQuadrant(nodeBounds, depthIndex); if (quadrantAtDepth == null) { return -1; } return quadrantAtDepth.ordinal(); }
/** * @param quadKey e.g. {@code "[0, 1, 2, 3]"} for quads {@code [SW, NW, NE, SE]} * @return */ public Envelope createBounds(String quadKey) { TreeId id = TreeId.fromString(quadKey); Quadrant[] quads = new Quadrant[id.depthLength()]; for (int i = 0; i < id.depthLength(); i++) { quads[i] = Quadrant.VALUES[id.bucketIndex(i)]; } return createBounds(quads); }
public ClusteringStrategy build() { DAGStorageProvider dagStoreProvider = createDAGStoreageProvider(); try { return buildInternal(dagStoreProvider); } catch (RuntimeException e) { dagStoreProvider.dispose(); throw e; } }
/** * Copy constructor * * @param store {@link org.locationtech.geogig.storage.ObjectStore ObjectStore} with which to * initialize this RevTreeBuilder. * @param original {@link org.locationtech.geogig.api.RevTree RevTree} to copy. */ CanonicalTreeBuilder(final ObjectStore store, final RevTree original) { super(store, original); ClusteringStrategy canonical = ClusteringStrategyBuilder.canonical(store).original(original) .build(); this.clusteringStrategy = canonical; }
/** * Tests {@code deepPath} collapses to {@code collapsedPath} when calling {@code buildRoot()}, * but doesn't change {@code strategy}, uses a cloned strategy instead */ private void assertCollapsesTo(QuadTreeClusteringStrategy strategy, String deepPath, String collapsedPath, Iterable<Node> expectedNodes) { QuadTreeClusteringStrategy clone = support.clone(strategy); support.assertDag(clone, deepPath, expectedNodes); clone.collapse(clone.root); support.assertDag(clone, collapsedPath, expectedNodes); }
/** * @return the exact bounds of the leaf quad addressed by the given list of quadrants */ public Envelope quadBounds(Quadrant... quadrants) { Envelope env = getMaxBounds(); for (Quadrant q : quadrants) { env = q.slice(env); } return env; }
@Override public void saveNodes(Map<NodeId, DAGNode> nodeMappings) { nodeStore.saveNodes(nodeMappings); swapNodeStore(); }
@Override public void saveNode(NodeId nodeId, Node node) { nodeStore.saveNode(nodeId, node); swapNodeStore(); }
public QuadTreeClusteringStrategy newStrategy(RevTree original) { QuadTreeClusteringStrategy quadStrategy = ClusteringStrategyBuilder// .quadTree(store)// .original(original)// .maxBounds(maxBoundsFloat64)// .maxDepth(maxDepth)// .build(); Assert.assertEquals(getMaxBounds(), quadStrategy.getMaxBounds()); return quadStrategy; }
/** * @param quadKey e.g. {@code "[0, 1, 2, 3]"} for quads {@code [SW, NW, NE, SE]} * @return */ public Envelope createBounds(String quadKey) { TreeId id = TreeId.fromString(quadKey); Quadrant[] quads = new Quadrant[id.depthLength()]; for (int i = 0; i < id.depthLength(); i++) { quads[i] = Quadrant.VALUES[id.bucketIndex(i)]; } return createBounds(quads); }
public ClusteringStrategy build() { DAGStorageProvider dagStoreProvider = createDAGStoreageProvider(); try { return buildInternal(dagStoreProvider); } catch (RuntimeException e) { dagStoreProvider.dispose(); throw e; } }
/** * Copy constructor * * @param store {@link org.locationtech.geogig.storage.ObjectStore ObjectStore} with which to * initialize this RevTreeBuilder. * @param original {@link org.locationtech.geogig.api.RevTree RevTree} to copy. */ CanonicalTreeBuilder(final ObjectStore store, final RevTree original) { super(store, original); ClusteringStrategy canonical = ClusteringStrategyBuilder.canonical(store).original(original) .build(); this.clusteringStrategy = canonical; }
/** * Tests {@code deepPath} collapses to {@code collapsedPath} when calling {@code buildRoot()}, * but doesn't change {@code strategy}, uses a cloned strategy instead */ private void assertCollapsesTo(QuadTreeClusteringStrategy strategy, String deepPath, String collapsedPath, Iterable<Node> expectedNodes) { QuadTreeClusteringStrategy clone = support.clone(strategy); support.assertDag(clone, deepPath, expectedNodes); clone.collapse(clone.root); support.assertDag(clone, collapsedPath, expectedNodes); }
/** * @return the exact bounds of the leaf quad addressed by the given list of quadrants */ public Envelope quadBounds(Quadrant... quadrants) { Envelope env = getMaxBounds(); for (Quadrant q : quadrants) { env = q.slice(env); } return env; }