use of org.locationtech.geogig.storage.NodeStorageOrder in project GeoGig by boundlessgeo.
the class RevTreeBuilderTest method testNodeOrderPassSplitThreshold.
@Test
public void testNodeOrderPassSplitThreshold() {
final int splitThreshold = RevTree.NORMALIZED_SIZE_LIMIT;
List<Node> expectedOrder = nodes(splitThreshold + 1);
Collections.sort(expectedOrder, new NodeStorageOrder());
final List<Node> flat = expectedOrder.subList(0, splitThreshold);
RevTreeBuilder flatTreeBuilder = new RevTreeBuilder(odb);
RevTreeBuilder bucketTreeBuilder = new RevTreeBuilder(odb);
for (Node n : flat) {
flatTreeBuilder.put(n);
bucketTreeBuilder.put(n);
}
bucketTreeBuilder.put(expectedOrder.get(expectedOrder.size() - 1));
RevTree flatTree = flatTreeBuilder.build();
RevTree bucketTree = bucketTreeBuilder.build();
assertFalse(flatTree.buckets().isPresent());
assertTrue(bucketTree.buckets().isPresent());
odb.put(flatTree);
odb.put(bucketTree);
List<Node> flatNodes = lstree(flatTree);
assertEquals(flat, flatNodes);
List<Node> splitNodes = lstree(bucketTree);
assertEquals(expectedOrder, splitNodes);
}
use of org.locationtech.geogig.storage.NodeStorageOrder in project GeoGig by boundlessgeo.
the class AbstractNodeIndexTest method testOrder.
private void testOrder(final int count) throws Exception {
List<Node> expected = new ArrayList<Node>(count);
for (int i = 0; i < count; i++) {
Node node = node(i);
index.add(node);
expected.add(node);
}
Collections.sort(expected, new NodeStorageOrder());
Iterator<Node> nodeIterator = index.nodes();
List<Node> actual = Lists.newArrayList(nodeIterator);
assertEquals(expected.size(), actual.size());
for (int i = 0; i < expected.size(); i++) {
Node expectedNode = expected.get(i);
Node actualNode = actual.get(i);
assertEquals("At index " + i, expectedNode, actualNode);
}
}
use of org.locationtech.geogig.storage.NodeStorageOrder in project GeoGig by boundlessgeo.
the class RevTreeBuilderPerformanceTest method testInsertPartitioned.
private void testInsertPartitioned(int partitionSize) {
UnmodifiableIterator<List<Node>> partitions = Iterators.partition(nodes.iterator(), partitionSize);
RevTreeBuilder builder = new RevTreeBuilder(odb);
Stopwatch sw = Stopwatch.createStarted();
while (partitions.hasNext()) {
List<Node> partition = new ArrayList<Node>(partitions.next());
Collections.sort(partition, new NodeStorageOrder());
createTree(partition, builder, false);
}
System.err.println("Calling RevTreeBuilder.build()...");
builder.build();
sw.stop();
System.err.printf("-- Created tree with %d sorted partitioned size in %s\n", partitionSize, sw);
}
Aggregations