use of org.apache.rya.prospector.utils.CustomEntry in project incubator-rya by apache.
the class CountPlan method map.
@Override
public Collection<Map.Entry<IntermediateProspect, LongWritable>> map(final RyaStatement ryaStatement) {
final RyaURI subject = ryaStatement.getSubject();
final RyaURI predicate = ryaStatement.getPredicate();
final String subjpred = ryaStatement.getSubject().getData() + DELIM + ryaStatement.getPredicate().getData();
final String predobj = ryaStatement.getPredicate().getData() + DELIM + ryaStatement.getObject().getData();
final String subjobj = ryaStatement.getSubject().getData() + DELIM + ryaStatement.getObject().getData();
final RyaType object = ryaStatement.getObject();
final int localIndex = URIUtil.getLocalNameIndex(subject.getData());
final String namespace = subject.getData().substring(0, localIndex - 1);
final String visibility = new String(ryaStatement.getColumnVisibility(), StandardCharsets.UTF_8);
final List<Map.Entry<IntermediateProspect, LongWritable>> entries = new ArrayList<>(7);
// Create an entry for each TripleValueType type.
entries.add(new CustomEntry<IntermediateProspect, LongWritable>(IntermediateProspect.builder().setIndex(COUNT).setData(subject.getData()).setDataType(URITYPE).setTripleValueType(TripleValueType.SUBJECT).setVisibility(visibility).build(), ONE));
entries.add(new CustomEntry<IntermediateProspect, LongWritable>(IntermediateProspect.builder().setIndex(COUNT).setData(predicate.getData()).setDataType(URITYPE).setTripleValueType(TripleValueType.PREDICATE).setVisibility(visibility).build(), ONE));
entries.add(new CustomEntry<IntermediateProspect, LongWritable>(IntermediateProspect.builder().setIndex(COUNT).setData(object.getData()).setDataType(object.getDataType().stringValue()).setTripleValueType(TripleValueType.OBJECT).setVisibility(visibility).build(), ONE));
entries.add(new CustomEntry<IntermediateProspect, LongWritable>(IntermediateProspect.builder().setIndex(COUNT).setData(subjpred).setDataType(XMLSchema.STRING.toString()).setTripleValueType(TripleValueType.SUBJECT_PREDICATE).setVisibility(visibility).build(), ONE));
entries.add(new CustomEntry<IntermediateProspect, LongWritable>(IntermediateProspect.builder().setIndex(COUNT).setData(subjobj).setDataType(XMLSchema.STRING.toString()).setTripleValueType(TripleValueType.SUBJECT_OBJECT).setVisibility(visibility).build(), ONE));
entries.add(new CustomEntry<IntermediateProspect, LongWritable>(IntermediateProspect.builder().setIndex(COUNT).setData(predobj).setDataType(XMLSchema.STRING.toString()).setTripleValueType(TripleValueType.PREDICATE_OBJECT).setVisibility(visibility).build(), ONE));
entries.add(new CustomEntry<IntermediateProspect, LongWritable>(IntermediateProspect.builder().setIndex(COUNT).setData(namespace).setDataType(URITYPE).setTripleValueType(TripleValueType.ENTITY).setVisibility(visibility).build(), ONE));
return entries;
}
Aggregations