예제 #1
0
 // check for duplicate code
 private static List<Tuple<NodeId>> convert(List<Triple> triples, NodeTable nodeTable) {
   return triples
       .stream()
       .map(
           t ->
               Tuple.createTuple(
                   nodeTable.getAllocateNodeId(t.getSubject()),
                   nodeTable.getAllocateNodeId(t.getPredicate()),
                   nodeTable.getAllocateNodeId(t.getObject())))
       .collect(Collectors.toList());
 }
예제 #2
0
  private static void convert(
      List<Triple> triples, List<Tuple<NodeId>> tuples, NodeTable nodeTable) {
    // Slightly faster.  But larger batches?
    for (Triple t : triples) {
      NodeId nid_s = nodeTable.getAllocateNodeId(t.getSubject());
      NodeId nid_p = nodeTable.getAllocateNodeId(t.getPredicate());
      NodeId nid_o = nodeTable.getAllocateNodeId(t.getObject());
      Tuple<NodeId> x = Tuple.createTuple(nid_s, nid_p, nid_o);
      tuples.add(x);
    }

    //        triples.stream().map(t->
    //                  Tuple.createTuple
    //                  (nodeTable.getAllocateNodeId(t.getSubject()),
    //                   nodeTable.getAllocateNodeId(t.getPredicate()),
    //                   nodeTable.getAllocateNodeId(t.getObject())))
    //                .collect(Collectors.toCollection(()->tuples)) ;
  }
예제 #3
0
  @Override
  public Node get1(Var var) {
    try {
      Node n = cacheGet(var);
      if (n != null) return n;

      NodeId id = idBinding.get(var);
      if (id == null) return null;
      n = nodeTable.getNodeForNodeId(id);
      // Update cache.
      cachePut(var, n);
      return n;
    } catch (Exception ex) {
      Log.fatal(this, String.format("get1(%s)", var), ex);
      return null;
    }
  }