Search in sources :

Example 1 with JexlControlledQueryParser

use of datawave.query.language.parser.jexl.JexlControlledQueryParser in project datawave by NationalSecurityAgency.

the class GroupingTest method testGroupingUsingLuceneFunction.

@Test
public void testGroupingUsingLuceneFunction() throws Exception {
    Map<String, String> extraParameters = new HashMap<>();
    extraParameters.put("group.fields.batch.size", "6");
    Date startDate = format.parse("20091231");
    Date endDate = format.parse("20150101");
    String queryString = "(UUID:C* or UUID:S* ) and #GROUPBY('AGE','$GENDER')";
    // @formatter:off
    Map<String, Integer> expectedMap = ImmutableMap.<String, Integer>builder().put("FEMALE-18", 2).put("MALE-30", 1).put("MALE-34", 1).put("MALE-16", 1).put("MALE-40", 2).put("MALE-20", 2).put("MALE-24", 1).put("MALE-22", 2).build();
    // @formatter:on
    logic.setParser(new LuceneToJexlQueryParser());
    for (RebuildingScannerTestHelper.TEARDOWN teardown : TEARDOWNS) {
        for (RebuildingScannerTestHelper.INTERRUPT interrupt : INTERRUPTS) {
            runTestQueryWithGrouping(expectedMap, queryString, startDate, endDate, extraParameters, teardown, interrupt);
        }
    }
    logic.setParser(new JexlControlledQueryParser());
}
Also used : HashMap(java.util.HashMap) RebuildingScannerTestHelper(datawave.query.RebuildingScannerTestHelper) LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Date(java.util.Date) JexlControlledQueryParser(datawave.query.language.parser.jexl.JexlControlledQueryParser) Test(org.junit.Test)

Example 2 with JexlControlledQueryParser

use of datawave.query.language.parser.jexl.JexlControlledQueryParser in project datawave by NationalSecurityAgency.

the class GroupingTestWithModel method testGroupingUsingLuceneFunction.

@Test
public void testGroupingUsingLuceneFunction() throws Exception {
    Map<String, String> extraParameters = new HashMap<>();
    extraParameters.put("group.fields.batch.size", "6");
    Date startDate = format.parse("20091231");
    Date endDate = format.parse("20150101");
    String queryString = "(UUID:C* or UUID:S* ) and #GROUPBY('AG','GEN')";
    // @formatter:off
    Map<String, Integer> expectedMap = ImmutableMap.<String, Integer>builder().put("FEMALE-18", 2).put("MALE-30", 1).put("MALE-34", 1).put("MALE-16", 1).put("MALE-40", 2).put("MALE-20", 2).put("MALE-24", 1).put("MALE-22", 2).build();
    // @formatter:on
    logic.setParser(new LuceneToJexlQueryParser());
    for (RebuildingScannerTestHelper.TEARDOWN teardown : TEARDOWNS) {
        for (RebuildingScannerTestHelper.INTERRUPT interrupt : INTERRUPTS) {
            runTestQueryWithGrouping(expectedMap, queryString, startDate, endDate, extraParameters, teardown, interrupt);
        }
    }
    logic.setParser(new JexlControlledQueryParser());
}
Also used : HashMap(java.util.HashMap) RebuildingScannerTestHelper(datawave.query.RebuildingScannerTestHelper) LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Date(java.util.Date) JexlControlledQueryParser(datawave.query.language.parser.jexl.JexlControlledQueryParser) Test(org.junit.Test)

Example 3 with JexlControlledQueryParser

use of datawave.query.language.parser.jexl.JexlControlledQueryParser in project datawave by NationalSecurityAgency.

the class GroupingTest method testGroupingUsingLuceneFunctionWithDuplicateValues.

@Test
public void testGroupingUsingLuceneFunctionWithDuplicateValues() throws Exception {
    Map<String, String> extraParameters = new HashMap<>();
    extraParameters.put("group.fields.batch.size", "6");
    Date startDate = format.parse("20091231");
    Date endDate = format.parse("20150101");
    String queryString = "(UUID:CORLEONE) and #GROUPBY('AGE','BIRTHDAY')";
    // @formatter:off
    Map<String, Integer> expectedMap = ImmutableMap.<String, Integer>builder().put("4-18", 1).put("5-40", 1).put("3-20", 1).put("1-24", 1).put("2-22", 1).put("22-22", 1).build();
    // @formatter:on
    logic.setParser(new LuceneToJexlQueryParser());
    for (RebuildingScannerTestHelper.TEARDOWN teardown : TEARDOWNS) {
        for (RebuildingScannerTestHelper.INTERRUPT interrupt : INTERRUPTS) {
            runTestQueryWithGrouping(expectedMap, queryString, startDate, endDate, extraParameters, teardown, interrupt);
        }
    }
    logic.setParser(new JexlControlledQueryParser());
}
Also used : HashMap(java.util.HashMap) RebuildingScannerTestHelper(datawave.query.RebuildingScannerTestHelper) LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Date(java.util.Date) JexlControlledQueryParser(datawave.query.language.parser.jexl.JexlControlledQueryParser) Test(org.junit.Test)

Aggregations

RebuildingScannerTestHelper (datawave.query.RebuildingScannerTestHelper)3 JexlControlledQueryParser (datawave.query.language.parser.jexl.JexlControlledQueryParser)3 LuceneToJexlQueryParser (datawave.query.language.parser.jexl.LuceneToJexlQueryParser)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 Test (org.junit.Test)3