Search in sources :

Example 1 with LcType

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

the class GroupingTest method testCountingMap.

@Test
public void testCountingMap() {
    MarkingFunctions markingFunctions = new MarkingFunctions.Default();
    GroupingTransform.GroupCountingHashMap map = new GroupingTransform.GroupCountingHashMap(markingFunctions);
    GroupingTypeAttribute attr1 = new GroupingTypeAttribute(new LcType("FOO"), new Key("FOO"), true);
    attr1.setColumnVisibility(new ColumnVisibility("A"));
    map.add(Collections.singleton(attr1));
    GroupingTypeAttribute attr2 = new GroupingTypeAttribute(new LcType("FOO"), new Key("FOO"), true);
    attr2.setColumnVisibility(new ColumnVisibility("B"));
    map.add(Collections.singleton(attr2));
    GroupingTypeAttribute attr3 = new GroupingTypeAttribute(new LcType("BAR"), new Key("BAR"), true);
    attr3.setColumnVisibility(new ColumnVisibility("C"));
    map.add(Collections.singleton(attr3));
    log.debug("map is: " + map);
    for (Map.Entry<Collection<GroupingTypeAttribute<?>>, Integer> entry : map.entrySet()) {
        // the first and only one
        Attribute<?> attr = entry.getKey().iterator().next();
        int count = entry.getValue();
        if (attr.getData().toString().equals("FOO")) {
            Assert.assertEquals(2, count);
            Assert.assertEquals(new ColumnVisibility("A&B"), attr.getColumnVisibility());
        } else if (attr.getData().toString().equals("BAR")) {
            Assert.assertEquals(1, count);
            Assert.assertEquals(new ColumnVisibility("C"), attr.getColumnVisibility());
        }
    }
}
Also used : MarkingFunctions(datawave.marking.MarkingFunctions) GroupingTypeAttribute(datawave.query.transformer.GroupingTransform.GroupingTypeAttribute) Collection(java.util.Collection) LcType(datawave.data.type.LcType) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 2 with LcType

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

the class FetchDataTypesVisitorTest method testFunctionWithNormalizer.

@Test
public void testFunctionWithNormalizer() throws ParseException {
    String query = "content:phrase(FOO2, termOffsetMap, 'bar', 'baz')";
    Multimap<String, Type<?>> expected = HashMultimap.create();
    expected.put("FOO2", new LcType());
    runTest(query, expected);
}
Also used : 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 3 with LcType

use of datawave.data.type.LcType 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()));
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) NumberType(datawave.data.type.NumberType) LcType(datawave.data.type.LcType) Date(java.util.Date) BeforeClass(org.junit.BeforeClass)

Example 4 with LcType

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

the class FetchDataTypesVisitorTest method testRegexWithNormalizer.

@Test
public void testRegexWithNormalizer() throws ParseException {
    String query = "filter:includeRegex(FOO2, 'bar.*')";
    Multimap<String, Type<?>> expected = HashMultimap.create();
    expected.put("FOO2", new LcType());
    runTest(query, expected);
}
Also used : 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 5 with LcType

use of datawave.data.type.LcType 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);
}
Also used : LcNoDiacriticsType(datawave.data.type.LcNoDiacriticsType) NumberType(datawave.data.type.NumberType) LcType(datawave.data.type.LcType) Type(datawave.data.type.Type) NumberType(datawave.data.type.NumberType) LcType(datawave.data.type.LcType) Test(org.junit.Test)

Aggregations

LcType (datawave.data.type.LcType)9 Test (org.junit.Test)8 NumberType (datawave.data.type.NumberType)7 LcNoDiacriticsType (datawave.data.type.LcNoDiacriticsType)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 Type (datawave.data.type.Type)4 MarkingFunctions (datawave.marking.MarkingFunctions)4 GroupingTypeAttribute (datawave.query.transformer.GroupingTransform.GroupingTypeAttribute)4 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Key (org.apache.accumulo.core.data.Key)4 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)4 Date (java.util.Date)1 BeforeClass (org.junit.BeforeClass)1