@Benchmark public Object stContainsInnerPointDeserialized(BenchmarkData data) { return data.ogcGeometry.contains(data.innerOgcPoint); }
@Benchmark public Object stContainsOuterPointInEnvelopeDeserialized(BenchmarkData data) { return data.ogcGeometry.contains(data.outerOgcPointInEnvelope); }
@Benchmark public Object stContainsOuterPointNotInEnvelopeDeserialized(BenchmarkData data) { return data.ogcGeometry.contains(data.outerOgcPointNotInEnvelope); }
public void eval() { com.esri.core.geometry.ogc.OGCGeometry geom1; com.esri.core.geometry.ogc.OGCGeometry geom2; geom1 = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geom1Param.buffer.nioBuffer(geom1Param.start, geom1Param.end - geom1Param.start)); geom2 = com.esri.core.geometry.ogc.OGCGeometry .fromBinary(geom2Param.buffer.nioBuffer(geom2Param.start, geom2Param.end - geom2Param.start)); out.value = geom1.contains(geom2) ? 1 : 0; } }
private void assertSpatialJoin(TaskContext taskContext, Type joinType, RowPagesBuilder buildPages, RowPagesBuilder probePages, MaterializedResult expected) { DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext(); PagesSpatialIndexFactory pagesSpatialIndexFactory = buildIndex(driverContext, (build, probe, r) -> build.contains(probe), Optional.empty(), Optional.empty(), buildPages); OperatorFactory joinOperatorFactory = new SpatialJoinOperatorFactory(2, new PlanNodeId("test"), joinType, probePages.getTypes(), Ints.asList(1), 0, Optional.empty(), pagesSpatialIndexFactory); assertOperatorEquals(joinOperatorFactory, driverContext, probePages.build(), expected); }
@SqlNullable @Description("Returns TRUE if and only if no points of right lie in the exterior of left, and at least one point of the interior of left lies in the interior of right") @ScalarFunction("ST_Contains") @SqlType(BOOLEAN) public static Boolean stContains(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) { if (!envelopes(left, right, Envelope::contains)) { return false; } OGCGeometry leftGeometry = deserialize(left); OGCGeometry rightGeometry = deserialize(right); verifySameSpatialReference(leftGeometry, rightGeometry); return leftGeometry.contains(rightGeometry); }
.pageBreak() .row(POLYGON_B, "B"); PagesSpatialIndexFactory pagesSpatialIndexFactory = buildIndex(driverContext, (build, probe, r) -> build.contains(probe), Optional.empty(), Optional.of(filterFunction), buildPages);
@Test public void testDistributedSpatialJoin() { TaskContext taskContext = createTaskContext(); DriverContext driverContext = taskContext.addPipelineContext(0, true, true, true).addDriverContext(); RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR, INTEGER)) .row(POLYGON_A, "A", 1) .row(POLYGON_A, "A", 2) .row(null, "null", null) .pageBreak() .row(POLYGON_B, "B", 0) .row(POLYGON_B, "B", 2); RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR, INTEGER)) .row(POINT_X, "x", 2) .row(null, "null", null) .row(POINT_Y, "y", 2) .pageBreak() .row(POINT_Z, "z", 0); MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)) .row("x", "A") .row("y", "A") .row("y", "B") .row("z", "B") .build(); PagesSpatialIndexFactory pagesSpatialIndexFactory = buildIndex(driverContext, (build, probe, r) -> build.contains(probe), Optional.empty(), Optional.of(2), Optional.of(KDB_TREE_JSON), Optional.empty(), buildPages); OperatorFactory joinOperatorFactory = new SpatialJoinOperatorFactory(2, new PlanNodeId("test"), INNER, probePages.getTypes(), Ints.asList(1), 0, Optional.of(2), pagesSpatialIndexFactory); assertOperatorEquals(joinOperatorFactory, driverContext, probePages.build(), expected); }
public boolean within(OGCGeometry another) { return another.contains(this); }
@Benchmark public Object stContainsInnerPointDeserialized(BenchmarkData data) { return data.ogcGeometry.contains(data.innerOgcPoint); }
@Benchmark public Object stContainsOuterPointInEnvelopeDeserialized(BenchmarkData data) { return data.ogcGeometry.contains(data.outerOgcPointInEnvelope); }
@Benchmark public Object stContainsOuterPointNotInEnvelopeDeserialized(BenchmarkData data) { return data.ogcGeometry.contains(data.outerOgcPointNotInEnvelope); }
@Benchmark public Object stContainsOuterPointNotInEnvelopeDeserialized(BenchmarkData data) { return data.ogcGeometry.contains(data.outerOgcPointNotInEnvelope); }
@Benchmark public Object stContainsInnerPointDeserialized(BenchmarkData data) { return data.ogcGeometry.contains(data.innerOgcPoint); }
@Benchmark public Object stContainsOuterPointInEnvelopeDeserialized(BenchmarkData data) { return data.ogcGeometry.contains(data.outerOgcPointInEnvelope); }
@Override public Boolean exec(Tuple input) throws IOException { OGCGeometry geom1 = null, geom2 = null; try { geom1 = geometryParser.parseGeom(input.get(0)); geom2 = geometryParser.parseGeom(input.get(1)); return geom1.contains(geom2); } catch (ExecException ee) { throw new GeoException(geom1, geom2, ee); } }
@SqlNullable @Description("Returns TRUE if and only if no points of right lie in the exterior of left, and at least one point of the interior of left lies in the interior of right") @ScalarFunction("ST_Contains") @SqlType(BOOLEAN) public static Boolean stContains(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) { if (!envelopes(left, right, Envelope::contains)) { return false; } OGCGeometry leftGeometry = deserialize(left); OGCGeometry rightGeometry = deserialize(right); verifySameSpatialReference(leftGeometry, rightGeometry); return leftGeometry.contains(rightGeometry); }
private void assertSpatialJoin(TaskContext taskContext, Type joinType, RowPagesBuilder buildPages, RowPagesBuilder probePages, MaterializedResult expected) { DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext(); PagesSpatialIndexFactory pagesSpatialIndexFactory = buildIndex(driverContext, (build, probe, r) -> build.contains(probe), Optional.empty(), Optional.empty(), buildPages); OperatorFactory joinOperatorFactory = new SpatialJoinOperatorFactory(2, new PlanNodeId("test"), joinType, probePages.getTypes(), Ints.asList(1), 0, Optional.empty(), pagesSpatialIndexFactory); assertOperatorEquals(joinOperatorFactory, driverContext, probePages.build(), expected); }
private void assertSpatialJoin(TaskContext taskContext, Type joinType, RowPagesBuilder buildPages, RowPagesBuilder probePages, MaterializedResult expected) { DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext(); PagesSpatialIndexFactory pagesSpatialIndexFactory = buildIndex(driverContext, (build, probe, r) -> build.contains(probe), Optional.empty(), Optional.empty(), buildPages); OperatorFactory joinOperatorFactory = new SpatialJoinOperatorFactory(2, new PlanNodeId("test"), joinType, probePages.getTypes(), Ints.asList(1), 0, Optional.empty(), pagesSpatialIndexFactory); assertOperatorEquals(joinOperatorFactory, driverContext, probePages.build(), expected); }