Search in sources :

Example 1 with StringType

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

the class FacetedTransformer method buildFacets.

/**
 * Accepts an attribute. The document data will be placed into the value of the Field.
 *
 * @param documentKey
 * @param fieldName
 * @param attr
 * @param topLevelColumnVisibility
 * @param markingFunctions
 * @return
 */
protected Collection<FieldCardinalityBase> buildFacets(Key documentKey, String fieldName, Attribute<?> attr, ColumnVisibility topLevelColumnVisibility, MarkingFunctions markingFunctions) {
    Set<FieldCardinalityBase> myFields = new HashSet<>();
    if (attr instanceof Attributes) {
        Attributes attributeList = Attributes.class.cast(attr);
        for (Attribute<?> embeddedAttr : attributeList.getAttributes()) myFields.addAll(buildFacets(documentKey, fieldName, embeddedAttr, topLevelColumnVisibility, markingFunctions));
    } else {
        // Use the markings on the Field if we're returning the markings to the client
        if (attr instanceof Cardinality) {
            try {
                Cardinality card = (Cardinality) attr;
                FieldValueCardinality v = card.getContent();
                StringType value = new StringType();
                value.setDelegate(v.toString());
                value.setNormalizedValue(v.toString());
                FieldCardinalityBase fc = this.responseObjectFactory.getFieldCardinality();
                fc.setField(v.getFieldName());
                // reduces colvis based on
                fc.setMarkings(markingFunctions.translateFromColumnVisibilityForAuths(attr.getColumnVisibility(), auths));
                // visibility
                fc.setColumnVisibility(new String(markingFunctions.translateToColumnVisibility(fc.getMarkings()).flatten()));
                fc.setLower(v.getFloorValue());
                fc.setUpper(v.getCeilingValue());
                fc.setCardinality(v.getEstimate().cardinality());
                myFields.add(fc);
            } catch (Exception e) {
                log.error("unable to process markings:" + e);
            }
        }
    }
    return myFields;
}
Also used : FieldValueCardinality(datawave.query.attributes.FieldValueCardinality) Cardinality(datawave.query.attributes.Cardinality) StringType(datawave.data.type.StringType) Attributes(datawave.query.attributes.Attributes) FieldValueCardinality(datawave.query.attributes.FieldValueCardinality) EmptyObjectException(datawave.webservice.query.exception.EmptyObjectException) FieldCardinalityBase(datawave.webservice.query.result.event.FieldCardinalityBase) HashSet(java.util.HashSet)

Example 2 with StringType

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

the class ShardQueryConfigurationTest method testGetSetIndexedFieldDataTypes.

@Test
public void testGetSetIndexedFieldDataTypes() {
    Assert.assertEquals("", config.getIndexedFieldDataTypesAsString());
    Set<String> indexedFields = Sets.newHashSet("fieldA", "fieldB");
    Multimap<String, Type<?>> queryFieldsDatatypes = ArrayListMultimap.create();
    queryFieldsDatatypes.put("fieldA", new DateType());
    queryFieldsDatatypes.put("fieldB", new StringType());
    config.setIndexedFields(indexedFields);
    config.setQueryFieldsDatatypes(queryFieldsDatatypes);
    String expected = "fieldA:datawave.data.type.DateType;fieldB:datawave.data.type.StringType;";
    Assert.assertEquals(expected, config.getIndexedFieldDataTypesAsString());
}
Also used : NoOpType(datawave.data.type.NoOpType) StringType(datawave.data.type.StringType) GeometryType(datawave.data.type.GeometryType) DiscreteIndexType(datawave.data.type.DiscreteIndexType) Type(datawave.data.type.Type) DateType(datawave.data.type.DateType) StringType(datawave.data.type.StringType) DateType(datawave.data.type.DateType) Test(org.junit.Test)

Example 3 with StringType

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

the class ShardQueryConfigurationTest method testGetSetNormalizedFieldNormalizers.

@Test
public void testGetSetNormalizedFieldNormalizers() {
    Assert.assertEquals("", config.getNormalizedFieldNormalizersAsString());
    Set<String> normalizedFields = Sets.newHashSet("fieldA", "fieldB");
    Multimap<String, Type<?>> normalizedFieldsDatatypes = ArrayListMultimap.create();
    normalizedFieldsDatatypes.put("fieldA", new DateType());
    normalizedFieldsDatatypes.put("fieldB", new StringType());
    config.setIndexedFields(normalizedFields);
    config.setNormalizedFieldsDatatypes(normalizedFieldsDatatypes);
    String expected = "fieldA:datawave.data.type.DateType;fieldB:datawave.data.type.StringType;";
    Assert.assertEquals(expected, config.getNormalizedFieldNormalizersAsString());
}
Also used : NoOpType(datawave.data.type.NoOpType) StringType(datawave.data.type.StringType) GeometryType(datawave.data.type.GeometryType) DiscreteIndexType(datawave.data.type.DiscreteIndexType) Type(datawave.data.type.Type) DateType(datawave.data.type.DateType) StringType(datawave.data.type.StringType) DateType(datawave.data.type.DateType) Test(org.junit.Test)

Aggregations

StringType (datawave.data.type.StringType)3 DateType (datawave.data.type.DateType)2 DiscreteIndexType (datawave.data.type.DiscreteIndexType)2 GeometryType (datawave.data.type.GeometryType)2 NoOpType (datawave.data.type.NoOpType)2 Type (datawave.data.type.Type)2 Test (org.junit.Test)2 Attributes (datawave.query.attributes.Attributes)1 Cardinality (datawave.query.attributes.Cardinality)1 FieldValueCardinality (datawave.query.attributes.FieldValueCardinality)1 EmptyObjectException (datawave.webservice.query.exception.EmptyObjectException)1 FieldCardinalityBase (datawave.webservice.query.result.event.FieldCardinalityBase)1 HashSet (java.util.HashSet)1