Search in sources :

Example 26 with EventBase

use of datawave.webservice.query.result.event.EventBase in project datawave by NationalSecurityAgency.

the class ParentDocumentTransformer method transform.

@Override
public EventBase transform(Entry<Key, Value> input) {
    EventBase event = super.transform(input);
    Metadata md = event.getMetadata();
    byte[] id = md.getInternalId().getBytes();
    ByteSequence parentIdBytes = TLD.parseParentPointerFromId(new ArrayByteSequence(id));
    String parentId = new String(parentIdBytes.getBackingArray(), parentIdBytes.offset(), parentIdBytes.length());
    md.setInternalId(parentId);
    return event;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) Metadata(datawave.webservice.query.result.event.Metadata) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence)

Example 27 with EventBase

use of datawave.webservice.query.result.event.EventBase in project datawave by NationalSecurityAgency.

the class ShardIndexQueryTransformer method createResponse.

@Override
public BaseQueryResponse createResponse(List<Object> resultList) {
    EventQueryResponseBase response = responseObjectFactory.getEventQueryResponse();
    List<EventBase> eventList = new ArrayList<>();
    for (Object o : resultList) {
        EventBase e = (EventBase) o;
        eventList.add(e);
    }
    response.setFields(this.variableFieldList);
    response.setEvents(eventList);
    response.setReturnedEvents((long) eventList.size());
    return response;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) ArrayList(java.util.ArrayList) EventQueryResponseBase(datawave.webservice.result.EventQueryResponseBase)

Example 28 with EventBase

use of datawave.webservice.query.result.event.EventBase in project datawave by NationalSecurityAgency.

the class ShardQueryCountTableTransformer method writeToCache.

@Override
public List<CacheableQueryRow> writeToCache(Object o) throws QueryException {
    List<CacheableQueryRow> cqoList = new ArrayList<>();
    EventBase event = (EventBase) o;
    CacheableQueryRowImpl cqo = new CacheableQueryRowImpl();
    Metadata metadata = event.getMetadata();
    cqo.setColFam(metadata.getDataType() + ":" + cqo.getEventId());
    cqo.setDataType(metadata.getDataType());
    cqo.setEventId(metadata.getInternalId());
    cqo.setRow(metadata.getRow());
    List<FieldBase> fields = event.getFields();
    for (FieldBase f : fields) {
        cqo.addColumn(f.getName(), f.getTypedValue(), f.getMarkings(), f.getColumnVisibility(), f.getTimestamp());
    }
    // set the size in bytes using the initial event size as an approximation
    cqo.setSizeInBytes(event.getSizeInBytes());
    cqoList.add(cqo);
    return cqoList;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) ArrayList(java.util.ArrayList) Metadata(datawave.webservice.query.result.event.Metadata) FieldBase(datawave.webservice.query.result.event.FieldBase) CacheableQueryRow(datawave.webservice.query.cachedresults.CacheableQueryRow) CacheableQueryRowImpl(datawave.webservice.query.cachedresults.CacheableQueryRowImpl)

Example 29 with EventBase

use of datawave.webservice.query.result.event.EventBase in project datawave by NationalSecurityAgency.

the class ShardQueryCountTableTransformer method createResponse.

@Override
public BaseQueryResponse createResponse(List<Object> resultList) {
    EventQueryResponseBase response = responseObjectFactory.getEventQueryResponse();
    List<EventBase> eventList = new ArrayList<>();
    for (Object o : resultList) {
        EventBase e = (EventBase) o;
        eventList.add(e);
    }
    response.setFields(variableFieldList);
    response.setEvents(eventList);
    response.setReturnedEvents((long) eventList.size());
    return response;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) ArrayList(java.util.ArrayList) EventQueryResponseBase(datawave.webservice.result.EventQueryResponseBase)

Example 30 with EventBase

use of datawave.webservice.query.result.event.EventBase in project datawave by NationalSecurityAgency.

the class ShardQueryCountTableTransformer method readFromCache.

@Override
public List<Object> readFromCache(List<CacheableQueryRow> cacheableQueryRowList) {
    List<Object> eventList = new ArrayList<>();
    for (CacheableQueryRow cqr : cacheableQueryRowList) {
        if (this.variableFieldList == null) {
            this.variableFieldList = cqr.getVariableColumnNames();
        }
        Map<String, String> markings = cqr.getMarkings();
        String dataType = cqr.getDataType();
        String internalId = cqr.getEventId();
        String row = cqr.getRow();
        EventBase event = responseObjectFactory.getEvent();
        event.setMarkings(markings);
        Metadata metadata = new Metadata();
        metadata.setDataType(dataType);
        metadata.setInternalId(internalId);
        metadata.setRow(row);
        event.setMetadata(metadata);
        List<FieldBase> fieldList = new ArrayList<>();
        Map<String, String> columnValueMap = cqr.getColumnValues();
        for (Map.Entry<String, String> entry : columnValueMap.entrySet()) {
            String columnName = entry.getKey();
            String columnValue = entry.getValue();
            String columnVisibility = cqr.getColumnVisibility(columnName);
            Long columnTimestamp = cqr.getColumnTimestamp(columnName);
            Map<String, String> columnMarkings = cqr.getColumnMarkings(columnName);
            FieldBase field = responseObjectFactory.getField();
            field.setName(columnName);
            field.setMarkings(columnMarkings);
            field.setColumnVisibility(columnVisibility);
            field.setTimestamp(columnTimestamp);
            field.setValue(columnValue);
            fieldList.add(field);
        }
        event.setFields(fieldList);
        eventList.add(event);
    }
    return eventList;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) ArrayList(java.util.ArrayList) Metadata(datawave.webservice.query.result.event.Metadata) CacheableQueryRow(datawave.webservice.query.cachedresults.CacheableQueryRow) FieldBase(datawave.webservice.query.result.event.FieldBase) Map(java.util.Map)

Aggregations

EventBase (datawave.webservice.query.result.event.EventBase)43 ArrayList (java.util.ArrayList)28 FieldBase (datawave.webservice.query.result.event.FieldBase)23 Metadata (datawave.webservice.query.result.event.Metadata)18 EventQueryResponseBase (datawave.webservice.result.EventQueryResponseBase)11 CacheableQueryRow (datawave.webservice.query.cachedresults.CacheableQueryRow)10 BaseQueryResponse (datawave.webservice.result.BaseQueryResponse)6 DefaultEventQueryResponse (datawave.webservice.result.DefaultEventQueryResponse)5 Map (java.util.Map)5 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)5 TransformIterator (org.apache.commons.collections4.iterators.TransformIterator)5 Exception (datawave.marking.MarkingFunctions.Exception)4 QueryImpl (datawave.webservice.query.QueryImpl)4 QueryException (datawave.webservice.query.exception.QueryException)4 HashMap (java.util.HashMap)4 CacheableQueryRowImpl (datawave.webservice.query.cachedresults.CacheableQueryRowImpl)3 GenericQueryConfiguration (datawave.webservice.query.configuration.GenericQueryConfiguration)3 DatawaveTransformIterator (datawave.webservice.query.iterator.DatawaveTransformIterator)3 DefaultEvent (datawave.webservice.query.result.event.DefaultEvent)3 Date (java.util.Date)3