use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.
the class MultiValueCompositeIndexTest method getResultsIterator.
private Iterator getResultsIterator(String queryString, ShardQueryLogic logic) throws Exception {
MultivaluedMap<String, String> params = new MultivaluedMapImpl<>();
params.putSingle(QUERY_STRING, queryString);
params.putSingle(QUERY_NAME, "geoQuery");
params.putSingle(QUERY_LOGIC_NAME, "EventQueryLogic");
params.putSingle(QUERY_PERSISTENCE, "PERSISTENT");
params.putSingle(QUERY_AUTHORIZATIONS, AUTHS);
params.putSingle(QUERY_EXPIRATION, "20200101 000000.000");
params.putSingle(QUERY_BEGIN, BEGIN_DATE);
params.putSingle(QUERY_END, END_DATE);
QueryParameters queryParams = new QueryParametersImpl();
queryParams.validate(params);
Set<Authorizations> auths = new HashSet<>();
auths.add(new Authorizations(AUTHS));
Query query = new QueryImpl();
query.initialize(USER, Arrays.asList(USER_DN), null, queryParams, null);
ShardQueryConfiguration config = ShardQueryConfiguration.create(logic, query);
logic.initialize(config, instance.getConnector("root", PASSWORD), query, auths);
logic.setupQuery(config);
return logic.getTransformIterator(query);
}
use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.
the class NodeTransformVisitorTest method testPushdown.
private void testPushdown(String original, String expected, List<NodeTransformRule> rules) throws Exception {
// create a query tree
ASTJexlScript originalScript = JexlASTHelper.parseJexlQuery(original);
MockMetadataHelper helper = new MockMetadataHelper();
// apply the visitor
ASTJexlScript resultScript = NodeTransformVisitor.transform(originalScript, rules, new ShardQueryConfiguration(), helper);
// Verify the script is as expected, and has a valid lineage.
assertScriptEquality(resultScript, expected);
assertLineage(resultScript);
// Verify the original script was not modified, and still has a valid lineage.
assertScriptEquality(originalScript, original);
assertLineage(originalScript);
}
use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.
the class WhindexVisitorTest method reverseManyToManyUniqueIntersectsTest.
@Test
public void reverseManyToManyUniqueIntersectsTest() throws ParseException {
String query = "(TOPPINGS == 'BANANA' || TOPPINGS == 'HOT_FUDGE') && (geowave:intersects(ICE_CREAM, 'POLYGON((-20 -20, 20 -20, 20 20, -20 20, -20 -20))') || geowave:intersects(ICE_CREAM, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))'))";
ShardQueryConfiguration config = new ShardQueryConfiguration();
config.setWhindexMappingFields(mappingFields);
config.setWhindexFieldMappings(multipleFieldMapping);
ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
Assert.assertEquals("(geowave:intersects(BANANA_SPLIT, 'POLYGON((-20 -20, 20 -20, 20 20, -20 20, -20 -20))') || geowave:intersects(BANANA_SPLIT, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')) || (geowave:intersects(HOT_FUDGE_SUNDAE, 'POLYGON((-20 -20, 20 -20, 20 20, -20 20, -20 -20))') || geowave:intersects(HOT_FUDGE_SUNDAE, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))'))", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.
the class WhindexVisitorTest method manyToManyIntersectsTest.
@Test
public void manyToManyIntersectsTest() throws ParseException {
String query = "geowave:intersects((ICE_CREAM || SHERBERT), 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') && (TOPPINGS == 'HOT_FUDGE' || TOPPINGS == 'BANANA')";
ShardQueryConfiguration config = new ShardQueryConfiguration();
config.setWhindexMappingFields(mappingFields);
config.setWhindexFieldMappings(multipleFieldMapping);
ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
Assert.assertEquals("((TOPPINGS == 'HOT_FUDGE' && geowave:intersects(SHERBERT, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')) || geowave:intersects(HOT_FUDGE_SUNDAE, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')) || ((TOPPINGS == 'BANANA' && geowave:intersects(SHERBERT, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')) || geowave:intersects(BANANA_SPLIT, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))'))", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
use of datawave.query.config.ShardQueryConfiguration in project datawave by NationalSecurityAgency.
the class WhindexVisitorTest method oneToOneWithinBoundingBoxTest.
@Test
public void oneToOneWithinBoundingBoxTest() throws ParseException {
String query = "geo:within_bounding_box(ICE_CREAM, '-10_-10', '10_10') && TOPPINGS == 'HOT_FUDGE'";
ShardQueryConfiguration config = new ShardQueryConfiguration();
config.setWhindexMappingFields(mappingFields);
config.setWhindexFieldMappings(singleFieldMapping);
ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
Assert.assertEquals("geo:within_bounding_box(HOT_FUDGE_SUNDAE, '-10_-10', '10_10')", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Aggregations