@Override public RyaStatement next() throws RyaDAOException { Map.Entry<RyaIRI, RyaType> subjObj = keys.nextElement(); return new RyaStatement(subjObj.getKey(), null, subjObj.getValue()); }
@Override public RyaStatement next() throws RyaDAOException { Map.Entry<RyaURI, RyaType> subjObj = keys.nextElement(); return new RyaStatement(subjObj.getKey(), null, subjObj.getValue()); }
/** * Gets the metadata key from the table. * @param predicateRyaIri the predicate {@link RyaIRI}. * @param dao the {@link AccumuloRyaDAO}. * @return the string value of the object from the metadata key. * @throws RyaDAOException */ private static String getMetadata(final RyaIRI predicateRyaIri, final AccumuloRyaDAO dao) throws RyaDAOException { final RyaStatement ryaStatement = new RyaStatement(RTS_SUBJECT_RYA, predicateRyaIri, null); return getMetadata(ryaStatement, dao); }
private boolean batchNext() throws RyaDAOException { if (!iteration.hasNext()) { return false; } Collection<Map.Entry<RyaStatement, BindingSet>> batchedResults = new ArrayList<Map.Entry<RyaStatement, BindingSet>>(); for (int i = 0; i < batch && iteration.hasNext(); i++) { batchedResults.add(new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>( new RyaStatement(iteration.next(), predObj.getKey(), predObj.getValue()), null)); } query = ryaQueryEngine.queryWithBindingSet(batchedResults, null); return query.hasNext(); }
private boolean batchNext() throws RyaDAOException { if (!iteration.hasNext()) { return false; } Collection<Map.Entry<RyaStatement, BindingSet>> batchedResults = new ArrayList<Map.Entry<RyaStatement, BindingSet>>(); for (int i = 0; i < batch && iteration.hasNext(); i++) { batchedResults.add(new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>( new RyaStatement(iteration.next(), predObj.getKey(), predObj.getValue()), null)); } query = ryaQueryEngine.queryWithBindingSet(batchedResults, null); return query.hasNext(); }
/** * Creates a copy tool run time {@link RyaStatement} from the specified {@link Date}. * @param date the copy tool run time {@link Date}. * @return the {@link RyaStatement} for the copy tool run time. */ public static RyaStatement createCopyToolRunTimeRyaStatement(final Date date) { final Literal literal = VALUE_FACTORY.createLiteral(date != null ? date : DEFAULT_DATE); final RyaType timeObject = new RyaType(literal.getDatatype(), literal.stringValue()); return new RyaStatement(RTS_SUBJECT_RYA, RTS_COPY_TOOL_RUN_TIME_PREDICATE_RYA, timeObject); }
@Override public String getVersion() throws RyaDAOException { String version = null; final CloseableIteration<RyaStatement, RyaDAOException> versIter = queryEngine.query(new RyaStatement(RTS_SUBJECT_RYA, RTS_VERSION_PREDICATE_RYA, null), conf); if (versIter.hasNext()) { version = versIter.next().getObject().getData(); } versIter.close(); return version; }
@Override public String getVersion() throws RyaDAOException { String version = null; final CloseableIteration<RyaStatement, RyaDAOException> versIter = queryEngine.query(new RyaStatement(RTS_SUBJECT_RYA, RTS_VERSION_PREDICATE_RYA, null), conf); if (versIter.hasNext()) { version = versIter.next().getObject().getData(); } versIter.close(); return version; }
public void testP() throws Exception { Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(null, uri, null, null, null); Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = ryaTripleContext.serializeTriple( new RyaStatement(uri, uri, uri, null)); TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO); assertContains(entry.getValue(), tripleRow.getRow()); }
public void testSp() throws Exception { Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = ryaTripleContext.serializeTriple( new RyaStatement(uri, uri, uri, null)); TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO); Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(uri, uri, null, null, null); assertContains(entry.getValue(), tripleRow.getRow()); entry = strategy.defineRange(uri, uri2, null, null, null); assertContainsFalse(entry.getValue(), tripleRow.getRow()); }
public void testPoRangeCustomType() throws Exception { Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = ryaTripleContext.serializeTriple( new RyaStatement(uri, uri, customType1, null)); TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO); Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(null, uri, customTypeRange1, null, null); assertContains(entry.getValue(), tripleRow.getRow()); entry = strategy.defineRange(null, uri, customTypeRange2, null, null); assertContainsFalse(entry.getValue(), tripleRow.getRow()); }
public void testSpoCustomType() throws Exception { Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = ryaTripleContext.serializeTriple( new RyaStatement(uri, uri, customType1, null)); TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO); Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(uri, uri, customType1, null, null); assertContains(entry.getValue(), tripleRow.getRow()); entry = strategy.defineRange(uri, uri, customType2, null, null); assertContainsFalse(entry.getValue(), tripleRow.getRow()); }
public void testSpRange() throws Exception { Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = ryaTripleContext.serializeTriple( new RyaStatement(uri, uri, uri, null)); TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO); Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(uri, rangeIRI, null, null, null); assertContains(entry.getValue(), tripleRow.getRow()); entry = strategy.defineRange(uri, rangeIRI2, null, null, null); assertContainsFalse(entry.getValue(), tripleRow.getRow()); }
public void testPoCustomType() throws Exception { Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = ryaTripleContext.serializeTriple( new RyaStatement(uri, uri, customType1, null)); TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO); Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(null, uri, customType1, null, null); assertContains(entry.getValue(), tripleRow.getRow()); entry = strategy.defineRange(null, uri, customType2, null, null); assertContainsFalse(entry.getValue(), tripleRow.getRow()); }
public void testPosRange() throws Exception { Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = ryaTripleContext.serializeTriple( new RyaStatement(uri, uri, uri, null)); TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO); Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(rangeIRI, uri, uri, null, null); assertContains(entry.getValue(), tripleRow.getRow()); entry = strategy.defineRange(rangeIRI2, uri, uri, null, null); assertContainsFalse(entry.getValue(), tripleRow.getRow()); }
public void testPoRange() throws Exception { Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = ryaTripleContext.serializeTriple( new RyaStatement(uri, uri, uri, null)); TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO); Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(null, uri, rangeIRI, null, null); assertContains(entry.getValue(), tripleRow.getRow()); entry = strategy.defineRange(null, uri, rangeIRI2, null, null); assertContainsFalse(entry.getValue(), tripleRow.getRow()); }
public static RyaStatement convertStatement(Statement statement) { if (statement == null) return null; Resource subject = statement.getSubject(); URI predicate = statement.getPredicate(); Value object = statement.getObject(); Resource context = statement.getContext(); return new RyaStatement( convertResource(subject), convertURI(predicate), convertValue(object), convertResource(context)); }
public void testHashedTripleRowSerialization() throws Exception { final RyaIRI subj = new RyaIRI("urn:test#subj"); final RyaIRI pred = new RyaIRI("urn:test#pred"); final RyaType obj = new RyaType("mydata"); final RyaStatement statement = new RyaStatement(subj, pred, obj); final MockRdfConfiguration config = new MockRdfConfiguration(); config.set(MockRdfConfiguration.CONF_PREFIX_ROW_WITH_HASH, Boolean.TRUE.toString()); final RyaTripleContext instance = RyaTripleContext.getInstance(config); final Map<TABLE_LAYOUT, TripleRow> map = instance.serializeTriple(statement); final TripleRow tripleRow = map.get(TABLE_LAYOUT.SPO); assertEquals(statement, instance.deserializeTriple(TABLE_LAYOUT.SPO, tripleRow)); }
public void testTripleRowSerialization() throws Exception { final RyaIRI subj = new RyaIRI("urn:test#subj"); final RyaIRI pred = new RyaIRI("urn:test#pred"); final RyaType obj = new RyaType("mydata"); final RyaStatement statement = new RyaStatement(subj, pred, obj); final RyaTripleContext instance = RyaTripleContext.getInstance(new MockRdfConfiguration()); final Map<TABLE_LAYOUT, TripleRow> map = instance.serializeTriple(statement); final TripleRow tripleRow = map.get(TABLE_LAYOUT.SPO); assertEquals(statement, instance.deserializeTriple(TABLE_LAYOUT.SPO, tripleRow)); }
@Test public void serializationTestWithLiteral() { RyaSubGraph bundle = new RyaSubGraph(UUID.randomUUID().toString()); bundle.addStatement(new RyaStatement(new RyaIRI("uri:123"), new RyaIRI("uri:234"), new RyaType(XMLSchema.INTEGER, "345"))); bundle.addStatement(new RyaStatement(new RyaIRI("uri:345"), new RyaIRI("uri:567"), new RyaType(XMLSchema.INTEGER, "789"))); byte[] bundleBytes = serializer.toBytes(bundle); RyaSubGraph deserializedBundle = serializer.fromBytes(bundleBytes); assertEquals(bundle, deserializedBundle); }