use of datawave.webservice.query.result.event.FacetsBase in project datawave by NationalSecurityAgency.
the class FacetedTransformer method _transform.
private FacetsBase _transform(Entry<Key, Document> documentEntry) throws EmptyObjectException {
if (documentEntry == null) {
// buildResponse will return a null object if there was only metadata in the document
throw new EmptyObjectException();
}
Key documentKey = correctKey(documentEntry.getKey());
Document document = documentEntry.getValue();
if (null == documentKey || null == document)
throw new IllegalArgumentException("Null key or value. Key:" + documentKey + ", Value: " + documentEntry.getValue());
extractMetrics(document, documentKey);
document.debugDocumentSize(documentKey);
String row = documentKey.getRow().toString();
String colf = documentKey.getColumnFamily().toString();
int index = colf.indexOf("\0");
Preconditions.checkArgument(-1 != index);
String dataType = colf.substring(0, index);
String uid = colf.substring(index + 1);
// We don't have to consult the Document to rebuild the Visibility, the key
// should have the correct top-level visibility
ColumnVisibility eventCV = new ColumnVisibility(documentKey.getColumnVisibility());
FacetsBase output = null;
try {
// build response method here
output = buildResponse(document, documentKey, eventCV, colf, row, this.markingFunctions);
} catch (Exception ex) {
log.error("Error building response document", ex);
throw new RuntimeException(ex);
}
if (output == null) {
// buildResponse will return a null object if there was only metadata in the document
throw new EmptyObjectException();
}
if (cardinalityConfiguration != null) {
collectCardinalities(document, documentKey, uid, dataType);
}
return output;
}
use of datawave.webservice.query.result.event.FacetsBase in project datawave by NationalSecurityAgency.
the class FacetedTransformer method buildResponse.
protected FacetsBase buildResponse(Document document, Key documentKey, ColumnVisibility eventCV, String colf, String row, MarkingFunctions mf) throws MarkingFunctions.Exception {
FacetsBase facetedResponse = responseObjectFactory.getFacets();
final Collection<FieldCardinalityBase> documentFields = buildFacets(documentKey, null, document, eventCV, mf);
facetedResponse.setMarkings(mf.translateFromColumnVisibility(eventCV));
facetedResponse.setFields(new ArrayList<>(documentFields));
// 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.
facetedResponse.setSizeInBytes(Math.round(document.sizeInBytes() * 2.5d));
return facetedResponse;
}
use of datawave.webservice.query.result.event.FacetsBase in project datawave by NationalSecurityAgency.
the class FacetedTransformer method createResponse.
@Override
public BaseQueryResponse createResponse(List<Object> resultList) {
FacetQueryResponseBase response = responseObjectFactory.getFacetQueryResponse();
Set<ColumnVisibility> combinedColumnVisibility = new HashSet<>();
for (Object result : resultList) {
FacetsBase facet = (FacetsBase) result;
response.addFacet(facet);
for (FieldCardinalityBase fcb : facet.getFields()) {
if (StringUtils.isNotBlank(fcb.getColumnVisibility())) {
combinedColumnVisibility.add(new ColumnVisibility(fcb.getColumnVisibility()));
}
}
}
try {
ColumnVisibility columnVisibility = this.markingFunctions.combine(combinedColumnVisibility);
response.setMarkings(this.markingFunctions.translateFromColumnVisibility(columnVisibility));
} catch (MarkingFunctions.Exception e) {
log.warn(e);
// original ignored these exceptions
}
return response;
}
Aggregations