use of datawave.webservice.query.result.event.FieldCardinalityBase in project datawave by NationalSecurityAgency.
the class FacetedTransformer method buildFacets.
/**
* Accepts an attribute. The document data will be placed into the value of the Field.
*
* @param documentKey
* @param fieldName
* @param attr
* @param topLevelColumnVisibility
* @param markingFunctions
* @return
*/
protected Collection<FieldCardinalityBase> buildFacets(Key documentKey, String fieldName, Attribute<?> attr, ColumnVisibility topLevelColumnVisibility, MarkingFunctions markingFunctions) {
Set<FieldCardinalityBase> myFields = new HashSet<>();
if (attr instanceof Attributes) {
Attributes attributeList = Attributes.class.cast(attr);
for (Attribute<?> embeddedAttr : attributeList.getAttributes()) myFields.addAll(buildFacets(documentKey, fieldName, embeddedAttr, topLevelColumnVisibility, markingFunctions));
} else {
// Use the markings on the Field if we're returning the markings to the client
if (attr instanceof Cardinality) {
try {
Cardinality card = (Cardinality) attr;
FieldValueCardinality v = card.getContent();
StringType value = new StringType();
value.setDelegate(v.toString());
value.setNormalizedValue(v.toString());
FieldCardinalityBase fc = this.responseObjectFactory.getFieldCardinality();
fc.setField(v.getFieldName());
// reduces colvis based on
fc.setMarkings(markingFunctions.translateFromColumnVisibilityForAuths(attr.getColumnVisibility(), auths));
// visibility
fc.setColumnVisibility(new String(markingFunctions.translateToColumnVisibility(fc.getMarkings()).flatten()));
fc.setLower(v.getFloorValue());
fc.setUpper(v.getCeilingValue());
fc.setCardinality(v.getEstimate().cardinality());
myFields.add(fc);
} catch (Exception e) {
log.error("unable to process markings:" + e);
}
}
}
return myFields;
}
use of datawave.webservice.query.result.event.FieldCardinalityBase 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.FieldCardinalityBase 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