/** * Perform an ACID update (delete+insert) per the semantics of <a href= * "https://sourceforge.net/apps/mediawiki/bigdata/index.php?title=NanoSparqlServer#UPDATE_.28DELETE_.2B_INSERT.29" * > the NanoSparqlServer. </a> * <p> * Currently, the only combination supported is delete by query with add by * post (Iterable<Statement> and File). You can embed statements you want to * delete inside a construct query without a where clause. * * @param remove * The RDF data to be removed. * @param add * The RDF data to be added. * * @return The mutation count. */ public long update(final RemoveOp remove, final AddOp add) throws Exception { return update(remove, add, UUID.randomUUID()); }
@Override protected void flushStatements(final List<Statement> m_inserts, final List<Statement> m_removes) { // handle batch removes try { final RemoveOp rop = m_removes.size() > 0 ? new RemoveOp(m_removes) : null; final AddOp iop = m_inserts.size() > 0 ? new AddOp(m_inserts) : null; if (rop != null && iop != null) { // Execute update. m_repo.update(rop, iop); } else if (iop != null) { // Execute add m_repo.add(iop); } else if (rop != null) { // Execute remove. m_repo.remove(rop); } } catch (Exception e) { throw new RuntimeException("Unable to flush statements", e); } }
@Override protected void flushStatements(final List<Statement> m_inserts, final List<Statement> m_removes) { // handle batch removes try { final RemoveOp rop = m_removes.size() > 0 ? new RemoveOp(m_removes) : null; final AddOp iop = m_inserts.size() > 0 ? new AddOp(m_inserts) : null; if (rop != null && iop != null) { // Execute update. m_repo.update(rop, iop); } else if (iop != null) { // Execute add m_repo.add(iop); } else if (rop != null) { // Execute remove. m_repo.remove(rop); } } catch (Exception e) { throw new RuntimeException("Unable to flush statements", e); } }