Search in sources :

Example 1 with AttributeBag

use of datawave.query.attributes.AttributeBag in project datawave by NationalSecurityAgency.

the class EventDataQueryExpressionVisitor method extractTypes.

public static Set<Type> extractTypes(AttributeFactory attrFactory, String fieldName, String fieldValue, Key key) {
    final Set<Type> types = new HashSet<>();
    final Queue<Attribute<?>> attrQueue = new LinkedList<>();
    attrQueue.add(attrFactory.create(fieldName, fieldValue, key, true));
    Attribute<?> attr;
    while ((attr = attrQueue.poll()) != null) {
        if (TypeAttribute.class.isAssignableFrom(attr.getClass())) {
            TypeAttribute dta = (TypeAttribute) attr;
            Type t = dta.getType();
            types.add(t);
        } else if (AttributeBag.class.isAssignableFrom(attr.getClass())) {
            attrQueue.addAll(((AttributeBag<?>) attr).getAttributes());
        } else {
            log.warn("Unexpected attribute type when extracting type: " + attr.getClass().getCanonicalName());
        }
    }
    return types;
}
Also used : NoOpType(datawave.data.type.NoOpType) Type(datawave.data.type.Type) TypeAttribute(datawave.query.attributes.TypeAttribute) Attribute(datawave.query.attributes.Attribute) TypeAttribute(datawave.query.attributes.TypeAttribute) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet) AttributeBag(datawave.query.attributes.AttributeBag)

Aggregations

NoOpType (datawave.data.type.NoOpType)1 Type (datawave.data.type.Type)1 Attribute (datawave.query.attributes.Attribute)1 AttributeBag (datawave.query.attributes.AttributeBag)1 TypeAttribute (datawave.query.attributes.TypeAttribute)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1