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);
}
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();
}
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);
}
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;
}
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;
}
Aggregations