Search in sources :

Example 21 with Node

use of org.locationtech.geogig.api.Node 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)

Example 22 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class ResponseWriter method writeTree.

public void writeTree(RevTree tree, String tag) throws XMLStreamException {
    out.writeStartElement(tag);
    writeElement("id", tree.getId().toString());
    writeElement("size", Long.toString(tree.size()));
    writeElement("numtrees", Integer.toString(tree.numTrees()));
    if (tree.trees().isPresent()) {
        ImmutableList<Node> trees = tree.trees().get();
        for (Node ref : trees) {
            writeNode(ref, "tree");
        }
    }
    if (tree.features().isPresent()) {
        ImmutableList<Node> features = tree.features().get();
        for (Node ref : features) {
            writeNode(ref, "feature");
        }
    } else if (tree.buckets().isPresent()) {
        Map<Integer, Bucket> buckets = tree.buckets().get();
        for (Entry<Integer, Bucket> entry : buckets.entrySet()) {
            Integer bucketIndex = entry.getKey();
            Bucket bucket = entry.getValue();
            out.writeStartElement("bucket");
            writeElement("bucketindex", bucketIndex.toString());
            writeElement("bucketid", bucket.id().toString());
            Envelope env = new Envelope();
            env.setToNull();
            bucket.expand(env);
            out.writeStartElement("bbox");
            writeElement("minx", Double.toString(env.getMinX()));
            writeElement("maxx", Double.toString(env.getMaxX()));
            writeElement("miny", Double.toString(env.getMinY()));
            writeElement("maxy", Double.toString(env.getMaxY()));
            out.writeEndElement();
            out.writeEndElement();
        }
    }
    out.writeEndElement();
}
Also used : DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Entry(java.util.Map.Entry) Bucket(org.locationtech.geogig.api.Bucket) Node(org.locationtech.geogig.api.Node) Envelope(com.vividsolutions.jts.geom.Envelope) Map(java.util.Map)

Example 23 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class WorkingTreeInsertHelper method findOrCreateTree.

private NodeRef findOrCreateTree(final String treePath, final FeatureType type) {
    RevTree tree = context.command(FindOrCreateSubtree.class).setChildPath(treePath).setIndex(true).setParent(workHead).setParentPath(NodeRef.ROOT).call();
    ObjectId metadataId = ObjectId.NULL;
    if (type != null) {
        RevFeatureType revFeatureType = RevFeatureTypeImpl.build(type);
        if (tree.isEmpty()) {
            indexDatabase.put(revFeatureType);
        }
        metadataId = revFeatureType.getId();
    }
    Envelope bounds = SpatialOps.boundsOf(tree);
    Node node = Node.create(NodeRef.nodeFromPath(treePath), tree.getId(), metadataId, TYPE.TREE, bounds);
    String parentPath = NodeRef.parentPath(treePath);
    return new NodeRef(node, parentPath, ObjectId.NULL);
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) FindOrCreateSubtree(org.locationtech.geogig.api.plumbing.FindOrCreateSubtree) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Envelope(com.vividsolutions.jts.geom.Envelope) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) RevTree(org.locationtech.geogig.api.RevTree)

Example 24 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class WorkingTreeInsertHelper method put.

public Node put(final ObjectId revFeatureId, final Feature feature) {
    final RevTreeBuilder2 treeBuilder = getTreeBuilder(feature);
    String fid = feature.getIdentifier().getID();
    BoundingBox bounds = feature.getBounds();
    FeatureType type = feature.getType();
    final Node node = treeBuilder.putFeature(revFeatureId, fid, bounds, type);
    return node;
}
Also used : FeatureType(org.opengis.feature.type.FeatureType) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) BoundingBox(org.opengis.geometry.BoundingBox) Node(org.locationtech.geogig.api.Node)

Example 25 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class FormatCommonV2 method readNode.

public static Node readNode(DataInput in) throws IOException {
    final int typeAndMasks = in.readByte() & 0xFF;
    final int nodeType = typeAndMasks & TYPE_READ_MASK;
    final int boundsMask = typeAndMasks & BOUNDS_READ_MASK;
    final int metadataMask = typeAndMasks & METADATA_READ_MASK;
    final RevObject.TYPE contentType = RevObject.TYPE.valueOf(nodeType);
    final String name = in.readUTF();
    final ObjectId objectId = readObjectId(in);
    ObjectId metadataId = ObjectId.NULL;
    if (metadataMask == METADATA_PRESENT_MASK) {
        metadataId = readObjectId(in);
    }
    @Nullable final Envelope bbox;
    if (boundsMask == BOUNDS_NULL_MASK) {
        bbox = null;
    } else if (boundsMask == BOUNDS_POINT_MASK) {
        bbox = readPointBoundingBox(in);
    } else if (boundsMask == BOUNDS_BOX2D_MASK) {
        bbox = readBoundingBox(in);
    } else {
        throw new IllegalStateException(String.format("Illegal bounds mask: %s, expected one of %s, %s, %s", toBinaryString(boundsMask), toBinaryString(BOUNDS_NULL_MASK), toBinaryString(BOUNDS_POINT_MASK), toBinaryString(BOUNDS_BOX2D_MASK)));
    }
    final Node node;
    node = Node.create(name, objectId, metadataId, contentType, bbox);
    return node;
}
Also used : TYPE(org.locationtech.geogig.api.RevObject.TYPE) RevObject(org.locationtech.geogig.api.RevObject) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Integer.toBinaryString(java.lang.Integer.toBinaryString) Envelope(com.vividsolutions.jts.geom.Envelope) Nullable(javax.annotation.Nullable)

Aggregations

Node (org.locationtech.geogig.api.Node)117 RevTree (org.locationtech.geogig.api.RevTree)56 Test (org.junit.Test)50 ObjectId (org.locationtech.geogig.api.ObjectId)44 NodeRef (org.locationtech.geogig.api.NodeRef)24 Bucket (org.locationtech.geogig.api.Bucket)20 TreeTestSupport.featureNode (org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode)18 Envelope (com.vividsolutions.jts.geom.Envelope)16 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)14 RevCommit (org.locationtech.geogig.api.RevCommit)10 Map (java.util.Map)9 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)9 Patch (org.locationtech.geogig.api.plumbing.diff.Patch)9 File (java.io.File)7 RevFeature (org.locationtech.geogig.api.RevFeature)7 WorkingTree (org.locationtech.geogig.repository.WorkingTree)7 Feature (org.opengis.feature.Feature)7 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7 Stopwatch (com.google.common.base.Stopwatch)6 SortedMap (java.util.SortedMap)5