/** * Equality is based on id * * @see AbstractRevObject#equals(Object) */ @Override public boolean equals(Object o) { if (!(o instanceof RevTree)) { return false; } return id.equals(((RevTree) o).getId()); }
private Map<ObjectId, RevTree> loadBucketTrees(final ObjectStore source, final SortedMap<Integer, Bucket> buckets) { final Map<ObjectId, RevTree> bucketTrees; { Iterable<ObjectId> ids = transform(buckets.values(), (b) -> b.getObjectId()); bucketTrees = uniqueIndex(source.getAll(ids, NOOP_LISTENER, RevTree.class), (t) -> t.getId()); } return bucketTrees; }
/** * @return the resolved root tree id */ private ObjectId resolveRootTreeId() { if (oldRoot != null) { RevTree rootTree = oldRoot.get(); return rootTree.getId(); } ObjectId targetTreeId = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call().get(); return targetTreeId; }
@Override protected void writeResultBody(StreamingWriter w, RevTree result) throws StreamWriterException { if (result != null) { w.writeStartElement("RevTree"); w.writeElement("treeId", result.getId().toString()); w.writeEndElement(); } }
@Test public void testUpdatesNodes() { indexInfo = createIndex(); RevTree newCanonicalTree = checkUpdatesNodes(); Optional<ObjectId> indexId = indexdb.resolveIndexedTree(indexInfo, newCanonicalTree.getId()); assertTrue(indexId.isPresent()); IndexTestSupport.verifyIndex(geogig, indexId.get(), newCanonicalTree.getId()); }
/** * Creates a root node for the given tree as the one {@link PreOrderDiffWalk} should use to * start the traversal */ private NodeRef nodeFor(RevTree root) { Envelope bounds = SpatialOps.boundsOf(root); return NodeRef.createRoot( Node.create(NodeRef.ROOT, root.getId(), ObjectId.NULL, TYPE.TREE, bounds)); }
@Test public void testSimple() { RevTree tree = createTree("blob"); NodeRef child = NodeRef.tree("subtree", tree.getId(), ObjectId.NULL); RevTree newRoot = context.command(UpdateTree.class).setRoot(RevTree.EMPTY).setChild(child) .call(); assertTrue(odb.exists(newRoot.getId())); Optional<NodeRef> ref = new DepthSearch(odb).find(newRoot.getId(), "subtree"); assertTrue(ref.isPresent()); assertEquals(child, ref.get()); }
@Test public void testRoundTripBuckets() throws IOException { RevTree roundTripped = (RevTree) read(tree3_buckets.getId(), write(tree3_buckets)); assertTreesAreEqual(tree3_buckets, roundTripped); }
@Test public void testRoundTripSpatialInternalTree() throws IOException { RevTree roundTripped = (RevTree) read(tree5_spatial_internal.getId(), write(tree5_spatial_internal)); assertTreesAreEqual(tree5_spatial_internal, roundTripped); }
@Test public void testCreatesIndex() { indexInfo = createIndex(); final RevTree oldCanonicalTree = RevTree.EMPTY; final RevTree newCanonicalTree = worldPointsTree; RevTree indexTree = updateIndex(oldCanonicalTree, newCanonicalTree); assertNotEquals(RevTree.EMPTY, indexTree); assertEquals(newCanonicalTree.size(), indexTree.size()); IndexTestSupport.verifyIndex(geogig, indexTree.getId(), newCanonicalTree.getId()); }
@Test public void testRoundTripSpatialLeafTree() throws IOException { RevTree roundTripped = (RevTree) read(tree4_spatial_leaves.getId(), write(tree4_spatial_leaves)); assertTreesAreEqual(tree4_spatial_leaves, roundTripped); }
@Test public void testRoundTripInternalTree() throws IOException { RevTree roundTripped = (RevTree) read(tree2_internal.getId(), write(tree2_internal)); assertTreesAreEqual(tree2_internal, roundTripped); }
private RevTree createStageHeadTree(NodeRef... treeRefs) { RevTree root = createFromRefs(objectDb, treeRefs); geogig.command(UpdateRef.class).setName(Ref.STAGE_HEAD).setNewValue(root.getId()).call(); return root; }
private RevTree createRoot(ObjectDatabase db, final RevTree tree1, final RevTree tree2) { RevTreeBuilder rootBuilder = RevTreeBuilder.builder(db); rootBuilder.put(RevObjectFactory.defaultInstance().createNode("tree1", tree1.getId(), metadataId, TYPE.TREE, SpatialOps.boundsOf(tree1), null)); rootBuilder.put(RevObjectFactory.defaultInstance().createNode("tree2", tree2.getId(), metadataId, TYPE.TREE, SpatialOps.boundsOf(tree2), null)); RevTree root = rootBuilder.build(); db.put(root); return root; }
public @Test void testPutIfAbsent() { Key k1 = repo1Id.create(obj.getId()); assertNotNull(cache.put(k1, obj)); assertNull(cache.put(k1, obj)); }
public @Test void testGetIfPresentImmediately() { cache = createCache(10, maxCacheSizeBytes); CacheKey k1 = repo1Id.create(obj.getId()); assertNull(cache.getIfPresent(k1)); assertNotNull(cache.put(k1, obj)); RevObject cached = cache.getIfPresent(k1); assertNotNull(cached); assertNull(cache.getIfPresent(repo2Id.create(obj.getId()))); assertEquals(obj, cached); }
@Test public void testRoundTripBucketsFull() throws IOException { ObjectId id = RevObjectTestSupport.hashString("fake"); long size = 100000000; int childTreeCount = 0; SortedSet<Bucket> bucketTrees = createBuckets(32); final RevTree tree = RevObjectFactory.defaultInstance().createTree(id, size, childTreeCount, bucketTrees); RevTree roundTripped = (RevTree) read(tree.getId(), write(tree)); assertTreesAreEqual(tree, roundTripped); }
public @Test void testCacheDisabled() { cache = createCache(0, 0L); CacheKey k1 = repo1Id.create(obj.getId()); cache.put(k1, obj); assertFalse(cache.contains(k1)); assertEquals(0L, cache.sizeBytes()); }