if(statement.getTimestamp() > metadata.getTimestamp().getTime()) { break; curTime = statement.getTimestamp(); if(!childStore.containsStatement(statement)) { statement.setTimestamp(statement.getTimestamp() - timeOffset); childStore.addStatement(statement);
if(statement.getTimestamp() > metadata.getTimestamp().getTime()) { break; curTime = statement.getTimestamp(); if(!childStore.containsStatement(statement)) { statement.setTimestamp(statement.getTimestamp() - timeOffset); childStore.addStatement(statement);
write(dataOutput, ryaStatement.getColumnVisibility()); write(dataOutput, ryaStatement.getValue()); Long timestamp = ryaStatement.getTimestamp(); boolean b = timestamp != null; dataOutput.writeBoolean(b);
write(dataOutput, ryaStatement.getColumnVisibility()); write(dataOutput, ryaStatement.getValue()); Long timestamp = ryaStatement.getTimestamp(); boolean b = timestamp != null; dataOutput.writeBoolean(b);
@Override public void addStatement(final RyaStatement statement) throws AddStatementException { try { accumuloRyaDao.add(statement); accumuloRyaDao.flush(); //This is a hack since a statement re-added with the same timestamp won't reappear since its been marked for deletion. //RYA-197 is the ticket for fixing this hack. if(!containsStatement(statement)) { statement.setTimestamp(statement.getTimestamp() + 1L); accumuloRyaDao.add(statement); } } catch (final RyaDAOException | ContainsStatementException e) { throw new AddStatementException("Unable to add the Rya Statement", e); } }
private static List<TripleRow> serializeStatement(final RyaStatement stmt) throws RyaTypeResolverException { final RyaURI subject = stmt.getSubject(); final RyaURI predicate = stmt.getPredicate(); final RyaType object = stmt.getObject(); final RyaURI context = stmt.getContext(); final Long timestamp = stmt.getTimestamp(); final byte[] columnVisibility = stmt.getColumnVisibility(); final byte[] value = stmt.getValue(); assert subject != null && predicate != null && object != null; final byte[] cf = (context == null) ? EMPTY_BYTES : context.getData().getBytes(StandardCharsets.UTF_8); final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8); final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8); final byte[][] objBytes = RyaContext.getInstance().serializeType(object); return Lists.newArrayList(new TripleRow(subjBytes, predBytes, Bytes.concat(cf, DELIM_BYTES, OBJECT.getBytes(StandardCharsets.UTF_8), DELIM_BYTES, objBytes[0], objBytes[1]), timestamp, columnVisibility, value), new TripleRow(objBytes[0], predBytes, Bytes.concat(cf, DELIM_BYTES, SUBJECT.getBytes(StandardCharsets.UTF_8), DELIM_BYTES, subjBytes, objBytes[1]), timestamp, columnVisibility, value)); }
@Override public void addStatement(final RyaStatement statement) throws AddStatementException { try { accumuloRyaDao.add(statement); accumuloRyaDao.flush(); //This is a hack since a statement re-added with the same timestamp won't reappear since its been marked for deletion. //RYA-197 is the ticket for fixing this hack. if(!containsStatement(statement)) { statement.setTimestamp(statement.getTimestamp() + 1L); accumuloRyaDao.add(statement); } } catch (final RyaDAOException | ContainsStatementException e) { throw new AddStatementException("Unable to add the Rya Statement", e); } }
private static List<TripleRow> serializeStatement(final RyaStatement stmt) throws RyaTypeResolverException { final RyaIRI subject = stmt.getSubject(); final RyaIRI predicate = stmt.getPredicate(); final RyaType object = stmt.getObject(); final RyaIRI context = stmt.getContext(); final Long timestamp = stmt.getTimestamp(); final byte[] columnVisibility = stmt.getColumnVisibility(); final byte[] value = stmt.getValue(); assert subject != null && predicate != null && object != null; final byte[] cf = (context == null) ? EMPTY_BYTES : context.getData().getBytes(StandardCharsets.UTF_8); final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8); final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8); final byte[][] objBytes = RyaContext.getInstance().serializeType(object); return Lists.newArrayList(new TripleRow(subjBytes, predBytes, Bytes.concat(cf, DELIM_BYTES, OBJECT.getBytes(StandardCharsets.UTF_8), DELIM_BYTES, objBytes[0], objBytes[1]), timestamp, columnVisibility, value), new TripleRow(objBytes[0], predBytes, Bytes.concat(cf, DELIM_BYTES, SUBJECT.getBytes(StandardCharsets.UTF_8), DELIM_BYTES, subjBytes, objBytes[1]), timestamp, columnVisibility, value)); }
final RyaType object = stmt.getObject(); final RyaURI context = stmt.getContext(); final Long timestamp = stmt.getTimestamp(); final byte[] columnVisibility = stmt.getColumnVisibility(); final String qualifer = stmt.getQualifer();
final RyaType object = stmt.getObject(); final RyaIRI context = stmt.getContext(); final Long timestamp = stmt.getTimestamp(); final byte[] columnVisibility = stmt.getColumnVisibility(); final String qualifer = stmt.getQualifer();
private static RyaStatement updateRyaStatementColumnVisibility(final RyaStatement ryaStatement, final ColumnVisibility newCv) { final RyaStatement newCvRyaStatement = new RyaStatement(ryaStatement.getSubject(), ryaStatement.getPredicate(), ryaStatement.getObject(), ryaStatement.getContext(), ryaStatement.getQualifer(), newCv.getExpression(), ryaStatement.getValue(), ryaStatement.getTimestamp()); return newCvRyaStatement; }
output.writeString(object.getQualifer()); shouldWrite = object.getTimestamp() != null; output.writeBoolean(shouldWrite); if(shouldWrite){ output.writeLong(object.getTimestamp());
.append(STATEMENT_METADATA, statement.getMetadata().toString()) .append(DOCUMENT_VISIBILITY, dvObject.get(DOCUMENT_VISIBILITY)) .append(TIMESTAMP, statement.getTimestamp()); return doc;
output.writeString(object.getQualifer()); shouldWrite = object.getTimestamp() != null; output.writeBoolean(shouldWrite); if(shouldWrite){ output.writeLong(object.getTimestamp());
.append(STATEMENT_METADATA, statement.getMetadata().toString()) .append(DOCUMENT_VISIBILITY, dvObject.get(DOCUMENT_VISIBILITY)) .append(TIMESTAMP, statement.getTimestamp()); return doc;
/** * Comparison method for natural ordering. Compares based on the logical * triple (the s/p/o/context information in the underlying RyaStatement) * and then by the metadata contained in the RyaStatement if the triples are * the same. * @return Zero if both RyaStatementWritables contain equivalent statements * or both have null statements; otherwise, an integer whose sign * corresponds to a consistent ordering. */ @Override public int compareTo(RyaStatementWritable other) { CompareToBuilder builder = new CompareToBuilder(); RyaStatement rsThis = this.getRyaStatement(); RyaStatement rsOther = other.getRyaStatement(); // should throw NPE if other is null, as per Comparable contract builder.append(rsThis == null, rsOther == null); if (rsThis != null && rsOther != null) { builder.append(rsThis.getSubject(), rsOther.getSubject()); builder.append(rsThis.getPredicate(), rsOther.getPredicate()); builder.append(rsThis.getObject(), rsOther.getObject()); builder.append(rsThis.getContext(), rsOther.getContext()); builder.append(rsThis.getQualifer(), rsOther.getQualifer()); builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility()); builder.append(rsThis.getValue(), rsOther.getValue()); builder.append(rsThis.getTimestamp(), rsOther.getTimestamp()); } return builder.toComparison(); }
/** * Comparison method for natural ordering. Compares based on the logical * triple (the s/p/o/context information in the underlying RyaStatement) * and then by the metadata contained in the RyaStatement if the triples are * the same. * @return Zero if both RyaStatementWritables contain equivalent statements * or both have null statements; otherwise, an integer whose sign * corresponds to a consistent ordering. */ @Override public int compareTo(RyaStatementWritable other) { CompareToBuilder builder = new CompareToBuilder(); RyaStatement rsThis = this.getRyaStatement(); RyaStatement rsOther = other.getRyaStatement(); // should throw NPE if other is null, as per Comparable contract builder.append(rsThis == null, rsOther == null); if (rsThis != null && rsOther != null) { builder.append(rsThis.getSubject(), rsOther.getSubject()); builder.append(rsThis.getPredicate(), rsOther.getPredicate()); builder.append(rsThis.getObject(), rsOther.getObject()); builder.append(rsThis.getContext(), rsOther.getContext()); builder.append(rsThis.getQualifer(), rsOther.getQualifer()); builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility()); builder.append(rsThis.getValue(), rsOther.getValue()); builder.append(rsThis.getTimestamp(), rsOther.getTimestamp()); } return builder.toComparison(); }
@Test public void testConstructProjectionProjectSubj() throws MalformedQueryException, UnsupportedEncodingException { String query = "select ?x where { ?x <uri:talksTo> <uri:Bob> }"; SPARQLParser parser = new SPARQLParser(); ParsedQuery pq = parser.parseQuery(query, null); List<StatementPattern> patterns = StatementPatternCollector.process(pq.getTupleExpr()); ConstructProjection projection = new ConstructProjection(patterns.get(0)); QueryBindingSet bs = new QueryBindingSet(); bs.addBinding("x", VF.createIRI("uri:Joe")); VisibilityBindingSet vBs = new VisibilityBindingSet(bs, "FOUO"); RyaStatement statement = projection.projectBindingSet(vBs, new HashMap<>()); RyaStatement expected = new RyaStatement(new RyaIRI("uri:Joe"), new RyaIRI("uri:talksTo"), new RyaIRI("uri:Bob")); expected.setColumnVisibility("FOUO".getBytes("UTF-8")); expected.setTimestamp(statement.getTimestamp()); assertEquals(expected, statement); }
@Test public void testConstructProjectionBNodes() throws MalformedQueryException { String query = "select ?o where { _:b <uri:talksTo> ?o }"; SPARQLParser parser = new SPARQLParser(); ParsedQuery pq = parser.parseQuery(query, null); List<StatementPattern> patterns = StatementPatternCollector.process(pq.getTupleExpr()); ConstructProjection projection = new ConstructProjection(patterns.get(0)); QueryBindingSet bs = new QueryBindingSet(); bs.addBinding("o", VF.createIRI("uri:Bob")); VisibilityBindingSet vBs = new VisibilityBindingSet(bs); BNode bNode = VF.createBNode(); Map<String, BNode> bNodeMap = new HashMap<>(); bNodeMap.put(VarNameUtils.prependAnonymous("1"), bNode); RyaStatement statement = projection.projectBindingSet(vBs,bNodeMap); RyaStatement expected = new RyaStatement(RdfToRyaConversions.convertResource(bNode), new RyaIRI("uri:talksTo"), new RyaIRI("uri:Bob")); expected.setTimestamp(statement.getTimestamp()); expected.setColumnVisibility(new byte[0]); assertEquals(expected, statement); }
@Test public void testConstructProjectionProjPred() throws MalformedQueryException { String query = "select ?p where { <uri:Joe> ?p <uri:Bob> }"; SPARQLParser parser = new SPARQLParser(); ParsedQuery pq = parser.parseQuery(query, null); List<StatementPattern> patterns = StatementPatternCollector.process(pq.getTupleExpr()); ConstructProjection projection = new ConstructProjection(patterns.get(0)); QueryBindingSet bs = new QueryBindingSet(); bs.addBinding("p", VF.createIRI("uri:worksWith")); VisibilityBindingSet vBs = new VisibilityBindingSet(bs); RyaStatement statement = projection.projectBindingSet(vBs, new HashMap<>()); RyaStatement expected = new RyaStatement(new RyaIRI("uri:Joe"), new RyaIRI("uri:worksWith"), new RyaIRI("uri:Bob")); expected.setTimestamp(statement.getTimestamp()); expected.setColumnVisibility(new byte[0]); assertEquals(expected, statement); }