Skip to content

Commit

Permalink
Changes from meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
murermader committed Aug 28, 2024
1 parent d50f158 commit 1374325
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 44 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,10 +883,13 @@ 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 ex2 = Expressions.new_( PolyGeometry.class, Expressions.constant( this.toString() ) );

// TODO: Why doesn't this work?
// return Expressions.call(PolyGeometry.class, "of", Expressions.constant(this.toString()));
return ex2;

return Expressions.new_( PolyGeometry.class, Expressions.constant( this.toString() ) );
// return Expressions.new_( PolyGeometry.class, Expressions.constant( this.toString() ) );
}


Expand Down
102 changes: 61 additions & 41 deletions dbms/src/test/java/org/polypheny/db/mql/MqlGeoFunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,42 +80,10 @@ public static void removeMongoDbAdapter() {
}
}

private void executeOnMongoAndInternally(){

}

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

for ( String ns : namespaces ) {
if ( ns.equals( namespaceMongo ) ) {
addMongoDbAdapter();
}

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 = """
String geoIntersects = """
db.%s.find({
legacy: {
$geoIntersects: {
Expand All @@ -126,16 +94,68 @@ public void docGeoIntersectsTest() {
}
}
})
""".formatted( ns );
result = execute( geoIntersects, ns );
results.add( result );
""".formatted( collectionName );
var result = execute( geoIntersects, namespace );

if ( ns.equals( namespaceMongo ) ) {
removeMongoDbAdapter();
}
}

compareResults( results.get( 0 ), results.get( 1 ) );
// 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 ) );
}


Expand Down

0 comments on commit 1374325

Please sign in to comment.