@@ -216,6 +216,50 @@ public void testBulkUpsert(String dataStoreName) {
216216 assertEquals (5 , collection .count ());
217217 }
218218
219+ @ ParameterizedTest
220+ @ MethodSource ("databaseContextProvider" )
221+ public void testDeleteByDocFilter (String dataStoreName ) {
222+ Datastore datastore = datastoreMap .get (dataStoreName );
223+ Collection collection = datastore .getCollection (COLLECTION_NAME );
224+ Map <Key , Document > bulkMap = new HashMap <>();
225+ bulkMap .put (new SingleValueKey ("default" , "testKey1" ), Utils .createDocument ("field" , "value" ));
226+ bulkMap .put (new SingleValueKey ("default" , "testKey2" ), Utils .createDocument ("field" , "value" ));
227+ bulkMap .put (new SingleValueKey ("default" , "testKey3" ), Utils .createDocument ("field" , "value" ));
228+ bulkMap .put (new SingleValueKey ("default" , "testKey4" ), Utils .createDocument ("field" , "value" ));
229+ bulkMap .put (new SingleValueKey ("default" , "testKey5" ), Utils .createDocument ("field" , "value" ));
230+ bulkMap .put (
231+ new SingleValueKey ("default" , "testKey6" ),
232+ Utils .
createDocument (
"email" ,
"[email protected] " ));
233+
234+ assertTrue (collection .bulkUpsert (bulkMap ));
235+
236+ collection .delete (org .hypertrace .core .documentstore .Filter .eq ("field" , "value" ));
237+ assertEquals (1 , collection .count ());
238+ }
239+
240+ @ ParameterizedTest
241+ @ MethodSource ("databaseContextProvider" )
242+ public void testDeleteByFilterUnsupportedOperationException (String dataStoreName ) {
243+ Datastore datastore = datastoreMap .get (dataStoreName );
244+ Collection collection = datastore .getCollection (COLLECTION_NAME );
245+ Map <Key , Document > bulkMap = new HashMap <>();
246+ bulkMap .put (new SingleValueKey ("default" , "testKey1" ), Utils .createDocument ("field" , "value" ));
247+ bulkMap .put (new SingleValueKey ("default" , "testKey2" ), Utils .createDocument ("field" , "value" ));
248+ bulkMap .put (new SingleValueKey ("default" , "testKey3" ), Utils .createDocument ("field" , "value" ));
249+ bulkMap .put (new SingleValueKey ("default" , "testKey4" ), Utils .createDocument ("field" , "value" ));
250+ bulkMap .put (new SingleValueKey ("default" , "testKey5" ), Utils .createDocument ("field" , "value" ));
251+ bulkMap .put (
252+ new SingleValueKey ("default" , "testKey6" ),
253+ Utils .
createDocument (
"email" ,
"[email protected] " ));
254+
255+ assertTrue (collection .bulkUpsert (bulkMap ));
256+
257+ UnsupportedOperationException exception =
258+ assertThrows (UnsupportedOperationException .class , () -> collection .delete ((Filter ) null ));
259+ assertTrue (exception .getMessage ().contains ("Filter must be provided" ));
260+ assertEquals (6 , collection .count ());
261+ }
262+
219263 @ ParameterizedTest
220264 @ MethodSource ("databaseContextProvider" )
221265 public void testWithDifferentFieldTypes (String dataStoreName ) throws Exception {
@@ -612,14 +656,18 @@ public void testSubDocumentUpdate(String dataStoreName) throws IOException {
612656 Assertions .assertFalse (documents .isEmpty ());
613657
614658 // mongo
615- // {"_lastUpdateTime":{"$date":"2021-03-14T18:53:14.914Z"},"createdTime":1615747994870,"foo1":"bar1","lastUpdatedTime":1615747994920,"subdoc":{"subfoo1":"subbar1","nesteddoc":{"nestedfoo1":"nestedbar1"}}}
659+ // {"_lastUpdateTime":{"$date":"2021-03-14T18:53:14.914Z"},"createdTime":1615747994870,
660+ // "foo1":"bar1","lastUpdatedTime":1615747994920,"subdoc":{"subfoo1":"subbar1",
661+ // "nesteddoc":{"nestedfoo1":"nestedbar1"}}}
616662
617663 // postgres
618- // {"foo1":"bar1","subdoc":{"subfoo1":"subbar1","nesteddoc":{"nestedfoo1":"nestedbar1"}},"created_at":"2021-03-15 00:24:50.981147","updated_at":"2021-03-15 00:24:50.981147"}
664+ // {"foo1":"bar1","subdoc":{"subfoo1":"subbar1","nesteddoc":{"nestedfoo1":"nestedbar1"}},
665+ // "created_at":"2021-03-15 00:24:50.981147","updated_at":"2021-03-15 00:24:50.981147"}
619666 System .out .println (documents .get (0 ).toJson ());
620667 ObjectNode jsonNode = (ObjectNode ) OBJECT_MAPPER .readTree (documents .get (0 ).toJson ());
621668 String expected =
622- "{\" foo1\" :\" bar1\" ,\" subdoc\" :{\" subfoo1\" :\" subbar1\" ,\" nesteddoc\" :{\" nestedfoo1\" :\" nestedbar1\" }}}" ;
669+ "{\" foo1\" :\" bar1\" ,\" subdoc\" :{\" subfoo1\" :\" subbar1\" ,"
670+ + "\" nesteddoc\" :{\" nestedfoo1\" :\" nestedbar1\" }}}" ;
623671 if (isMongo (dataStoreName )) {
624672 jsonNode .remove (MONGO_CREATED_TIME_KEY );
625673 jsonNode .remove (MONGO_LAST_UPDATE_TIME_KEY );
@@ -1044,7 +1092,13 @@ public void testSearchForNestedKey(String dataStoreName) throws IOException {
10441092 Datastore datastore = datastoreMap .get (dataStoreName );
10451093 Collection collection = datastore .getCollection (COLLECTION_NAME );
10461094 String documentString =
1047- "{\" attributes\" :{\" trace_id\" :{\" value\" :{\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
1095+ "{\" attributes\" :{\" trace_id\" :{\" value\" :{\" string\" :\" 00000000000000005e194fdf9fbf5101"
1096+ + "\" }},\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},"
1097+ + "\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},"
1098+ + "\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},"
1099+ + "\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,"
1100+ + "\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string"
1101+ + "\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
10481102 Document document = new JSONDocument (documentString );
10491103 SingleValueKey key = new SingleValueKey ("default" , "testKey1" );
10501104 collection .upsert (key , document );
@@ -1067,19 +1121,42 @@ public void testSearch(String dataStoreName) throws IOException {
10671121 Datastore datastore = datastoreMap .get (dataStoreName );
10681122 Collection collection = datastore .getCollection (COLLECTION_NAME );
10691123 String docStr1 =
1070- "{\" amount\" :1234.5,\" testKeyExist\" :null,\" attributes\" :{\" trace_id\" :{\" value\" :{\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
1124+ "{\" amount\" :1234.5,\" testKeyExist\" :null,"
1125+ + "\" attributes\" :{\" trace_id\" :{\" value\" :{\" string"
1126+ + "\" :\" 00000000000000005e194fdf9fbf5101\" }},"
1127+ + "\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},"
1128+ + "\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},"
1129+ + "\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},"
1130+ + "\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,"
1131+ + "\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string"
1132+ + "\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
10711133 Document document1 = new JSONDocument (docStr1 );
10721134 SingleValueKey key1 = new SingleValueKey ("default" , "testKey1" );
10731135 collection .upsert (key1 , document1 );
10741136
10751137 String docStr2 =
1076- "{\" amount\" :1234,\" testKeyExist\" :123,\" attributes\" :{\" trace_id\" :{\" value\" :{\" testKeyExistNested\" :123,\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
1138+ "{\" amount\" :1234,\" testKeyExist\" :123,"
1139+ + "\" attributes\" :{\" trace_id\" :{\" value\" :{\" testKeyExistNested\" :123,"
1140+ + "\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},"
1141+ + "\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},"
1142+ + "\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},"
1143+ + "\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},"
1144+ + "\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,"
1145+ + "\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string"
1146+ + "\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
10771147 Document document2 = new JSONDocument (docStr2 );
10781148 SingleValueKey key2 = new SingleValueKey ("default" , "testKey2" );
10791149 collection .upsert (key2 , document2 );
10801150
10811151 String docStr3 =
1082- "{\" attributes\" :{\" trace_id\" :{\" value\" :{\" testKeyExistNested\" :null,\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
1152+ "{\" attributes\" :{\" trace_id\" :{\" value\" :{\" testKeyExistNested\" :null,"
1153+ + "\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},"
1154+ + "\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},"
1155+ + "\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},"
1156+ + "\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},"
1157+ + "\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,"
1158+ + "\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string"
1159+ + "\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
10831160 Document document3 = new JSONDocument (docStr3 );
10841161 SingleValueKey key3 = new SingleValueKey ("default" , "testKey3" );
10851162 collection .upsert (key3 , document3 );
@@ -1337,19 +1414,42 @@ public void testSearchIteratorInterface(String dataStoreName) throws IOException
13371414 Datastore datastore = datastoreMap .get (dataStoreName );
13381415 Collection collection = datastore .getCollection (COLLECTION_NAME );
13391416 String docStr1 =
1340- "{\" amount\" :1234.5,\" testKeyExist\" :null,\" attributes\" :{\" trace_id\" :{\" value\" :{\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
1417+ "{\" amount\" :1234.5,\" testKeyExist\" :null,"
1418+ + "\" attributes\" :{\" trace_id\" :{\" value\" :{\" string"
1419+ + "\" :\" 00000000000000005e194fdf9fbf5101\" }},"
1420+ + "\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},"
1421+ + "\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},"
1422+ + "\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},"
1423+ + "\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,"
1424+ + "\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string"
1425+ + "\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
13411426 Document document1 = new JSONDocument (docStr1 );
13421427 SingleValueKey key1 = new SingleValueKey ("default" , "testKey1" );
13431428 collection .upsert (key1 , document1 );
13441429
13451430 String docStr2 =
1346- "{\" amount\" :1234,\" testKeyExist\" :123,\" attributes\" :{\" trace_id\" :{\" value\" :{\" testKeyExistNested\" :123,\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
1431+ "{\" amount\" :1234,\" testKeyExist\" :123,"
1432+ + "\" attributes\" :{\" trace_id\" :{\" value\" :{\" testKeyExistNested\" :123,"
1433+ + "\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},"
1434+ + "\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},"
1435+ + "\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},"
1436+ + "\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},"
1437+ + "\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,"
1438+ + "\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string"
1439+ + "\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
13471440 Document document2 = new JSONDocument (docStr2 );
13481441 SingleValueKey key2 = new SingleValueKey ("default" , "testKey2" );
13491442 collection .upsert (key2 , document2 );
13501443
13511444 String docStr3 =
1352- "{\" attributes\" :{\" trace_id\" :{\" value\" :{\" testKeyExistNested\" :null,\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
1445+ "{\" attributes\" :{\" trace_id\" :{\" value\" :{\" testKeyExistNested\" :null,"
1446+ + "\" string\" :\" 00000000000000005e194fdf9fbf5101\" }},"
1447+ + "\" span_id\" :{\" value\" :{\" string\" :\" 6449f1f720c93a67\" }},"
1448+ + "\" service_type\" :{\" value\" :{\" string\" :\" JAEGER_SERVICE\" }},"
1449+ + "\" FQN\" :{\" value\" :{\" string\" :\" driver\" }}},"
1450+ + "\" entityId\" :\" e3ffc6f0-fc92-3a9c-9fa0-26269184d1aa\" ,\" entityName\" :\" driver\" ,"
1451+ + "\" entityType\" :\" SERVICE\" ,\" identifyingAttributes\" :{\" FQN\" :{\" value\" :{\" string"
1452+ + "\" :\" driver\" }}},\" tenantId\" :\" __default\" }" ;
13531453 Document document3 = new JSONDocument (docStr3 );
13541454 SingleValueKey key3 = new SingleValueKey ("default" , "testKey3" );
13551455 collection .upsert (key3 , document3 );
@@ -1379,7 +1479,9 @@ public void testSearchIteratorInterface(String dataStoreName) throws IOException
13791479 List <Document > documents = new ArrayList <>();
13801480 while (true ) {
13811481 documents .add (results .next ());
1382- if (!results .hasNext ()) break ;
1482+ if (!results .hasNext ()) {
1483+ break ;
1484+ }
13831485 }
13841486 Assertions .assertEquals (1 , documents .size ());
13851487 }
@@ -1425,10 +1527,9 @@ private Map<String, List<CreateUpdateTestThread>> executeCreateUpdateThreads(
14251527 }
14261528
14271529 /**
1428- * mongo
1429- * {"_lastUpdateTime":{"$date":"2021-03-14T15:43:04.842Z"},"createdTime":1615736584763,"foo1":"bar1","lastUpdatedTime":1615736584763}
1430- * postgres {"foo1":"bar1","created_at":"2021-03-14 21:20:00.178909","updated_at":"2021-03-14
1431- * 21:20:00.178909"}
1530+ * mongo {"_lastUpdateTime":{"$date":"2021-03-14T15:43:04.842Z"},"createdTime":1615736584763,
1531+ * "foo1":"bar1","lastUpdatedTime":1615736584763} postgres {"foo1":"bar1","created_at":"2021-03-14
1532+ * 21:20:00.178909","updated_at":"2021-03-14 21:20:00.178909"}
14321533 */
14331534 private static void verifyTimeRelatedFieldsPresent (String doc , String dataStoreName ) {
14341535 if (isMongo (dataStoreName )) {
0 commit comments