/** * Insert a statement into the child Accumulo instance via the child DAO. * @param rstmt RyaStatement to add to the child * @param context Map context, not used * @throws IOException if the DAO encounters an error adding the statement to Accumulo */ @Override protected void copyStatement(final RyaStatement rstmt, final Context context) throws IOException { try { childDao.add(rstmt); } catch (final RyaDAOException e) { throw new IOException("Error inserting statement into child Rya DAO", e); } }
/** * Sets the copy tool split {@link Date} metadata key for the table. * @param date the tool copy split time {@link Date}. * @param dao the {@link AccumuloRyaDAO}. * @throws RyaDAOException */ public static RyaStatement setCopyToolSplitDate(final Date date, final AccumuloRyaDAO dao) throws RyaDAOException { final RyaStatement ryaStatement = createCopyToolSplitTimeRyaStatement(date); dao.add(ryaStatement); return ryaStatement; }
/** * Sets the copy tool run {@link Date} metadata key for the table. * @param date the copy tool run time {@link Date}. * @param dao the {@link AccumuloRyaDAO}. * @throws RyaDAOException */ public static RyaStatement setCopyToolRunDate(final Date date, final AccumuloRyaDAO dao) throws RyaDAOException { final RyaStatement ryaStatement = createCopyToolRunTimeRyaStatement(date); dao.add(ryaStatement); return ryaStatement; }
/** * Sets the copy tool parent time offset metadata key for the table. * @param timeOffset the difference between the parent machine's system time and * the NTP server's time. * @param dao the {@link AccumuloRyaDAO}. * @throws RyaDAOException */ public static RyaStatement setTimeOffset(final long timeOffset, final AccumuloRyaDAO dao) throws RyaDAOException { final RyaStatement ryaStatement = createTimeOffsetRyaStatement(timeOffset); dao.add(ryaStatement); return ryaStatement; } }
/** * Add a statement to an in-memory Accumulo instance, serialized as spo/pos/osp and any applicable secondary * indexes, and flush the in-memory rows through to the output if enough statements have been cached. * @param rstmt RyaStatement to copy to the child * @param context Context to use for writing * @throws InterruptedException if Hadoop is interrupted while writing output. * @throws IOException if an error is encountered serializing and storing the statement in memory, or * if Hadoop reports an error writing the in-memory tables to the output. */ @Override protected void copyStatement(final RyaStatement rstmt, final Context context) throws IOException, InterruptedException { try { childDao.add(rstmt); cachedStatements++; } catch (final RyaDAOException e) { throw new IOException("Error serializing RyaStatement", e); } if (cachedStatements >= maxStatements) { flush(context); } }
@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); } }
ryaIndexer.add(buffer.iterator());
ryaIndexer.add(buffer.iterator());
protected String loadRyaStatements(final String sparql, final Collection<RyaStatement> statements) throws Exception { requireNonNull(sparql); requireNonNull(statements); FluoClient client = null; try { CreateFluoPcj createPcj = new CreateFluoPcj(); client = new FluoClientImpl(super.getFluoConfiguration()); String id = createPcj.createPcj(sparql, client).getQueryId(); AccumuloRyaDAO dao = getRyaDAO(); dao.add(statements.iterator()); // Wait for the Fluo application to finish computing the end result. super.getMiniFluo().waitForObservers(); // FluoITHelper.printFluoTable(client); return id; } finally { if (client != null) { client.close(); } } }
static void setUpRya() throws AccumuloException, AccumuloSecurityException, RyaDAOException { MockInstance mock = new MockInstance(INSTANCE_NAME); Connector conn = mock.getConnector(USERNAME, new PasswordToken(USERP)); AccumuloRyaDAO dao = new AccumuloRyaDAO(); dao.setConnector(conn); AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); conf.setTablePrefix(PREFIX); dao.setConf(conf); dao.init(); String ns = "http://example.com/"; dao.add(new RyaStatement(new RyaIRI(ns+"s1"), new RyaIRI(ns+"p1"), new RyaIRI(ns+"o1"))); dao.add(new RyaStatement(new RyaIRI(ns+"s1"), new RyaIRI(ns+"p2"), new RyaIRI(ns+"o2"))); dao.add(new RyaStatement(new RyaIRI(ns+"s2"), new RyaIRI(ns+"p1"), new RyaIRI(ns+"o3"), new RyaIRI(ns+"g1"))); dao.add(new RyaStatement(new RyaIRI(ns+"s3"), new RyaIRI(ns+"p3"), new RyaIRI(ns+"o3"), new RyaIRI(ns+"g2"))); dao.destroy(); }
static void setUpRya() throws AccumuloException, AccumuloSecurityException, RyaDAOException { MockInstance mock = new MockInstance(INSTANCE_NAME); Connector conn = mock.getConnector(USERNAME, new PasswordToken(USERP)); AccumuloRyaDAO dao = new AccumuloRyaDAO(); dao.setConnector(conn); AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); conf.setTablePrefix(PREFIX); dao.setConf(conf); dao.init(); String ns = "http://example.com/"; dao.add(new RyaStatement(new RyaURI(ns+"s1"), new RyaURI(ns+"p1"), new RyaURI(ns+"o1"))); dao.add(new RyaStatement(new RyaURI(ns+"s1"), new RyaURI(ns+"p2"), new RyaURI(ns+"o2"))); dao.add(new RyaStatement(new RyaURI(ns+"s2"), new RyaURI(ns+"p1"), new RyaURI(ns+"o3"), new RyaURI(ns+"g1"))); dao.add(new RyaStatement(new RyaURI(ns+"s3"), new RyaURI(ns+"p3"), new RyaURI(ns+"o3"), new RyaURI(ns+"g2"))); dao.destroy(); }
makeRyaStatement(vf.createStatement(vf.createIRI("http://David"), vf.createIRI("http://worksAt"), vf.createIRI("http://Chipotle")), "V")); dao.add(historicTriples.iterator()); dao.flush();