Search in sources :

Example 21 with NumberType

use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.

the class RangeStreamTest method testOrOneFieldIndexed.

@Test
public void testOrOneFieldIndexed() throws Exception {
    String originalQuery = "(FOO == 'bag' || TACO == 'ba')";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(originalQuery);
    config.setBeginDate(new Date(0));
    config.setEndDate(new Date(System.currentTimeMillis()));
    Multimap<String, Type<?>> dataTypes = HashMultimap.create();
    dataTypes.putAll("FOO", Sets.newHashSet(new LcNoDiacriticsType()));
    dataTypes.putAll("NUM", Sets.newHashSet(new NumberType()));
    config.setQueryFieldsDatatypes(dataTypes);
    config.setIndexedFields(dataTypes);
    MockMetadataHelper helper = new MockMetadataHelper();
    helper.setIndexedFields(dataTypes.keySet());
    helper.addFields(ImmutableSet.of("TACO"));
    assertFalse(new RangeStream(config, new ScannerFactory(config.getConnector()), helper).streamPlans(script).iterator().hasNext());
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) MockMetadataHelper(datawave.query.util.MockMetadataHelper) NoOpType(datawave.data.type.NoOpType) NumberType(datawave.data.type.NumberType) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) Type(datawave.data.type.Type) NumberType(datawave.data.type.NumberType) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ScannerFactory(datawave.query.tables.ScannerFactory) Test(org.junit.Test)

Example 22 with NumberType

use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.

the class RangeStreamTest method testShardAndDaysHints.

public void testShardAndDaysHints(String originalQuery) throws Exception {
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(originalQuery);
    config.setBeginDate(new Date(0));
    config.setEndDate(new Date(System.currentTimeMillis()));
    Multimap<String, Type<?>> dataTypes = HashMultimap.create();
    dataTypes.putAll("FOO", Sets.newHashSet(new LcNoDiacriticsType()));
    dataTypes.putAll("NUM", Sets.newHashSet(new NumberType()));
    config.setQueryFieldsDatatypes(dataTypes);
    config.setIndexedFields(dataTypes);
    MockMetadataHelper helper = new MockMetadataHelper();
    helper.setIndexedFields(dataTypes.keySet());
    Set<Range> expectedRanges = Sets.newHashSet();
    for (String shard : Lists.newArrayList("20190314_0", "20190314_1", "20190314_9")) {
        expectedRanges.add(makeTestRange(shard, "datatype1\u0000345"));
        expectedRanges.add(makeTestRange(shard, "datatype1\u0000456"));
        expectedRanges.add(makeTestRange(shard, "datatype1\u0000567"));
    }
    for (String shard : Lists.newArrayList("20190314_10", "20190314_100")) {
        expectedRanges.add(makeTestRange(shard, "datatype2\u0000345"));
        expectedRanges.add(makeTestRange(shard, "datatype2\u0000456"));
        expectedRanges.add(makeTestRange(shard, "datatype2\u0000567"));
    }
    for (QueryPlan queryPlan : new RangeStream(config, new ScannerFactory(config.getConnector()), helper).streamPlans(script)) {
        for (Range range : queryPlan.getRanges()) {
            assertTrue("Tried to remove unexpected range " + range.toString() + " from expected ranges: " + expectedRanges.toString(), expectedRanges.remove(range));
        }
    }
    assertTrue(expectedRanges.size() + " expected ranges not found in query plan: " + expectedRanges.toString(), expectedRanges.isEmpty());
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) RangeFactoryForTests.makeTestRange(datawave.common.test.utils.query.RangeFactoryForTests.makeTestRange) Range(org.apache.accumulo.core.data.Range) QueryPlan(datawave.query.planner.QueryPlan) ScannerFactory(datawave.query.tables.ScannerFactory) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) MockMetadataHelper(datawave.query.util.MockMetadataHelper) NoOpType(datawave.data.type.NoOpType) NumberType(datawave.data.type.NumberType) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) Type(datawave.data.type.Type) NumberType(datawave.data.type.NumberType)

Example 23 with NumberType

use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.

the class RangeStreamTest method testAndTwoFieldsIndexed.

@Test
public void testAndTwoFieldsIndexed() throws Exception {
    String originalQuery = "(FOO == 'bag' && FOO == 'ba')";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(originalQuery);
    config.setBeginDate(new Date(0));
    config.setEndDate(new Date(System.currentTimeMillis()));
    Multimap<String, Type<?>> dataTypes = HashMultimap.create();
    dataTypes.putAll("FOO", Sets.newHashSet(new LcNoDiacriticsType()));
    dataTypes.putAll("NUM", Sets.newHashSet(new NumberType()));
    config.setQueryFieldsDatatypes(dataTypes);
    config.setIndexedFields(dataTypes);
    MockMetadataHelper helper = new MockMetadataHelper();
    helper.setIndexedFields(dataTypes.keySet());
    assertFalse(new RangeStream(config, new ScannerFactory(config.getConnector()), helper).streamPlans(script).iterator().hasNext());
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) MockMetadataHelper(datawave.query.util.MockMetadataHelper) NoOpType(datawave.data.type.NoOpType) NumberType(datawave.data.type.NumberType) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) Type(datawave.data.type.Type) NumberType(datawave.data.type.NumberType) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ScannerFactory(datawave.query.tables.ScannerFactory) Test(org.junit.Test)

Example 24 with NumberType

use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.

the class RangeStreamTest method testTheSimplestOfQueries.

@Test
public void testTheSimplestOfQueries() throws Exception {
    String originalQuery = "FOO == 'bag'";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(originalQuery);
    config.setBeginDate(new Date(0));
    config.setEndDate(new Date(System.currentTimeMillis()));
    Multimap<String, Type<?>> dataTypes = HashMultimap.create();
    dataTypes.putAll("FOO", Sets.newHashSet(new LcNoDiacriticsType()));
    dataTypes.putAll("NUM", Sets.newHashSet(new NumberType()));
    config.setQueryFieldsDatatypes(dataTypes);
    config.setIndexedFields(dataTypes);
    MockMetadataHelper helper = new MockMetadataHelper();
    helper.setIndexedFields(dataTypes.keySet());
    Set<Range> expectedRanges = Sets.newHashSet(makeTestRange("20190314", "datatype1\u0000234"), makeTestRange("20190314", "datatype1\u0000345"));
    for (QueryPlan queryPlan : new RangeStream(config, new ScannerFactory(config.getConnector()), helper).streamPlans(script)) {
        for (Range range : queryPlan.getRanges()) {
            assertTrue("Tried to remove unexpected range from expected ranges: " + range.toString(), expectedRanges.remove(range));
        }
    }
    assertTrue("Expected ranges not found in query plan: " + expectedRanges.toString(), expectedRanges.isEmpty());
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) RangeFactoryForTests.makeTestRange(datawave.common.test.utils.query.RangeFactoryForTests.makeTestRange) Range(org.apache.accumulo.core.data.Range) QueryPlan(datawave.query.planner.QueryPlan) ScannerFactory(datawave.query.tables.ScannerFactory) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) MockMetadataHelper(datawave.query.util.MockMetadataHelper) NoOpType(datawave.data.type.NoOpType) NumberType(datawave.data.type.NumberType) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) Type(datawave.data.type.Type) NumberType(datawave.data.type.NumberType) Test(org.junit.Test)

Example 25 with NumberType

use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.

the class RangeStreamTest method testOrNoFieldIndexed.

@Test
public void testOrNoFieldIndexed() throws Exception {
    String originalQuery = "(TACO == 'bag' || TACO == 'ba')";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(originalQuery);
    config.setBeginDate(new Date(0));
    config.setEndDate(new Date(System.currentTimeMillis()));
    Multimap<String, Type<?>> dataTypes = HashMultimap.create();
    dataTypes.putAll("FOO", Sets.newHashSet(new LcNoDiacriticsType()));
    dataTypes.putAll("NUM", Sets.newHashSet(new NumberType()));
    config.setQueryFieldsDatatypes(dataTypes);
    config.setIndexedFields(dataTypes);
    MockMetadataHelper helper = new MockMetadataHelper();
    helper.setIndexedFields(dataTypes.keySet());
    assertFalse(new RangeStream(config, new ScannerFactory(config.getConnector()), helper).streamPlans(script).iterator().hasNext());
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) MockMetadataHelper(datawave.query.util.MockMetadataHelper) NoOpType(datawave.data.type.NoOpType) NumberType(datawave.data.type.NumberType) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) Type(datawave.data.type.Type) NumberType(datawave.data.type.NumberType) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ScannerFactory(datawave.query.tables.ScannerFactory) Test(org.junit.Test)

Aggregations

NumberType (datawave.data.type.NumberType)28 LcNoDiacriticsType (datawave.data.type.LcNoDiacriticsType)21 Test (org.junit.Test)21 Type (datawave.data.type.Type)20 NoOpType (datawave.data.type.NoOpType)18 ScannerFactory (datawave.query.tables.ScannerFactory)13 MockMetadataHelper (datawave.query.util.MockMetadataHelper)13 ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)13 RangeFactoryForTests.makeTestRange (datawave.common.test.utils.query.RangeFactoryForTests.makeTestRange)9 QueryPlan (datawave.query.planner.QueryPlan)9 Range (org.apache.accumulo.core.data.Range)9 LcType (datawave.data.type.LcType)8 IpAddressType (datawave.data.type.IpAddressType)4 ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)3 Key (org.apache.accumulo.core.data.Key)3 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 MarkingFunctions (datawave.marking.MarkingFunctions)2 ValueTuple (datawave.query.attributes.ValueTuple)2 QueryIterator (datawave.query.iterator.QueryIterator)2