Search in sources :

Example 1 with NodeStorageOrder

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);
}
Also used : Node(org.locationtech.geogig.api.Node) NodeStorageOrder(org.locationtech.geogig.storage.NodeStorageOrder) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 2 with NodeStorageOrder

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);
    }
}
Also used : Node(org.locationtech.geogig.api.Node) ArrayList(java.util.ArrayList) NodeStorageOrder(org.locationtech.geogig.storage.NodeStorageOrder)

Example 3 with NodeStorageOrder

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);
}
Also used : Node(org.locationtech.geogig.api.Node) Stopwatch(com.google.common.base.Stopwatch) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) NodeStorageOrder(org.locationtech.geogig.storage.NodeStorageOrder)

Aggregations

Node (org.locationtech.geogig.api.Node)3 NodeStorageOrder (org.locationtech.geogig.storage.NodeStorageOrder)3 ArrayList (java.util.ArrayList)2 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)2 Stopwatch (com.google.common.base.Stopwatch)1 List (java.util.List)1 Test (org.junit.Test)1 RevTree (org.locationtech.geogig.api.RevTree)1