use of datawave.webservice.query.result.event.Metadata in project datawave by NationalSecurityAgency.
the class FieldIndexCountQueryTransformer 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 = this.responseObjectFactory.getEvent();
event.setMarkings(markings);
Metadata metadata = new Metadata();
metadata.setDataType(dataType);
metadata.setInternalId(internalId);
metadata.setRow(row);
metadata.setTable(logic.getTableName());
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();
Map<String, String> columnMarkings = cqr.getColumnMarkings(columnName);
String columnVisibility = cqr.getColumnVisibility(columnName);
Long columnTimestamp = cqr.getColumnTimestamp(columnName);
FieldBase field = this.makeField(columnName, columnMarkings, columnVisibility, columnTimestamp, 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 FieldIndexCountQueryTransformer method writeToCache.
@Override
public List<CacheableQueryRow> writeToCache(Object o) throws QueryException {
List<CacheableQueryRow> cqoList = new ArrayList<>();
EventBase event = (EventBase) o;
CacheableQueryRow cqo = responseObjectFactory.getCacheableQueryRow();
Metadata metadata = event.getMetadata();
cqo.setColFam(metadata.getDataType() + ":" + cqo.getEventId());
cqo.setDataType(metadata.getDataType());
cqo.setEventId(metadata.getInternalId());
cqo.setRow(metadata.getRow());
List<? extends 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 DiscoveryTransformer method transform.
@Override
public EventBase transform(DiscoveredThing thing) {
Preconditions.checkNotNull(thing, "Received a null object to transform!");
EventBase event = this.responseObjectFactory.getEvent();
Map<String, String> markings;
try {
markings = this.markingFunctions.translateFromColumnVisibility(new ColumnVisibility(thing.getColumnVisibility()));
} catch (Exception e) {
throw new RuntimeException("could not parse to markings: " + thing.getColumnVisibility());
}
event.setMarkings(markings);
List<FieldBase> fields = new ArrayList<>();
fields.add(this.makeField("VALUE", markings, "", 0L, thing.getTerm()));
/**
* Added query model to alias FIELD
*/
fields.add(this.makeField("FIELD", markings, "", 0L, myQueryModel.aliasFieldNameReverseModel(thing.getField())));
fields.add(this.makeField("DATE", markings, "", 0L, thing.getDate()));
fields.add(this.makeField("DATA TYPE", markings, "", 0L, thing.getType()));
// If requested return counts separated by colvis, all counts by colvis could be > total record count
if (thing.getCountsByColumnVisibility() != null && !thing.getCountsByColumnVisibility().isEmpty()) {
for (Map.Entry<Writable, Writable> entry : thing.getCountsByColumnVisibility().entrySet()) {
try {
Map<String, String> eMarkings = this.markingFunctions.translateFromColumnVisibility(new ColumnVisibility(entry.getKey().toString()));
fields.add(this.makeField("RECORD COUNT", new HashMap<>(), entry.getKey().toString(), 0L, entry.getValue().toString()));
} catch (Exception e) {
throw new RuntimeException("could not parse to markings: " + thing.getColumnVisibility());
}
}
} else {
fields.add(this.makeField("RECORD COUNT", markings, "", 0L, Long.toString(thing.getCount())));
}
event.setFields(fields);
Metadata metadata = new Metadata();
// there is no UUID for a single index pointer
metadata.setInternalId("");
// duplicate
metadata.setDataType(thing.getType());
// duplicate
metadata.setRow(thing.getTerm());
metadata.setTable(logic.getTableName());
event.setMetadata(metadata);
return event;
}
use of datawave.webservice.query.result.event.Metadata in project datawave by NationalSecurityAgency.
the class DiscoveryTransformer 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 = this.responseObjectFactory.getEvent();
event.setMarkings(markings);
Metadata metadata = new Metadata();
metadata.setDataType(dataType);
metadata.setInternalId(internalId);
metadata.setRow(row);
metadata.setTable(logic.getTableName());
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 = this.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 DiscoveryTransformer method writeToCache.
@Override
public List<CacheableQueryRow> writeToCache(Object o) throws QueryException {
List<CacheableQueryRow> cqoList = new ArrayList<>();
EventBase event = (EventBase) o;
CacheableQueryRow 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());
}
cqoList.add(cqo);
return cqoList;
}
Aggregations