public RyaStatementBuilder setTimestamp(final Long timestamp) { ryaStatement.setTimestamp(timestamp); return this; }
public RyaStatementBuilder setTimestamp(final Long timestamp) { ryaStatement.setTimestamp(timestamp); return this; }
/** * Creates a construct query graph represented as a Set of {@link RyaStatement}s * @param bs - VisiblityBindingSet used to build statement BindingSets * @return - Set of RyaStatements that represent a construct query graph. */ public Set<RyaStatement> createGraphFromBindingSet(VisibilityBindingSet bs) { Set<RyaStatement> bSets = new HashSet<>(); long ts = System.currentTimeMillis(); Map<String, BNode> bNodes = getBNodeMap(); for(ConstructProjection projection: projections) { RyaStatement statement = projection.projectBindingSet(bs, bNodes); //ensure that all RyaStatements in graph have the same timestamp statement.setTimestamp(ts); bSets.add(statement); } return bSets; }
/** * Creates a construct query graph represented as a Set of {@link RyaStatement}s * @param bs - VisibilityBindingSet used to build statement BindingSets * @return - Set of RyaStatements that represent a construct query graph. */ public Set<RyaStatement> createGraphFromBindingSet(VisibilityBindingSet bs) { Set<RyaStatement> bSets = new HashSet<>(); long ts = System.currentTimeMillis(); Map<String, BNode> bNodes = getBNodeMap(); for(ConstructProjection projection: projections) { RyaStatement statement = projection.projectBindingSet(bs, bNodes); //ensure that all RyaStatements in graph have the same timestamp statement.setTimestamp(ts); bSets.add(statement); } return bSets; }
curTime = statement.getTimestamp(); if(!childStore.containsStatement(statement)) { statement.setTimestamp(statement.getTimestamp() - timeOffset); childStore.addStatement(statement);
curTime = statement.getTimestamp(); if(!childStore.containsStatement(statement)) { statement.setTimestamp(statement.getTimestamp() - timeOffset); childStore.addStatement(statement);
/** * Loads a RyaStatementWritable by reading data from an input stream. * Creates a new RyaStatement and assigns it to this RyaStatementWritable. * @param dataInput An stream containing serialized statement data. */ @Override public void readFields(DataInput dataInput) throws IOException { byte[] row = read(dataInput); byte[] columnFamily = read(dataInput); byte[] columnQualifier = read(dataInput); byte[] columnVisibility = read(dataInput); byte[] value = read(dataInput); boolean b = dataInput.readBoolean(); Long timestamp = null; if (b) { timestamp = dataInput.readLong(); } try { ryaStatement = ryaContext.deserializeTriple(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO, new TripleRow(row, columnFamily, columnQualifier)); ryaStatement.setColumnVisibility(columnVisibility); ryaStatement.setValue(value); ryaStatement.setTimestamp(timestamp); } catch (TripleRowResolverException e) { throw new IOException(e); } } }
/** * Loads a RyaStatementWritable by reading data from an input stream. * Creates a new RyaStatement and assigns it to this RyaStatementWritable. * @param dataInput An stream containing serialized statement data. */ @Override public void readFields(DataInput dataInput) throws IOException { byte[] row = read(dataInput); byte[] columnFamily = read(dataInput); byte[] columnQualifier = read(dataInput); byte[] columnVisibility = read(dataInput); byte[] value = read(dataInput); boolean b = dataInput.readBoolean(); Long timestamp = null; if (b) { timestamp = dataInput.readLong(); } try { ryaStatement = ryaContext.deserializeTriple(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO, new TripleRow(row, columnFamily, columnQualifier)); ryaStatement.setColumnVisibility(columnVisibility); ryaStatement.setValue(value); ryaStatement.setTimestamp(timestamp); } catch (TripleRowResolverException e) { throw new IOException(e); } } }
@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); } }
@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); } }
statement.setTimestamp(timestamp);
@Test public void testDeSerializeStatementToDBO() throws RyaDAOException, MongoException, IOException { RyaStatement statement = storageStrategy.deserializeDBObject(testDBO); /* * Since RyaStatement creates a timestamp using JVM time if the timestamp is null, we want to re-null it * for this test. Timestamp is created at insert time by the Server, this test * can be found in the RyaDAO. */ statement.setTimestamp(null); assertEquals(testStatement, statement); statement = storageStrategy.deserializeDBObject(testDBO2); /* * Since RyaStatement creates a timestamp using JVM time if the timestamp is null, we want to re-null it * for this test. Timestamp is created at insert time by the Server, this test * can be found in the RyaDAO. */ statement.setTimestamp(null); assertEquals(testStatement2, statement); } }
statement.setTimestamp(timestamp);
@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); }
statement.setTimestamp(input.readLong());
statement.setTimestamp(input.readLong());
@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); }