use of datawave.webservice.query.result.event.Metadata in project datawave by NationalSecurityAgency.
the class DocumentTransformer method buildResponse.
protected EventBase buildResponse(Document document, Key documentKey, ColumnVisibility eventCV, String colf, String row, MarkingFunctions mf) throws MarkingFunctions.Exception {
Map<String, String> markings = mf.translateFromColumnVisibility(eventCV);
EventBase event = null;
final Collection<FieldBase<?>> documentFields = buildDocumentFields(documentKey, null, document, eventCV, mf);
// if documentFields is empty, then the response contained only timing metadata
if (!documentFields.isEmpty()) {
event = this.responseObjectFactory.getEvent();
event.setMarkings(markings);
event.setFields(new ArrayList<>(documentFields));
Metadata metadata = new Metadata();
String[] colfParts = StringUtils.split(colf, '\0');
if (colfParts.length >= 1) {
metadata.setDataType(colfParts[0]);
}
if (colfParts.length >= 2) {
metadata.setInternalId(colfParts[1]);
}
if (this.tableName != null) {
metadata.setTable(this.tableName);
}
metadata.setRow(row);
event.setMetadata(metadata);
if (eventQueryDataDecoratorTransformer != null) {
event = (EventBase) eventQueryDataDecoratorTransformer.transform(event);
}
// assign an estimate of the event size based on the document size
// in practice this is about 2.5 times the size of the document estimated size
// we need to set something here for page size trigger purposes.
event.setSizeInBytes(Math.round(document.sizeInBytes() * 2.5d));
}
return event;
}
use of datawave.webservice.query.result.event.Metadata 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;
}
use of datawave.webservice.query.result.event.Metadata 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;
}
use of datawave.webservice.query.result.event.Metadata 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;
}
use of datawave.webservice.query.result.event.Metadata in project datawave by NationalSecurityAgency.
the class ShardQueryCountTableTransformer method transform.
@Override
public EventBase transform(Entry<Long, ColumnVisibility> untypedEntry) {
Long count = untypedEntry.getKey();
ColumnVisibility vis = untypedEntry.getValue();
Map<String, String> markings;
try {
markings = markingFunctions.translateFromColumnVisibilityForAuths(vis, auths);
} catch (Exception e1) {
throw new IllegalArgumentException("Unable to translate markings", e1);
}
EventBase e = this.responseObjectFactory.getEvent();
e.setMarkings(markings);
FieldBase field = this.makeField(COUNT_CELL, markings, vis, System.currentTimeMillis(), count);
e.setMarkings(markings);
List<FieldBase> fields = new ArrayList<>();
fields.add(field);
e.setFields(fields);
Metadata metadata = new Metadata();
metadata.setDataType(Constants.EMPTY_STRING);
// There is only one item returned for the entire query logic.
metadata.setInternalId(field.getName());
metadata.setRow(Constants.EMPTY_STRING);
e.setMetadata(metadata);
return e;
}
Aggregations