use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.
the class RangeStreamTest method testNestedOr.
@Test
public void testNestedOr() throws Exception {
String originalQuery = "(FOO == 'bag' || FOO == 'ba' || FOO == 'barglegarglebarsh')";
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());
Range range1 = makeTestRange("20190314", "datatype1\u0000234");
Range range2 = makeTestRange("20190314", "datatype1\u0000345");
Range range3 = makeTestRange("20190314", "datatype1\u0000123");
Set<Range> expectedRanges = Sets.newHashSet(range1, range2, range3);
RangeStream rangeStream = new RangeStream(config, new ScannerFactory(config.getConnector(), 1), helper);
rangeStream.setLimitScanners(true);
for (QueryPlan queryPlan : rangeStream.streamPlans(script)) {
for (Range range : queryPlan.getRanges()) {
assertTrue("Tried to remove unexpected range " + range.toString() + " from expected ranges: " + expectedRanges.toString(), expectedRanges.remove(range));
}
}
assertTrue("Expected ranges not found in query plan: " + expectedRanges.toString(), expectedRanges.isEmpty());
}
use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.
the class ExpandMultiNormalizedTermsTest method testWeirdlyNormalizedFunction.
@Test
public void testWeirdlyNormalizedFunction() throws ParseException {
Multimap<String, Type<?>> dataTypes = HashMultimap.create();
dataTypes.put("NUM", new NumberType());
helper.setIndexedFields(dataTypes.keySet());
helper.setIndexOnlyFields(dataTypes.keySet());
helper.addTermFrequencyFields(dataTypes.keySet());
config.setQueryFieldsDatatypes(dataTypes);
String original = "content:phrase(termOffsetMap, '1', '2')";
String expected = "content:phrase(termOffsetMap, '+aE1', '+aE2')";
expandTerms(original, expected);
}
use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.
the class FetchDataTypesVisitorTest method setup.
@BeforeClass
public static void setup() {
// 1. Configure the ShardQueryConfig
config.setBeginDate(new Date(0));
config.setEndDate(new Date(System.currentTimeMillis()));
// 2. Configure the MockMetadataHelper
helper.addNormalizers("FOO", Sets.newHashSet(new LcNoDiacriticsType()));
helper.addNormalizers("FOO2", Sets.newHashSet(new LcType()));
helper.addNormalizers("FOO3", Sets.newHashSet(new NumberType()));
helper.addNormalizers("FOO4", Sets.newHashSet(new LcType(), new LcNoDiacriticsType()));
}
use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.
the class FetchDataTypesVisitorTest method testTwoSingleTermNormalizers.
@Test
public void testTwoSingleTermNormalizers() throws ParseException {
String query = "FOO2 == 'bar' && FOO3 == '3'";
Multimap<String, Type<?>> expected = HashMultimap.create();
expected.put("FOO2", new LcType());
expected.put("FOO3", new NumberType());
runTest(query, expected);
}
use of datawave.data.type.NumberType in project datawave by NationalSecurityAgency.
the class FunctionalSet method getGroupsForValue.
public Object getGroupsForValue(int value) {
Set<String> groups = Sets.newHashSet();
for (Iterator<T> iterator = iterator(); iterator.hasNext(); ) {
ValueTuple next = iterator.next();
String field = next.first();
Object val = next.getValue();
if (val instanceof String) {
if (((String) val).equals("" + value)) {
groups.add(field.substring(field.indexOf('.') + 1));
}
} else if (val instanceof Number) {
String longValue = ((Number) val).toString();
if (longValue.equals("" + value)) {
groups.add(field.substring(field.indexOf('.') + 1));
}
} else if (val instanceof NumberType) {
String longValue = "" + ((NumberType) val).getDelegate().longValue();
if (longValue.equals("" + value)) {
groups.add(field.substring(field.indexOf('.') + 1));
}
}
}
return groups;
}
Aggregations