@Override public void send(Quad quad) { try { byte[] s = tdbloader3.serialize(quad.getSubject()).getBytes("UTF-8"); byte[] p = tdbloader3.serialize(quad.getPredicate()).getBytes("UTF-8"); byte[] o = tdbloader3.serialize(quad.getObject()).getBytes("UTF-8"); byte[] g = null; // Union graph?! if (!quad.isTriple() && !quad.isDefaultGraph()) g = tdbloader3.serialize(quad.getGraph()).getBytes("UTF-8"); digest.reset(); digest.update(s); // TODO: should we do something better here? digest.update(p); digest.update(o); if (g != null) digest.update(g.toString().getBytes("UTF-8")); String md5 = new String(Hex.encodeHex(digest.digest())); sdb01.add(new Pair<byte[], byte[]>(s, (md5 + "|s").getBytes("UTF-8"))); sdb01.add(new Pair<byte[], byte[]>(p, (md5 + "|p").getBytes("UTF-8"))); sdb01.add(new Pair<byte[], byte[]>(o, (md5 + "|o").getBytes("UTF-8"))); if (g != null) sdb01.add(new Pair<byte[], byte[]>(g, (md5 + "|g").getBytes("UTF-8"))); } catch (UnsupportedEncodingException e) { throw new AtlasException(e); } monitor.tick(); }
@Override public void add(Quad quad) { Graph graph; if (quad.isDefaultGraph()) { graph = getDefaultGraph(); } else { graph = getGraph(quad.getGraph()); } if (graph != null) { graph.add(quad.asTriple()); } }