Search in sources :

Example 26 with LcNoDiacriticsType

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

the class ExpandMultiNormalizedTermsTest method testNumber.

@Test
public void testNumber() throws ParseException {
    Multimap<String, Type<?>> dataTypes = HashMultimap.create();
    dataTypes.putAll("MULTI", Sets.newHashSet(new LcNoDiacriticsType(), new NumberType()));
    dataTypes.put("NUM", new NumberType());
    helper.setIndexedFields(dataTypes.keySet());
    helper.setIndexOnlyFields(dataTypes.keySet());
    helper.addTermFrequencyFields(dataTypes.keySet());
    config.setQueryFieldsDatatypes(dataTypes);
    String original = "NUM == '1'";
    String expected = "NUM == '+aE1'";
    expandTerms(original, expected);
    original = "MULTI == '1'";
    expected = "(MULTI == '1' || MULTI == '+aE1')";
    expandTerms(original, expected);
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) IpAddressType(datawave.data.type.IpAddressType) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) NoOpType(datawave.data.type.NoOpType) NumberType(datawave.data.type.NumberType) LcType(datawave.data.type.LcType) Type(datawave.data.type.Type) NumberType(datawave.data.type.NumberType) Test(org.junit.Test)

Example 27 with LcNoDiacriticsType

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

the class ExpandMultiNormalizedTermsTest method testBoundedNormalizedAndUnNormalizedBoundsCase.

@Test
public void testBoundedNormalizedAndUnNormalizedBoundsCase() throws ParseException {
    Multimap<String, Type<?>> dataTypes = HashMultimap.create();
    dataTypes.put("NEW", new LcNoDiacriticsType());
    config.setQueryFieldsDatatypes(dataTypes);
    String original = "((_Bounded_ = true) && (NEW > '0' && NEW < '9')) && ((_Bounded_ = true) && (FOO > 1 && FOO < 10))";
    String expected = "((_Bounded_ = true) && (NEW > '0' && NEW < '9')) && ((_Bounded_ = true) && (FOO > 1 && FOO < 10))";
    expandTerms(original, expected);
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) IpAddressType(datawave.data.type.IpAddressType) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) NoOpType(datawave.data.type.NoOpType) NumberType(datawave.data.type.NumberType) LcType(datawave.data.type.LcType) Type(datawave.data.type.Type) Test(org.junit.Test)

Example 28 with LcNoDiacriticsType

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

the class FetchDataTypesVisitorTest method testSingleTermNormalizer.

@Test
public void testSingleTermNormalizer() throws ParseException {
    String query = "FOO == 'bar'";
    Multimap<String, Type<?>> expected = HashMultimap.create();
    expected.put("FOO", new LcNoDiacriticsType());
    runTest(query, expected);
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) NumberType(datawave.data.type.NumberType) LcType(datawave.data.type.LcType) Type(datawave.data.type.Type) Test(org.junit.Test)

Example 29 with LcNoDiacriticsType

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

the class FetchDataTypesVisitorTest method testSingleTermTwoNormalizers.

@Test
public void testSingleTermTwoNormalizers() throws ParseException {
    String query = "FOO4 == 'bar'";
    Multimap<String, Type<?>> expected = HashMultimap.create();
    expected.put("FOO4", new LcType());
    expected.put("FOO4", new LcNoDiacriticsType());
    runTest(query, expected);
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) NumberType(datawave.data.type.NumberType) LcType(datawave.data.type.LcType) Type(datawave.data.type.Type) LcType(datawave.data.type.LcType) Test(org.junit.Test)

Example 30 with LcNoDiacriticsType

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

the class JexlASTHelperTest method testNormalizeLiteral.

@Test
public void testNormalizeLiteral() throws Throwable {
    LcNoDiacriticsType normalizer = new LcNoDiacriticsType();
    ASTJexlScript script = JexlASTHelper.parseJexlQuery("F == 'aSTrInG'");
    if (log.isDebugEnabled()) {
        PrintingVisitor.printQuery(script);
    }
    JexlNode literal = script.jjtGetChild(0).jjtGetChild(1).jjtGetChild(0);
    ASTReference ref = JexlASTHelper.normalizeLiteral(literal, normalizer);
    Assert.assertEquals("astring", ref.jjtGetChild(0).image);
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) ASTReference(org.apache.commons.jexl2.parser.ASTReference) Test(org.junit.Test)

Aggregations

LcNoDiacriticsType (datawave.data.type.LcNoDiacriticsType)49 Type (datawave.data.type.Type)46 NumberType (datawave.data.type.NumberType)44 Test (org.junit.Test)42 NoOpType (datawave.data.type.NoOpType)41 ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)36 MockMetadataHelper (datawave.query.util.MockMetadataHelper)35 ScannerFactory (datawave.query.tables.ScannerFactory)34 RangeFactoryForTests.makeTestRange (datawave.common.test.utils.query.RangeFactoryForTests.makeTestRange)25 QueryPlan (datawave.query.planner.QueryPlan)25 Range (org.apache.accumulo.core.data.Range)25 LcType (datawave.data.type.LcType)9 SimpleDateFormat (java.text.SimpleDateFormat)9 IpAddressType (datawave.data.type.IpAddressType)6 JexlASTHelper (datawave.query.jexl.JexlASTHelper)2 Date (java.util.Date)2 Set (java.util.Set)2 ASTReference (org.apache.commons.jexl2.parser.ASTReference)2 JexlNode (org.apache.commons.jexl2.parser.JexlNode)2 ParseException (org.apache.commons.jexl2.parser.ParseException)2