Search in sources :

Example 86 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.

the class IterativeJoinTest method testIterativeJoinMultiWayNone2.

@Test
public void testIterativeJoinMultiWayNone2() throws Exception {
    // add data
    RyaURI pred = new RyaURI(litdupsNS, "pred1");
    RyaType zero = new RyaType("0");
    RyaType one = new RyaType("1");
    RyaType two = new RyaType("2");
    RyaType three = new RyaType("3");
    RyaType four = new RyaType("4");
    RyaURI subj1 = new RyaURI(litdupsNS, "subj1");
    RyaURI subj2 = new RyaURI(litdupsNS, "subj2");
    RyaURI subj3 = new RyaURI(litdupsNS, "subj3");
    RyaURI subj4 = new RyaURI(litdupsNS, "subj4");
    dao.add(new RyaStatement(subj1, pred, one));
    dao.add(new RyaStatement(subj1, pred, four));
    dao.add(new RyaStatement(subj2, pred, zero));
    dao.add(new RyaStatement(subj2, pred, one));
    dao.add(new RyaStatement(subj2, pred, four));
    dao.add(new RyaStatement(subj3, pred, two));
    dao.add(new RyaStatement(subj3, pred, four));
    dao.add(new RyaStatement(subj4, pred, one));
    dao.add(new RyaStatement(subj4, pred, two));
    // 1 join
    IterativeJoin iterativeJoin = new IterativeJoin(dao.getQueryEngine());
    CloseableIteration<RyaURI, RyaDAOException> join = iterativeJoin.join(null, new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, one), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, two), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, three), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, four));
    assertFalse(join.hasNext());
    join.close();
}
Also used : RdfCloudTripleStoreUtils(org.apache.rya.api.RdfCloudTripleStoreUtils) RyaURI(org.apache.rya.api.domain.RyaURI) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) IterativeJoin(org.apache.rya.api.persist.query.join.IterativeJoin) RyaType(org.apache.rya.api.domain.RyaType) Test(org.junit.Test)

Example 87 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.

the class IterativeJoinTest method testIterativeJoinMultiWay.

@Test
public void testIterativeJoinMultiWay() throws Exception {
    // add data
    RyaURI pred = new RyaURI(litdupsNS, "pred1");
    RyaType zero = new RyaType("0");
    RyaType one = new RyaType("1");
    RyaType two = new RyaType("2");
    RyaType three = new RyaType("3");
    RyaType four = new RyaType("4");
    RyaURI subj1 = new RyaURI(litdupsNS, "subj1");
    RyaURI subj2 = new RyaURI(litdupsNS, "subj2");
    RyaURI subj3 = new RyaURI(litdupsNS, "subj3");
    RyaURI subj4 = new RyaURI(litdupsNS, "subj4");
    dao.add(new RyaStatement(subj1, pred, one));
    dao.add(new RyaStatement(subj1, pred, two));
    dao.add(new RyaStatement(subj1, pred, three));
    dao.add(new RyaStatement(subj1, pred, four));
    dao.add(new RyaStatement(subj2, pred, zero));
    dao.add(new RyaStatement(subj2, pred, one));
    dao.add(new RyaStatement(subj2, pred, two));
    dao.add(new RyaStatement(subj2, pred, three));
    dao.add(new RyaStatement(subj2, pred, four));
    dao.add(new RyaStatement(subj3, pred, one));
    dao.add(new RyaStatement(subj3, pred, two));
    dao.add(new RyaStatement(subj3, pred, four));
    dao.add(new RyaStatement(subj4, pred, one));
    dao.add(new RyaStatement(subj4, pred, two));
    dao.add(new RyaStatement(subj4, pred, three));
    dao.add(new RyaStatement(subj4, pred, four));
    // 1 join
    IterativeJoin iterativeJoin = new IterativeJoin(dao.getQueryEngine());
    CloseableIteration<RyaURI, RyaDAOException> join = iterativeJoin.join(null, new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, one), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, two), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, three), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, four));
    Set<RyaURI> uris = new HashSet<RyaURI>();
    while (join.hasNext()) {
        uris.add(join.next());
    }
    assertTrue(uris.contains(subj1));
    assertTrue(uris.contains(subj2));
    assertTrue(uris.contains(subj4));
    join.close();
}
Also used : RdfCloudTripleStoreUtils(org.apache.rya.api.RdfCloudTripleStoreUtils) RyaURI(org.apache.rya.api.domain.RyaURI) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) IterativeJoin(org.apache.rya.api.persist.query.join.IterativeJoin) RyaType(org.apache.rya.api.domain.RyaType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 88 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.

the class MergeToolMapper method setup.

@Override
protected void setup(final Context context) throws IOException, InterruptedException {
    super.setup(context);
    log.info("Setting up mapper");
    parentConfig = context.getConfiguration();
    childConfig = getChildConfig(parentConfig);
    startTimeString = parentConfig.get(MergeTool.START_TIME_PROP, null);
    if (startTimeString != null) {
        startTime = MergeTool.convertStartTimeStringToDate(startTimeString);
    }
    usesStartTime = startTime != null;
    useTimeSync = parentConfig.getBoolean(CopyTool.USE_NTP_SERVER_PROP, false);
    useMergeFileInput = parentConfig.getBoolean(MergeTool.USE_MERGE_FILE_INPUT, false);
    parentTableName = parentConfig.get(MergeTool.TABLE_NAME_PROP, null);
    parentTablePrefix = parentConfig.get(MRUtils.TABLE_PREFIX_PROPERTY, null);
    childTablePrefix = childConfig.get(MRUtils.TABLE_PREFIX_PROPERTY, null);
    if (useMergeFileInput) {
        childTableName = parentTableName.replaceFirst(parentTablePrefix, childTablePrefix) + MergeTool.TEMP_SUFFIX;
    } else {
        childTableName = parentTableName.replaceFirst(parentTablePrefix, childTablePrefix);
    }
    spoTable = new Text(parentTablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
    poTable = new Text(parentTablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
    ospTable = new Text(parentTablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
    childScanner = setupChildScanner(context);
    childIterator = childScanner.iterator();
    parentAccumuloRdfConfiguration = new AccumuloRdfConfiguration(parentConfig);
    parentAccumuloRdfConfiguration.setTablePrefix(parentTablePrefix);
    parentRyaContext = RyaTripleContext.getInstance(parentAccumuloRdfConfiguration);
    ryaTableMutationFactory = new RyaTableMutationsFactory(parentRyaContext);
    childAccumuloRdfConfiguration = new AccumuloRdfConfiguration(childConfig);
    childAccumuloRdfConfiguration.setTablePrefix(childTablePrefix);
    childRyaContext = RyaTripleContext.getInstance(childAccumuloRdfConfiguration);
    childConnector = AccumuloRyaUtils.setupConnector(childAccumuloRdfConfiguration);
    childDao = AccumuloRyaUtils.setupDao(childConnector, childAccumuloRdfConfiguration);
    if (startTime != null && useTimeSync) {
        try {
            copyToolInputTime = AccumuloRyaUtils.getCopyToolSplitDate(childDao);
            copyToolRunTime = AccumuloRyaUtils.getCopyToolRunDate(childDao);
            // Find the parent's time offset that was stored when the child was copied.
            parentTimeOffset = AccumuloRyaUtils.getTimeOffset(childDao);
            final String durationBreakdown = TimeUtils.getDurationBreakdown(parentTimeOffset);
            log.info("The table " + parentTableName + " has a time offset of: " + durationBreakdown);
            childTimeOffset = Long.valueOf(childConfig.get(CopyTool.CHILD_TIME_OFFSET_PROP, null));
            final Date adjustedParentStartTime = new Date(startTime.getTime() - parentTimeOffset);
            final Date adjustedChildStartTime = new Date(startTime.getTime() - childTimeOffset);
            log.info("Adjusted parent start time: " + adjustedParentStartTime);
            log.info("Adjusted child start time: " + adjustedChildStartTime);
        } catch (final RyaDAOException e) {
            log.error("Error getting time offset", e);
        }
    }
    log.info("Finished setting up mapper");
}
Also used : RyaTableMutationsFactory(org.apache.rya.accumulo.RyaTableMutationsFactory) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) Text(org.apache.hadoop.io.Text) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) Date(java.util.Date)

Example 89 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.

the class AccumuloRyaDAO method flush.

@Override
public void flush() throws RyaDAOException {
    try {
        mt_bw.flush();
        flushIndexers();
    } catch (final MutationsRejectedException e) {
        throw new RyaDAOException(e);
    }
}
Also used : RyaDAOException(org.apache.rya.api.persist.RyaDAOException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 90 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.

the class AccumuloRyaDAO method addNamespace.

@Override
public void addNamespace(final String pfx, final String namespace) throws RyaDAOException {
    try {
        final Mutation m = new Mutation(new Text(pfx));
        m.put(INFO_NAMESPACE_TXT, EMPTY_TEXT, new Value(namespace.getBytes(StandardCharsets.UTF_8)));
        bw_ns.addMutation(m);
        if (flushEachUpdate.get()) {
            mt_bw.flush();
        }
    } catch (final Exception e) {
        throw new RyaDAOException(e);
    }
}
Also used : Value(org.apache.accumulo.core.data.Value) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

Aggregations

RyaDAOException (org.apache.rya.api.persist.RyaDAOException)100 RyaStatement (org.apache.rya.api.domain.RyaStatement)61 RyaURI (org.apache.rya.api.domain.RyaURI)45 Test (org.junit.Test)39 RyaType (org.apache.rya.api.domain.RyaType)28 IOException (java.io.IOException)26 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)23 AccumuloException (org.apache.accumulo.core.client.AccumuloException)22 SailException (org.openrdf.sail.SailException)15 HashSet (java.util.HashSet)12 AccumuloRyaQueryEngine (org.apache.rya.accumulo.query.AccumuloRyaQueryEngine)12 RdfCloudTripleStoreUtils (org.apache.rya.api.RdfCloudTripleStoreUtils)12 Map (java.util.Map)11 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)11 RyaClientException (org.apache.rya.api.client.RyaClientException)11 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)10 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)10 ArrayList (java.util.ArrayList)9 Scanner (org.apache.accumulo.core.client.Scanner)8 Text (org.apache.hadoop.io.Text)8