Пример #1
0
 protected Statement peekNextStatement() throws Exception {
   if (!statefulHasNext()) return null;
   Map.Entry<Key, Value> entry = iter.peek();
   Key key = entry.getKey();
   if (DOC.equals(key.getColumnFamily()))
     return readStatement(
         ByteStreams.newDataInput(key.getColumnQualifier().getBytes()), VALUE_FACTORY);
   else
     return readStatement(
         ByteStreams.newDataInput(key.getColumnQualifier().getBytes()), VALUE_FACTORY, false);
 }
 public static Namespace getNamespace(Iterator<Entry<Key, Value>> rowResults) {
   for (; rowResults.hasNext(); ) {
     Entry<Key, Value> next = rowResults.next();
     Key key = next.getKey();
     Value val = next.getValue();
     String cf = key.getColumnFamily().toString();
     String cq = key.getColumnQualifier().toString();
     return new NamespaceImpl(key.getRow().toString(), new String(val.get()));
   }
   return null;
 }
Пример #3
0
  protected List<Statement> nextDocument() throws QueryEvaluationException {
    try {
      Map.Entry<Key, Value> entry = iter.peek();
      Key key = entry.getKey();
      Value value = entry.getValue();

      if (value.getSize() == 0) {
        // not an aggregate document
        return nextNonAggregateDocument();
        //                return
        // Collections.singletonList(RdfIO.readStatement(ByteStreams.newDataInput(key.getColumnQualifier().getBytes()), VALUE_FACTORY, true));
      }

      List<Statement> document = new ArrayList<Statement>();

      org.openrdf.model.Value subj =
          RdfIO.readValue(
              ByteStreams.newDataInput(key.getColumnQualifier().getBytes()),
              VALUE_FACTORY,
              FAMILY_DELIM);
      Map<String, String> map = converter.toMap(entry.getKey(), value);
      for (Map.Entry<String, String> e : map.entrySet()) {
        String predObj = e.getKey();
        String[] split = predObj.split(FAMILY_DELIM_STR);
        document.add(
            new StatementImpl(
                (Resource) subj,
                VALUE_FACTORY.createURI(split[0]),
                RdfIO.readValue(
                    ByteStreams.newDataInput(split[1].getBytes()), VALUE_FACTORY, FAMILY_DELIM)));
      }
      iter.next();
      return document;
    } catch (Exception e) {
      throw new QueryEvaluationException("Error retrieving document", e);
    }
  }