Search in sources :

Example 6 with ShardQueryConfiguration

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);
}
Also used : Authorizations(org.apache.accumulo.core.security.Authorizations) QueryImpl(datawave.webservice.query.QueryImpl) Query(datawave.webservice.query.Query) MultivaluedMapImpl(org.jboss.resteasy.specimpl.MultivaluedMapImpl) QueryParameters(datawave.webservice.query.QueryParameters) QueryParametersImpl(datawave.webservice.query.QueryParametersImpl) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) HashSet(java.util.HashSet)

Example 7 with ShardQueryConfiguration

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);
}
Also used : MockMetadataHelper(datawave.query.util.MockMetadataHelper) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration)

Example 8 with ShardQueryConfiguration

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));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 9 with ShardQueryConfiguration

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));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 10 with ShardQueryConfiguration

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));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)108 Test (org.junit.Test)75 ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)48 HashSet (java.util.HashSet)42 Date (java.util.Date)38 GeometryType (datawave.data.type.GeometryType)17 MetadataHelper (datawave.query.util.MetadataHelper)17 HashMap (java.util.HashMap)16 CompositeFunctionsTest (datawave.query.CompositeFunctionsTest)13 Query (datawave.webservice.query.Query)10 Authorizations (org.apache.accumulo.core.security.Authorizations)10 Before (org.junit.Before)10 QueryImpl (datawave.webservice.query.QueryImpl)9 QueryParameters (datawave.webservice.query.QueryParameters)9 QueryParametersImpl (datawave.webservice.query.QueryParametersImpl)9 MultivaluedMapImpl (org.jboss.resteasy.specimpl.MultivaluedMapImpl)8 MockMetadataHelper (datawave.query.util.MockMetadataHelper)7 JexlNode (org.apache.commons.jexl2.parser.JexlNode)6 ExceededOrThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededOrThresholdMarkerJexlNode)5 ExceededValueThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode)5