// 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()); }
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)) ; }
@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; } }