http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/157c0649/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerFilterIT.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerFilterIT.java b/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerFilterIT.java index 4ca6b4c..11c1d21 100644 --- a/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerFilterIT.java +++ b/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerFilterIT.java @@ -57,241 +57,241 @@ import com.vividsolutions.jts.io.WKTReader; import com.vividsolutions.jts.io.WKTWriter; public class MongoGeoIndexerFilterIT extends MongoTestBase { - private static final GeometryFactory GF = new GeometryFactory(); - private static final Geometry WASHINGTON_MONUMENT = GF.createPoint(new Coordinate(38.8895, 77.0353)); - private static final Geometry LINCOLN_MEMORIAL = GF.createPoint(new Coordinate(38.8893, 77.0502)); - private static final Geometry CAPITAL_BUILDING = GF.createPoint(new Coordinate(38.8899, 77.0091)); - private static final Geometry WHITE_HOUSE = GF.createPoint(new Coordinate(38.8977, 77.0365)); - - @Override - public void updateConfiguration(final MongoDBRdfConfiguration conf) { - conf.setBoolean(OptionalConfigUtils.USE_GEO, true); - conf.set(ConfigUtils.GEO_PREDICATES_LIST, "http://www.opengis.net/ont/geosparql#asWKT"); - conf.setBoolean(ConfigUtils.USE_MONGO, true); - } - - @Test - public void nearHappyUsesTest() throws Exception { - final Sail sail = GeoRyaSailFactory.getInstance(conf); - final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); - try { - populateRya(conn); - - //Only captial - String query = - "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" - + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" - + "SELECT * \n" // - + "WHERE { \n" - + " <urn:geo> geo:asWKT ?point .\n" - + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 0.0, 2000))" - + "}"; - - TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); - final List<BindingSet> results = new ArrayList<>(); - while (rez.hasNext()) { - final BindingSet bs = rez.next(); - results.add(bs); - } - assertEquals(1, results.size()); - assertEquals(CAPITAL_BUILDING, bindingToGeo(results.get(0))); - - //all but capital - query = - "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" - + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" - + "SELECT * \n" // - + "WHERE { \n" - + " <urn:geo> geo:asWKT ?point .\n" - + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 2000))" - + "}"; - - rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); - results.clear(); - while (rez.hasNext()) { - final BindingSet bs = rez.next(); - results.add(bs); - } - assertEquals(3, results.size()); - assertEquals(WASHINGTON_MONUMENT, bindingToGeo(results.get(0))); - assertEquals(WHITE_HOUSE, bindingToGeo(results.get(1))); - assertEquals(LINCOLN_MEMORIAL, bindingToGeo(results.get(2))); - - // all of them - query = - "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" - + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" - + "SELECT * \n" // - + "WHERE { \n" - + " <urn:geo> geo:asWKT ?point .\n" - + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 6000, 000))" - + "}"; - - rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); - results.clear(); - while (rez.hasNext()) { - final BindingSet bs = rez.next(); - results.add(bs); - } - assertEquals(4, results.size()); - assertEquals(WASHINGTON_MONUMENT, bindingToGeo(results.get(0))); - assertEquals(WHITE_HOUSE, bindingToGeo(results.get(1))); - assertEquals(LINCOLN_MEMORIAL, bindingToGeo(results.get(2))); - assertEquals(CAPITAL_BUILDING, bindingToGeo(results.get(3))); - - // donut, only 2 - query = - "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" - + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" - + "SELECT * \n" // - + "WHERE { \n" - + " <urn:geo> geo:asWKT ?point .\n" - + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 2000, 100))" - + "}"; - - rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); - results.clear(); - while (rez.hasNext()) { - final BindingSet bs = rez.next(); - results.add(bs); - } - assertEquals(2, results.size()); - assertEquals(WHITE_HOUSE, bindingToGeo(results.get(0))); - assertEquals(LINCOLN_MEMORIAL, bindingToGeo(results.get(1))); - - // all of them - query = - "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" - + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" - + "SELECT * \n" // - + "WHERE { \n" - + " <urn:geo> geo:asWKT ?point .\n" - + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral))" - + "}"; - rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); - results.clear(); - while (rez.hasNext()) { - final BindingSet bs = rez.next(); - results.add(bs); - } - assertEquals(4, results.size()); - assertEquals(WASHINGTON_MONUMENT, bindingToGeo(results.get(0))); - assertEquals(WHITE_HOUSE, bindingToGeo(results.get(1))); - assertEquals(LINCOLN_MEMORIAL, bindingToGeo(results.get(2))); - assertEquals(CAPITAL_BUILDING, bindingToGeo(results.get(3))); - } finally { - conn.close(); - sail.shutDown(); - } - } - - @Test(expected = MalformedQueryException.class) - public void near_invalidDistance() throws Exception { - final Sail sail = GeoRyaSailFactory.getInstance(conf); - final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); - try { - populateRya(conn); - - //Only captial - final String query = - "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" - + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" - + "SELECT * \n" // - + "WHERE { \n" - + " <urn:geo> geo:asWKT ?point .\n" - + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, distance))" - + "}"; - - conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); - } finally { - conn.close(); - sail.shutDown(); - } - } - - @Test(expected = IllegalArgumentException.class) - public void near_negativeDistance() throws Exception { - final Sail sail = GeoRyaSailFactory.getInstance(conf); - final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); - try { - populateRya(conn); - - //Only captial - final String query = - "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" - + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" - + "SELECT * \n" // - + "WHERE { \n" - + " <urn:geo> geo:asWKT ?point .\n" - + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, -100))" - + "}"; - - final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); - while(rez.hasNext()) { - rez.next(); - } - } finally { - conn.close(); - sail.shutDown(); - } - } - - @Test(expected = QueryEvaluationException.class) - public void tooManyArgumentsTest() throws Exception { - final Sail sail = GeoRyaSailFactory.getInstance(conf); - final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); - try { - populateRya(conn); - - // Only captial - final String query = - "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" - + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" - + "SELECT * \n" // - + "WHERE { \n" + " <urn:geo> geo:asWKT ?point .\n" - + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 100, 1000, 10))" - + "}"; - - conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); - } finally { - conn.close(); - sail.shutDown(); - } - } - - private void populateRya(final SailRepositoryConnection conn) throws Exception { - // geo 2x2 points - conn.begin(); - RyaStatement stmnt = statement(WASHINGTON_MONUMENT); - Statement statement = RyaToRdfConversions.convertStatement(stmnt); - conn.add(statement); - - stmnt = statement(LINCOLN_MEMORIAL); - statement = RyaToRdfConversions.convertStatement(stmnt); - conn.add(statement); - - stmnt = statement(CAPITAL_BUILDING); - statement = RyaToRdfConversions.convertStatement(stmnt); - conn.add(statement); - - stmnt = statement(WHITE_HOUSE); - statement = RyaToRdfConversions.convertStatement(stmnt); - conn.add(statement); - conn.commit(); - } - - private static Geometry bindingToGeo(final BindingSet bs) throws ParseException { - final WKTReader w = new WKTReader(); - return w.read(bs.getValue("point").stringValue()); - } - - private static RyaStatement statement(final Geometry geo) { - final ValueFactory vf = new ValueFactoryImpl(); - final Resource subject = vf.createURI("urn:geo"); - final URI predicate = GeoConstants.GEO_AS_WKT; - final WKTWriter w = new WKTWriter(); - final Value object = vf.createLiteral(w.write(geo), GeoConstants.XMLSCHEMA_OGC_WKT); - return RdfToRyaConversions.convertStatement(new StatementImpl(subject, predicate, object)); - } + private static final GeometryFactory GF = new GeometryFactory(); + private static final Geometry WASHINGTON_MONUMENT = GF.createPoint(new Coordinate(38.8895, 77.0353)); + private static final Geometry LINCOLN_MEMORIAL = GF.createPoint(new Coordinate(38.8893, 77.0502)); + private static final Geometry CAPITAL_BUILDING = GF.createPoint(new Coordinate(38.8899, 77.0091)); + private static final Geometry WHITE_HOUSE = GF.createPoint(new Coordinate(38.8977, 77.0365)); + + @Override + public void updateConfiguration(final MongoDBRdfConfiguration conf) { + conf.setBoolean(OptionalConfigUtils.USE_GEO, true); + conf.set(ConfigUtils.GEO_PREDICATES_LIST, "http://www.opengis.net/ont/geosparql#asWKT"); + conf.setBoolean(ConfigUtils.USE_MONGO, true); + } + + @Test + public void nearHappyUsesTest() throws Exception { + final Sail sail = GeoRyaSailFactory.getInstance(conf); + final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); + try { + populateRya(conn); + + //Only captial + String query = + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + + "SELECT * \n" // + + "WHERE { \n" + + " <urn:geo> geo:asWKT ?point .\n" + + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 0.0, 2000))" + + "}"; + + TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); + final List<BindingSet> results = new ArrayList<>(); + while (rez.hasNext()) { + final BindingSet bs = rez.next(); + results.add(bs); + } + assertEquals(1, results.size()); + assertEquals(CAPITAL_BUILDING, bindingToGeo(results.get(0))); + + //all but capital + query = + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + + "SELECT * \n" // + + "WHERE { \n" + + " <urn:geo> geo:asWKT ?point .\n" + + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 2000))" + + "}"; + + rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); + results.clear(); + while (rez.hasNext()) { + final BindingSet bs = rez.next(); + results.add(bs); + } + assertEquals(3, results.size()); + assertEquals(WASHINGTON_MONUMENT, bindingToGeo(results.get(0))); + assertEquals(WHITE_HOUSE, bindingToGeo(results.get(1))); + assertEquals(LINCOLN_MEMORIAL, bindingToGeo(results.get(2))); + + // all of them + query = + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + + "SELECT * \n" // + + "WHERE { \n" + + " <urn:geo> geo:asWKT ?point .\n" + + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 6000, 000))" + + "}"; + + rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); + results.clear(); + while (rez.hasNext()) { + final BindingSet bs = rez.next(); + results.add(bs); + } + assertEquals(4, results.size()); + assertEquals(WASHINGTON_MONUMENT, bindingToGeo(results.get(0))); + assertEquals(WHITE_HOUSE, bindingToGeo(results.get(1))); + assertEquals(LINCOLN_MEMORIAL, bindingToGeo(results.get(2))); + assertEquals(CAPITAL_BUILDING, bindingToGeo(results.get(3))); + + // donut, only 2 + query = + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + + "SELECT * \n" // + + "WHERE { \n" + + " <urn:geo> geo:asWKT ?point .\n" + + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 2000, 100))" + + "}"; + + rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); + results.clear(); + while (rez.hasNext()) { + final BindingSet bs = rez.next(); + results.add(bs); + } + assertEquals(2, results.size()); + assertEquals(WHITE_HOUSE, bindingToGeo(results.get(0))); + assertEquals(LINCOLN_MEMORIAL, bindingToGeo(results.get(1))); + + // all of them + query = + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + + "SELECT * \n" // + + "WHERE { \n" + + " <urn:geo> geo:asWKT ?point .\n" + + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral))" + + "}"; + rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); + results.clear(); + while (rez.hasNext()) { + final BindingSet bs = rez.next(); + results.add(bs); + } + assertEquals(4, results.size()); + assertEquals(WASHINGTON_MONUMENT, bindingToGeo(results.get(0))); + assertEquals(WHITE_HOUSE, bindingToGeo(results.get(1))); + assertEquals(LINCOLN_MEMORIAL, bindingToGeo(results.get(2))); + assertEquals(CAPITAL_BUILDING, bindingToGeo(results.get(3))); + } finally { + conn.close(); + sail.shutDown(); + } + } + + @Test(expected = MalformedQueryException.class) + public void near_invalidDistance() throws Exception { + final Sail sail = GeoRyaSailFactory.getInstance(conf); + final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); + try { + populateRya(conn); + + //Only captial + final String query = + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + + "SELECT * \n" // + + "WHERE { \n" + + " <urn:geo> geo:asWKT ?point .\n" + + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, distance))" + + "}"; + + conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); + } finally { + conn.close(); + sail.shutDown(); + } + } + + @Test(expected = IllegalArgumentException.class) + public void near_negativeDistance() throws Exception { + final Sail sail = GeoRyaSailFactory.getInstance(conf); + final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); + try { + populateRya(conn); + + //Only captial + final String query = + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + + "SELECT * \n" // + + "WHERE { \n" + + " <urn:geo> geo:asWKT ?point .\n" + + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, -100))" + + "}"; + + final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); + while(rez.hasNext()) { + rez.next(); + } + } finally { + conn.close(); + sail.shutDown(); + } + } + + @Test(expected = QueryEvaluationException.class) + public void tooManyArgumentsTest() throws Exception { + final Sail sail = GeoRyaSailFactory.getInstance(conf); + final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); + try { + populateRya(conn); + + // Only captial + final String query = + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + + "SELECT * \n" // + + "WHERE { \n" + " <urn:geo> geo:asWKT ?point .\n" + + " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 100, 1000, 10))" + + "}"; + + conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); + } finally { + conn.close(); + sail.shutDown(); + } + } + + private void populateRya(final SailRepositoryConnection conn) throws Exception { + // geo 2x2 points + conn.begin(); + RyaStatement stmnt = statement(WASHINGTON_MONUMENT); + Statement statement = RyaToRdfConversions.convertStatement(stmnt); + conn.add(statement); + + stmnt = statement(LINCOLN_MEMORIAL); + statement = RyaToRdfConversions.convertStatement(stmnt); + conn.add(statement); + + stmnt = statement(CAPITAL_BUILDING); + statement = RyaToRdfConversions.convertStatement(stmnt); + conn.add(statement); + + stmnt = statement(WHITE_HOUSE); + statement = RyaToRdfConversions.convertStatement(stmnt); + conn.add(statement); + conn.commit(); + } + + private static Geometry bindingToGeo(final BindingSet bs) throws ParseException { + final WKTReader w = new WKTReader(); + return w.read(bs.getValue("point").stringValue()); + } + + private static RyaStatement statement(final Geometry geo) { + final ValueFactory vf = new ValueFactoryImpl(); + final Resource subject = vf.createURI("urn:geo"); + final URI predicate = GeoConstants.GEO_AS_WKT; + final WKTWriter w = new WKTWriter(); + final Value object = vf.createLiteral(w.write(geo), GeoConstants.XMLSCHEMA_OGC_WKT); + return RdfToRyaConversions.convertStatement(new StatementImpl(subject, predicate, object)); + } }
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/157c0649/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java b/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java index 2d09a6c..bc4d870 100644 --- a/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java +++ b/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java @@ -126,28 +126,28 @@ public class MongoGeoIndexerSfTest extends MongoTestBase { @Test public void testEquals() throws Exception { - try(final MongoGeoIndexer g = new MongoGeoIndexer()) { - g.setConf(conf); - g.init(); - - g.storeStatement(statement(A)); - g.storeStatement(statement(B)); - g.storeStatement(statement(C)); - g.storeStatement(statement(D)); - g.storeStatement(statement(F)); - g.storeStatement(statement(E)); - // point - compare(g.queryEquals(F, EMPTY_CONSTRAINTS), F); - compare(g.queryEquals(point(2, 2), EMPTY_CONSTRAINTS), EMPTY_RESULTS); - - // line - compare(g.queryEquals(E, EMPTY_CONSTRAINTS), E); - compare(g.queryEquals(line(2, 2, 3, 3), EMPTY_CONSTRAINTS), EMPTY_RESULTS); - - // poly - compare(g.queryEquals(A, EMPTY_CONSTRAINTS), A); - compare(g.queryEquals(poly(bbox(1, 1, 4, 5)), EMPTY_CONSTRAINTS), EMPTY_RESULTS); - } + try(final MongoGeoIndexer g = new MongoGeoIndexer()) { + g.setConf(conf); + g.init(); + + g.storeStatement(statement(A)); + g.storeStatement(statement(B)); + g.storeStatement(statement(C)); + g.storeStatement(statement(D)); + g.storeStatement(statement(F)); + g.storeStatement(statement(E)); + // point + compare(g.queryEquals(F, EMPTY_CONSTRAINTS), F); + compare(g.queryEquals(point(2, 2), EMPTY_CONSTRAINTS), EMPTY_RESULTS); + + // line + compare(g.queryEquals(E, EMPTY_CONSTRAINTS), E); + compare(g.queryEquals(line(2, 2, 3, 3), EMPTY_CONSTRAINTS), EMPTY_RESULTS); + + // poly + compare(g.queryEquals(A, EMPTY_CONSTRAINTS), A); + compare(g.queryEquals(poly(bbox(1, 1, 4, 5)), EMPTY_CONSTRAINTS), EMPTY_RESULTS); + } } // @Test http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/157c0649/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java b/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java index 0e0fff2..5953132 100644 --- a/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java +++ b/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java @@ -57,7 +57,7 @@ public class MongoGeoIndexerTest extends MongoTestBase { GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 4326); @Override - public void updateConfiguration(final MongoDBRdfConfiguration conf) { + public void updateConfiguration(final MongoDBRdfConfiguration conf) { conf.set(ConfigUtils.GEO_PREDICATES_LIST, "http://www.opengis.net/ont/geosparql#asWKT"); conf.set(OptionalConfigUtils.USE_GEO, "true"); } @@ -65,8 +65,8 @@ public class MongoGeoIndexerTest extends MongoTestBase { @Test public void testRestrictPredicatesSearch() throws Exception { try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - conf.setStrings(ConfigUtils.GEO_PREDICATES_LIST, "pred:1,pred:2"); - f.setConf(conf); + conf.setStrings(ConfigUtils.GEO_PREDICATES_LIST, "pred:1,pred:2"); + f.setConf(conf); f.init(); final ValueFactory vf = new ValueFactoryImpl(); @@ -106,7 +106,7 @@ public class MongoGeoIndexerTest extends MongoTestBase { @Test public void testPrimeMeridianSearch() throws Exception { try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.setConf(conf); + f.setConf(conf); f.init(); final ValueFactory vf = new ValueFactoryImpl(); @@ -151,7 +151,7 @@ public class MongoGeoIndexerTest extends MongoTestBase { public void testDcSearch() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.setConf(conf); + f.setConf(conf); f.init(); final ValueFactory vf = new ValueFactoryImpl(); @@ -181,7 +181,7 @@ public class MongoGeoIndexerTest extends MongoTestBase { public void testDeleteSearch() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.setConf(conf); + f.setConf(conf); f.init(); final ValueFactory vf = new ValueFactoryImpl(); @@ -221,7 +221,7 @@ public class MongoGeoIndexerTest extends MongoTestBase { public void testDcSearchWithContext() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.setConf(conf); + f.setConf(conf); f.init(); final ValueFactory vf = new ValueFactoryImpl(); @@ -251,7 +251,7 @@ public class MongoGeoIndexerTest extends MongoTestBase { public void testDcSearchWithSubject() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.setConf(conf); + f.setConf(conf); f.init(); final ValueFactory vf = new ValueFactoryImpl(); @@ -280,7 +280,7 @@ public class MongoGeoIndexerTest extends MongoTestBase { public void testDcSearchWithSubjectAndContext() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.setConf(conf); + f.setConf(conf); f.init(); final ValueFactory vf = new ValueFactoryImpl(); @@ -314,7 +314,7 @@ public class MongoGeoIndexerTest extends MongoTestBase { public void testDcSearchWithPredicate() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.setConf(conf); + f.setConf(conf); f.init(); final ValueFactory vf = new ValueFactoryImpl(); @@ -345,7 +345,7 @@ public class MongoGeoIndexerTest extends MongoTestBase { public void testAntiMeridianSearch() throws Exception { // verify that a search works if the bounding box crosses the anti meridian try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.setConf(conf); + f.setConf(conf); f.init(); final ValueFactory vf = new ValueFactoryImpl(); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/157c0649/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java b/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java index cbb53e5..1c2a339 100644 --- a/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java +++ b/extras/rya.geoindexing/geo.mongo/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java @@ -55,7 +55,7 @@ import com.vividsolutions.jts.io.WKTWriter; public class MongoIndexerDeleteIT extends MongoTestBase { @Override - public void updateConfiguration(final MongoDBRdfConfiguration conf) { + public void updateConfiguration(final MongoDBRdfConfiguration conf) { conf.setStrings(ConfigUtils.FREETEXT_PREDICATES_LIST, new String[] {RDFS.LABEL.stringValue()}); conf.setStrings(ConfigUtils.TEMPORAL_PREDICATES_LIST, new String[] {"Property:atTime"}); conf.setBoolean(ConfigUtils.USE_FREETEXT, true); @@ -66,59 +66,59 @@ public class MongoIndexerDeleteIT extends MongoTestBase { @Test public void deleteTest() throws Exception { - final Sail sail = GeoRyaSailFactory.getInstance(conf); - final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); - try { - populateRya(conn); - final MongoClient client = conf.getMongoClient(); - - //The extra 1 is from the person type defined in freetext - assertEquals(8, client.getDatabase(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName()).count()); - assertEquals(4, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_geo").count()); - assertEquals(1, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_temporal").count()); - assertEquals(2, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_freetext").count()); - - //free text -- remove one from many - String delete = "DELETE DATA \n" // - + "{\n" - + " <urn:people> <http://www.w3.org/2000/01/rdf-schema#label> \"Alice Palace Hose\" " - + "}"; - Update update = conn.prepareUpdate(QueryLanguage.SPARQL, delete); - update.execute(); - - // temporal -- remove one from one - delete = "DELETE DATA \n" // - + "{\n" - + " <foo:time> <Property:atTime> \"0001-02-03T04:05:06Z\" " - + "}"; - - update = conn.prepareUpdate(QueryLanguage.SPARQL, delete); - update.execute(); - - //geo -- remove many from many - delete = - "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" - + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" - + "DELETE \n" // - + "{\n" - + " <urn:geo> geo:asWKT ?point \n" - + "}" - + "WHERE { \n" - + " <urn:geo> geo:asWKT ?point .\n" - + " FILTER(geof:sfWithin(?point, \"POLYGON((0 0, 2 0, 2 1, 0 1, 0 0))\"^^geo:wktLiteral))" - + "}"; - - update = conn.prepareUpdate(QueryLanguage.SPARQL, delete); - update.execute(); - - assertEquals(2, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_geo").count()); - assertEquals(0, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_temporal").count()); - assertEquals(1, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_freetext").count()); - assertEquals(4, client.getDatabase(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName()).count()); - } finally { - conn.close(); - sail.shutDown(); - } + final Sail sail = GeoRyaSailFactory.getInstance(conf); + final SailRepositoryConnection conn = new SailRepository(sail).getConnection(); + try { + populateRya(conn); + final MongoClient client = conf.getMongoClient(); + + //The extra 1 is from the person type defined in freetext + assertEquals(8, client.getDatabase(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName()).count()); + assertEquals(4, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_geo").count()); + assertEquals(1, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_temporal").count()); + assertEquals(2, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_freetext").count()); + + //free text -- remove one from many + String delete = "DELETE DATA \n" // + + "{\n" + + " <urn:people> <http://www.w3.org/2000/01/rdf-schema#label> \"Alice Palace Hose\" " + + "}"; + Update update = conn.prepareUpdate(QueryLanguage.SPARQL, delete); + update.execute(); + + // temporal -- remove one from one + delete = "DELETE DATA \n" // + + "{\n" + + " <foo:time> <Property:atTime> \"0001-02-03T04:05:06Z\" " + + "}"; + + update = conn.prepareUpdate(QueryLanguage.SPARQL, delete); + update.execute(); + + //geo -- remove many from many + delete = + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" + + "DELETE \n" // + + "{\n" + + " <urn:geo> geo:asWKT ?point \n" + + "}" + + "WHERE { \n" + + " <urn:geo> geo:asWKT ?point .\n" + + " FILTER(geof:sfWithin(?point, \"POLYGON((0 0, 2 0, 2 1, 0 1, 0 0))\"^^geo:wktLiteral))" + + "}"; + + update = conn.prepareUpdate(QueryLanguage.SPARQL, delete); + update.execute(); + + assertEquals(2, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_geo").count()); + assertEquals(0, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_temporal").count()); + assertEquals(1, client.getDatabase(conf.getMongoDBName()).getCollection("ryatest_freetext").count()); + assertEquals(4, client.getDatabase(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName()).count()); + } finally { + conn.close(); + sail.shutDown(); + } } private void populateRya(final SailRepositoryConnection conn) throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/157c0649/sail/src/main/java/org/apache/rya/rdftriplestore/RdfCloudTripleStoreConnection.java ---------------------------------------------------------------------- diff --git a/sail/src/main/java/org/apache/rya/rdftriplestore/RdfCloudTripleStoreConnection.java b/sail/src/main/java/org/apache/rya/rdftriplestore/RdfCloudTripleStoreConnection.java index eaf3033..921acaa 100644 --- a/sail/src/main/java/org/apache/rya/rdftriplestore/RdfCloudTripleStoreConnection.java +++ b/sail/src/main/java/org/apache/rya/rdftriplestore/RdfCloudTripleStoreConnection.java @@ -284,8 +284,8 @@ public class RdfCloudTripleStoreConnection extends SailConnectionBase { } try { - final List<Class<QueryOptimizer>> optimizers = conf.getOptimizers(); - final Class<QueryOptimizer> pcjOptimizer = conf.getPcjOptimizer(); + final List<Class<QueryOptimizer>> optimizers = queryConf.getOptimizers(); + final Class<QueryOptimizer> pcjOptimizer = queryConf.getPcjOptimizer(); if(pcjOptimizer != null) { QueryOptimizer opt = null; @@ -304,7 +304,7 @@ public class RdfCloudTripleStoreConnection extends SailConnectionBase { } final ParallelEvaluationStrategyImpl strategy = new ParallelEvaluationStrategyImpl( - new StoreTripleSource(conf, ryaDAO), inferenceEngine, dataset, queryConf); + new StoreTripleSource(queryConf, ryaDAO), inferenceEngine, dataset, queryConf); (new BindingAssigner()).optimize(tupleExpr, dataset, bindings); (new ConstantOptimizer(strategy)).optimize(tupleExpr, dataset, http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/157c0649/sail/src/test/java/org/apache/rya/RdfCloudTripleStoreConnectionTest.java ---------------------------------------------------------------------- diff --git a/sail/src/test/java/org/apache/rya/RdfCloudTripleStoreConnectionTest.java b/sail/src/test/java/org/apache/rya/RdfCloudTripleStoreConnectionTest.java index f34129e..8c926db 100644 --- a/sail/src/test/java/org/apache/rya/RdfCloudTripleStoreConnectionTest.java +++ b/sail/src/test/java/org/apache/rya/RdfCloudTripleStoreConnectionTest.java @@ -23,7 +23,9 @@ import static org.apache.rya.api.RdfCloudTripleStoreConstants.NAMESPACE; import java.io.InputStream; import java.util.List; -import junit.framework.TestCase; +import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.mock.MockInstance; import org.apache.rya.accumulo.AccumuloRdfConfiguration; import org.apache.rya.accumulo.AccumuloRyaDAO; import org.apache.rya.api.RdfCloudTripleStoreConfiguration; @@ -32,10 +34,6 @@ import org.apache.rya.rdftriplestore.RdfCloudTripleStore; import org.apache.rya.rdftriplestore.RyaSailRepository; import org.apache.rya.rdftriplestore.inference.InferenceEngine; import org.apache.rya.rdftriplestore.namespace.NamespaceManager; - -import org.apache.accumulo.core.client.Connector; -import org.apache.accumulo.core.client.Instance; -import org.apache.accumulo.core.client.mock.MockInstance; import org.openrdf.model.Literal; import org.openrdf.model.Model; import org.openrdf.model.Resource; @@ -62,6 +60,8 @@ import org.openrdf.repository.sail.SailRepository; import org.openrdf.rio.RDFFormat; import org.openrdf.rio.Rio; +import junit.framework.TestCase; + /** * Class RdfCloudTripleStoreConnectionTest * Date: Mar 3, 2011 @@ -1086,13 +1086,14 @@ public class RdfCloudTripleStoreConnectionTest extends TestCase { Update u = conn.prepareUpdate(QueryLanguage.SPARQL, sparqlUpdate); u.execute(); - String query = "PREFIX ex: <http://www.example.org/exampleDocument#>\n" + + String query = + "PREFIX ex: <http://www.example.org/exampleDocument#>\n" + "PREFIX voc: <http://www.example.org/vocabulary#>\n" + "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" + "\n" + "SELECT * \n" + -// "FROM NAMED <http://www.example.org/exampleDocument#G1>\n" + +// "FROM NAMED <http://www.example.org/exampleDocument#G1>\n" + "WHERE\n" + "{\n" + " GRAPH ex:G1\n" +
