Search in sources :

Example 1 with CustomEntry

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;
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) IndexEntry(org.apache.rya.prospector.domain.IndexEntry) CustomEntry(org.apache.rya.prospector.utils.CustomEntry) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) IntermediateProspect(org.apache.rya.prospector.domain.IntermediateProspect) LongWritable(org.apache.hadoop.io.LongWritable) RyaType(org.apache.rya.api.domain.RyaType)

Aggregations

ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 LongWritable (org.apache.hadoop.io.LongWritable)1 RyaType (org.apache.rya.api.domain.RyaType)1 RyaURI (org.apache.rya.api.domain.RyaURI)1 IndexEntry (org.apache.rya.prospector.domain.IndexEntry)1 IntermediateProspect (org.apache.rya.prospector.domain.IntermediateProspect)1 CustomEntry (org.apache.rya.prospector.utils.CustomEntry)1