@Test public void Update_with_nulls() { conn.update(Collections.<STMT> emptySet(), null); conn.update(null, Collections.<STMT> emptySet()); conn.update(null, null); }
@Override public void update(Collection<STMT> removedStatements, Collection<STMT> addedStatements) { Set<NODE> oldNodes = new HashSet<NODE>(); if (removedStatements != null) { for (STMT stmt : removedStatements) { if (stmt.getContext() != null) { oldNodes.add(stmt.getContext()); } oldNodes.add(stmt.getSubject()); oldNodes.add(stmt.getPredicate()); oldNodes.add(stmt.getObject()); } if (!removedStatements.isEmpty()) { Iterator<STMT> stmts = removedStatements.iterator(); SQLDeleteClause delete = context.createDelete(statement); populate(delete, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(delete, statement, stmts.next()).addBatch(); if (counter == DELETE_BATCH) { delete.execute(); delete = context.createDelete(statement); counter = 0; } } if (counter > 0) { delete.execute(); } } } Set<NODE> newNodes = new HashSet<NODE>(); if (addedStatements != null) { for (STMT stmt : addedStatements) { if (stmt.getContext() != null) { newNodes.add(stmt.getContext()); } newNodes.add(stmt.getSubject()); newNodes.add(stmt.getPredicate()); newNodes.add(stmt.getObject()); if (stmt.getObject().isLiteral()) { LIT lit = stmt.getObject().asLiteral(); if (lit.getDatatype() != null) { newNodes.add(lit.getDatatype()); } } } } newNodes.removeAll(oldNodes); newNodes.removeAll(context.getNodes()); addNodes(newNodes, null); if (addedStatements != null && !addedStatements.isEmpty()) { Iterator<STMT> stmts = addedStatements.iterator(); SQLMergeClause merge = context.createMerge(statement); populate(merge, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(merge, statement, stmts.next()).addBatch(); if (counter == ADD_BATCH) { merge.execute(); merge = context.createMerge(statement); counter = 0; } } if (counter > 0) { merge.execute(); } } }
RDBConnection implements RDFConnection { @Override public void update(Collection<STMT> removedStatements, Collection<STMT> addedStatements) { Set<NODE> oldNodes = new HashSet<NODE>(); if (removedStatements != null) { for (STMT stmt : removedStatements) { if (stmt.getContext() != null) { oldNodes.add(stmt.getContext()); } oldNodes.add(stmt.getSubject()); oldNodes.add(stmt.getPredicate()); oldNodes.add(stmt.getObject()); } if (!removedStatements.isEmpty()) { Iterator<STMT> stmts = removedStatements.iterator(); SQLDeleteClause delete = context.createDelete(statement); populate(delete, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(delete, statement, stmts.next()).addBatch(); if (counter == DELETE_BATCH) { delete.execute(); delete = context.createDelete(statement); counter = 0; } } if (counter > 0) { delete.execute(); } } } Set<NODE> newNodes = new HashSet<NODE>(); if (addedStatements != null) { for (STMT stmt : addedStatements) { if (stmt.getContext() != null) { newNodes.add(stmt.getContext()); } newNodes.add(stmt.getSubject()); newNodes.add(stmt.getPredicate()); newNodes.add(stmt.getObject()); if (stmt.getObject().isLiteral()) { LIT lit = stmt.getObject().asLiteral(); if (lit.getDatatype() != null) { newNodes.add(lit.getDatatype()); } } } } newNodes.removeAll(oldNodes); newNodes.removeAll(context.getNodes()); addNodes(newNodes, null); if (addedStatements != null && !addedStatements.isEmpty()) { Iterator<STMT> stmts = addedStatements.iterator(); SQLMergeClause merge = context.createMerge(statement); populate(merge, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(merge, statement, stmts.next()).addBatch(); if (counter == ADD_BATCH) { merge.execute(); merge = context.createMerge(statement); counter = 0; } } if (counter > 0) { merge.execute(); } } } }
RDBConnection implements RDFConnection { @Override public void update(Collection<STMT> removedStatements, Collection<STMT> addedStatements) { Set<NODE> oldNodes = new HashSet<NODE>(); if (removedStatements != null) { for (STMT stmt : removedStatements) { if (stmt.getContext() != null) { oldNodes.add(stmt.getContext()); } oldNodes.add(stmt.getSubject()); oldNodes.add(stmt.getPredicate()); oldNodes.add(stmt.getObject()); } if (!removedStatements.isEmpty()) { Iterator<STMT> stmts = removedStatements.iterator(); SQLDeleteClause delete = context.createDelete(statement); populate(delete, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(delete, statement, stmts.next()).addBatch(); if (counter == DELETE_BATCH) { delete.execute(); delete = context.createDelete(statement); counter = 0; } } if (counter > 0) { delete.execute(); } } } Set<NODE> newNodes = new HashSet<NODE>(); if (addedStatements != null) { for (STMT stmt : addedStatements) { if (stmt.getContext() != null) { newNodes.add(stmt.getContext()); } newNodes.add(stmt.getSubject()); newNodes.add(stmt.getPredicate()); newNodes.add(stmt.getObject()); if (stmt.getObject().isLiteral()) { LIT lit = stmt.getObject().asLiteral(); if (lit.getDatatype() != null) { newNodes.add(lit.getDatatype()); } } } } newNodes.removeAll(oldNodes); newNodes.removeAll(context.getNodes()); addNodes(newNodes, null); if (addedStatements != null && !addedStatements.isEmpty()) { Iterator<STMT> stmts = addedStatements.iterator(); SQLMergeClause merge = context.createMerge(statement); populate(merge, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(merge, statement, stmts.next()).addBatch(); if (counter == ADD_BATCH) { merge.execute(); merge = context.createMerge(statement); counter = 0; } } if (counter > 0) { merge.execute(); } } } RDBConnection(RDBContext context); }
RDBConnection implements RDFConnection { @Override public void update(Collection<STMT> removedStatements, Collection<STMT> addedStatements) { Set<NODE> oldNodes = new HashSet<NODE>(); if (removedStatements != null) { for (STMT stmt : removedStatements) { if (stmt.getContext() != null) { oldNodes.add(stmt.getContext()); } oldNodes.add(stmt.getSubject()); oldNodes.add(stmt.getPredicate()); oldNodes.add(stmt.getObject()); } if (!removedStatements.isEmpty()) { Iterator<STMT> stmts = removedStatements.iterator(); SQLDeleteClause delete = context.createDelete(statement); populate(delete, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(delete, statement, stmts.next()).addBatch(); if (counter == DELETE_BATCH) { delete.execute(); delete = context.createDelete(statement); counter = 0; } } if (counter > 0) { delete.execute(); } } } Set<NODE> newNodes = new HashSet<NODE>(); if (addedStatements != null) { for (STMT stmt : addedStatements) { if (stmt.getContext() != null) { newNodes.add(stmt.getContext()); } newNodes.add(stmt.getSubject()); newNodes.add(stmt.getPredicate()); newNodes.add(stmt.getObject()); if (stmt.getObject().isLiteral()) { LIT lit = stmt.getObject().asLiteral(); if (lit.getDatatype() != null) { newNodes.add(lit.getDatatype()); } } } } newNodes.removeAll(oldNodes); newNodes.removeAll(context.getNodes()); addNodes(newNodes, null); if (addedStatements != null && !addedStatements.isEmpty()) { Iterator<STMT> stmts = addedStatements.iterator(); SQLMergeClause merge = context.createMerge(statement); populate(merge, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(merge, statement, stmts.next()).addBatch(); if (counter == ADD_BATCH) { merge.execute(); merge = context.createMerge(statement); counter = 0; } } if (counter > 0) { merge.execute(); } } } RDBConnection(RDBContext context); void addLocales(Set<Locale> l, @Nullable BiMap<Locale, Integer> cache); void addNodes(Set<NODE> n, @Nullable BiMap<NODE, Long> cache); @Override RDFBeanTransaction beginTransaction(boolean readOnly, int txTimeout, int isolationLevel); @Override void clear(); @Override void close(); @Override BID createBNode(); @Override Q createUpdate(UpdateLanguage<D, Q> updateLanguage, D definition); @SuppressWarnings("unchecked") @Override Q createQuery(QueryLanguage<D, Q> queryLanguage, D definition); void deleteFromContext(UID model); List<STMT> find(
            @Nullable ID subject,
            @Nullable UID predicate,
            @Nullable NODE object,
            @Nullable UID model, boolean includeInferred); @Override @SuppressWarnings("serial") CloseableIterator<STMT> findStatements(
            @Nullable final ID subject,
            @Nullable final UID predicate,
            @Nullable final NODE object,
            @Nullable final UID model, boolean includeInferred); @Override boolean exists(ID subject, UID predicate, NODE object, UID context, boolean includeInferred); @Override long getNextLocalId(); @Override void remove(ID s, UID p, NODE o, UID c); @Override void update(Collection<STMT> removedStatements, Collection<STMT> addedStatements); @Override QueryOptions getQueryOptions(); @Override InferenceOptions getInferenceOptions(); }
RDBConnection implements RDFConnection { @Override public void update(Collection<STMT> removedStatements, Collection<STMT> addedStatements) { Set<NODE> oldNodes = new HashSet<NODE>(); if (removedStatements != null) { for (STMT stmt : removedStatements) { if (stmt.getContext() != null) { oldNodes.add(stmt.getContext()); } oldNodes.add(stmt.getSubject()); oldNodes.add(stmt.getPredicate()); oldNodes.add(stmt.getObject()); } if (!removedStatements.isEmpty()) { Iterator<STMT> stmts = removedStatements.iterator(); SQLDeleteClause delete = context.createDelete(statement); populate(delete, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(delete, statement, stmts.next()).addBatch(); if (counter == DELETE_BATCH) { delete.execute(); delete = context.createDelete(statement); counter = 0; } } if (counter > 0) { delete.execute(); } } } Set<NODE> newNodes = new HashSet<NODE>(); if (addedStatements != null) { for (STMT stmt : addedStatements) { if (stmt.getContext() != null) { newNodes.add(stmt.getContext()); } newNodes.add(stmt.getSubject()); newNodes.add(stmt.getPredicate()); newNodes.add(stmt.getObject()); if (stmt.getObject().isLiteral()) { LIT lit = stmt.getObject().asLiteral(); if (lit.getDatatype() != null) { newNodes.add(lit.getDatatype()); } } } } newNodes.removeAll(oldNodes); newNodes.removeAll(context.getNodes()); addNodes(newNodes, null); if (addedStatements != null && !addedStatements.isEmpty()) { Iterator<STMT> stmts = addedStatements.iterator(); SQLMergeClause merge = context.createMerge(statement); populate(merge, statement, stmts.next()).addBatch(); int counter = 1; while (stmts.hasNext()) { counter++; populate(merge, statement, stmts.next()).addBatch(); if (counter == ADD_BATCH) { merge.execute(); merge = context.createMerge(statement); counter = 0; } } if (counter > 0) { merge.execute(); } } } RDBConnection(RDBContext context); void addLocales(Set<Locale> l, @Nullable BiMap<Locale, Integer> cache); void addNodes(Set<NODE> n, @Nullable BiMap<NODE, Long> cache); @Override RDFBeanTransaction beginTransaction(boolean readOnly, int txTimeout, int isolationLevel); @Override void clear(); @Override void close(); @Override BID createBNode(); @Override Q createUpdate(UpdateLanguage<D, Q> updateLanguage, D definition); @SuppressWarnings("unchecked") @Override Q createQuery(QueryLanguage<D, Q> queryLanguage, D definition); void deleteFromContext(UID model); List<STMT> find(
            @Nullable ID subject,
            @Nullable UID predicate,
            @Nullable NODE object,
            @Nullable UID model, boolean includeInferred); @Override @SuppressWarnings("serial") CloseableIterator<STMT> findStatements(
            @Nullable final ID subject,
            @Nullable final UID predicate,
            @Nullable final NODE object,
            @Nullable final UID model, boolean includeInferred); @Override boolean exists(ID subject, UID predicate, NODE object, UID context, boolean includeInferred); @Override long getNextLocalId(); @Override void remove(ID s, UID p, NODE o, UID c); @Override void update(Collection<STMT> removedStatements, Collection<STMT> addedStatements); @Override QueryOptions getQueryOptions(); @Override InferenceOptions getInferenceOptions(); static final QSymbol con; static final QSymbol obj; static final QSymbol pre; static final QSymbol sub; }