Skip to content

Commit

Permalink
docGeoIntersectsTest: Try to add remove placements, to run query on s…
Browse files Browse the repository at this point in the history
…pecific adapter
  • Loading branch information
murermader committed Aug 28, 2024
1 parent 1374325 commit 87d612e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static <T> Pair<Bindable<T>, String> toBindable(

// TODO RB: Remove this
// (temporary hack, so that code compilation does not fail because exception of constructor is not caught)
// s = s.replace("new org.polypheny.db.type.entity.spatial.PolyGeometry(", "org.polypheny.db.type.entity.spatial.PolyGeometry.of(");
s = s.replace("new org.polypheny.db.type.entity.spatial.PolyGeometry(", "org.polypheny.db.type.entity.spatial.PolyGeometry.of(");

if ( RuntimeConfig.DEBUG.getBoolean() ) {
Util.debugCode( System.out, s );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ public PolySerializable copy() {
public Expression asExpression() {
// this basically calls a constructor with WKT

var ex = Expressions.call(PolyGeometry.class, "of", Expressions.constant(this.toString()));
// var ex = Expressions.call(PolyGeometry.class, "of", Expressions.constant(this.toString()));
var ex2 = Expressions.new_( PolyGeometry.class, Expressions.constant( this.toString() ) );

// TODO: Why doesn't this work?
Expand Down
107 changes: 45 additions & 62 deletions dbms/src/test/java/org/polypheny/db/mql/MqlGeoFunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class MqlGeoFunctionsTest extends MqlTestTemplate {
public static void init() {
namespaces.add( namespace );
namespaces.add( namespaceMongo );
addMongoDbAdapter();
}


Expand Down Expand Up @@ -83,7 +84,45 @@ public static void removeMongoDbAdapter() {

@Test
public void docGeoIntersectsTest() {
String geoIntersects = """
ArrayList<DocResult> results = new ArrayList<>();

for ( String ns : namespaces ) {
String createCollection = """
db.createCollection(%s)
""".formatted( ns );
execute( createCollection, ns );

if ( ns.equals( namespaceMongo ) ) {
execute( String.format( "db.%s.addPlacement(\"%s\")", ns, mongoAdapterName ) );
execute( String.format( "db.%s.deletePlacement(\"%s\")", ns, "hsqldb" ) );
} else {
execute( String.format( "db.%s.addPlacement(\"%s\")", ns, "hsqldb" ) );
execute( String.format( "db.%s.deletePlacement(\"%s\")", ns, mongoAdapterName ) );
}

String insertDocuments = """
db.%s.insertMany([
{
name: "Legacy [0,0]",
num: 1,
legacy: [0,0]
},
{
name: "Legacy [1,1]",
num: 2,
legacy: [1,1]
},
{
name: "Legacy [2,2]",
num: 3,
legacy: [2,2]
}
])
""".formatted( ns );
execute( insertDocuments, ns );

DocResult result;
String geoIntersects = """
db.%s.find({
legacy: {
$geoIntersects: {
Expand All @@ -94,68 +133,12 @@ public void docGeoIntersectsTest() {
}
}
})
""".formatted( collectionName );
var result = execute( geoIntersects, namespace );

""".formatted( ns );
result = execute( geoIntersects, ns );
results.add( result );
}

// ArrayList<DocResult> results = new ArrayList<>();
//
// for ( String collectionName : namespaces ) {
// String createCollection = """
// db.createCollection(%s)
// """.formatted( collectionName );
// execute( createCollection, namespace );
//
// if ( collectionName.equals( namespaceMongo ) ) {
// addMongoDbAdapter();
// // TODO: try to do the reverse, and add the hsqldb placement back in, so I can createMongo only once
// execute( String.format( "db.%s.addPlacement(\"%s\")", collectionName, mongoAdapterName ) );
// execute( String.format( "db.%s.deletePlacement(\"%s\")", collectionName, "hsqldb" ) );
// }
//
// String insertDocuments = """
// db.%s.insertMany([
// {
// name: "Legacy [0,0]",
// num: 1,
// legacy: [0,0]
// },
// {
// name: "Legacy [1,1]",
// num: 2,
// legacy: [1,1]
// },
// {
// name: "Legacy [2,2]",
// num: 3,
// legacy: [2,2]
// }
// ])
// """.formatted( collectionName );
// execute( insertDocuments, namespace );
//
// DocResult result;
// String geoIntersects = """
// db.%s.find({
// legacy: {
// $geoIntersects: {
// $geometry: {
// type: "Polygon",
// coordinates: [[ [0,0], [0,1], [1,1], [1,0], [0,0] ]]
// }
// }
// }
// })
// """.formatted( collectionName );
// result = execute( geoIntersects, namespace );
// results.add( result );
//
//// if ( ns.equals( namespaceMongo ) ) {
//// removeMongoDbAdapter();
//// }
// }
//
// compareResults( results.get( 0 ), results.get( 1 ) );
compareResults( results.get( 0 ), results.get( 1 ) );
}


Expand Down

0 comments on commit 87d612e

Please sign in to comment.