You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by pu...@apache.org on 2016/04/06 22:47:56 UTC

[1/2] incubator-rya git commit: move delete mutation creation to RyaTableMutationsFactory so it can be reused (i.e. applications needing to migrate data within Rya)

Repository: incubator-rya
Updated Branches:
  refs/heads/develop d3323fac9 -> 1d92d1991


move delete mutation creation to RyaTableMutationsFactory so it can be reused (i.e. applications needing to migrate data within Rya)


Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/b6d271c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/b6d271c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/b6d271c6

Branch: refs/heads/develop
Commit: b6d271c6c85d45d0bc8993bcbf19503d299ba17a
Parents: 358c13b
Author: jej2003 <je...@gmail.com>
Authored: Thu Mar 17 17:08:39 2016 -0400
Committer: jej2003 <je...@gmail.com>
Committed: Thu Mar 17 17:08:39 2016 -0400

----------------------------------------------------------------------
 .../java/mvm/rya/accumulo/AccumuloRyaDAO.java   | 27 +++---------
 .../rya/accumulo/RyaTableMutationsFactory.java  | 46 ++++++++++++++++++++
 2 files changed, 52 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b6d271c6/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/AccumuloRyaDAO.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/AccumuloRyaDAO.java b/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/AccumuloRyaDAO.java
index e251fd3..b10c522 100644
--- a/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/AccumuloRyaDAO.java
+++ b/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/AccumuloRyaDAO.java
@@ -32,6 +32,7 @@ import static mvm.rya.api.RdfCloudTripleStoreConstants.RTS_SUBJECT_RYA;
 import static mvm.rya.api.RdfCloudTripleStoreConstants.RTS_VERSION_PREDICATE_RYA;
 import static mvm.rya.api.RdfCloudTripleStoreConstants.VERSION_RYA;
 
+import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -55,7 +56,6 @@ import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.io.Text;
@@ -255,26 +255,11 @@ public class AccumuloRyaDAO implements RyaDAO<AccumuloRdfConfiguration>, RyaName
 
     }
 
-    protected void deleteSingleRyaStatement(RyaStatement stmt) throws TripleRowResolverException, MutationsRejectedException {
-        Map<TABLE_LAYOUT, TripleRow> map = ryaContext.serializeTriple(stmt);
-        bw_spo.addMutation(deleteMutation(map.get(TABLE_LAYOUT.SPO)));
-        bw_po.addMutation(deleteMutation(map.get(TABLE_LAYOUT.PO)));
-        bw_osp.addMutation(deleteMutation(map.get(TABLE_LAYOUT.OSP)));
-
-    }
-
-    protected Mutation deleteMutation(TripleRow tripleRow) {
-        Mutation m = new Mutation(new Text(tripleRow.getRow()));
-
-        byte[] columnFamily = tripleRow.getColumnFamily();
-        Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);
-
-        byte[] columnQualifier = tripleRow.getColumnQualifier();
-        Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
-
-        m.putDelete(cfText, cqText, new ColumnVisibility(tripleRow.getColumnVisibility()),
-                    tripleRow.getTimestamp());
-        return m;
+    protected void deleteSingleRyaStatement(RyaStatement stmt) throws IOException, MutationsRejectedException {
+        Map<TABLE_LAYOUT, Collection<Mutation>> map = ryaTableMutationsFactory.serializeDelete(stmt);
+        bw_spo.addMutations(map.get(TABLE_LAYOUT.SPO));
+        bw_po.addMutations(map.get(TABLE_LAYOUT.PO));
+        bw_osp.addMutations(map.get(TABLE_LAYOUT.OSP));
     }
 
     protected void commit(Iterator<RyaStatement> commitStatements) throws RyaDAOException {

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b6d271c6/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/RyaTableMutationsFactory.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/RyaTableMutationsFactory.java b/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/RyaTableMutationsFactory.java
index 0dbafc1..2a4871d 100644
--- a/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/RyaTableMutationsFactory.java
+++ b/dao/accumulo.rya/src/main/java/mvm/rya/accumulo/RyaTableMutationsFactory.java
@@ -84,6 +84,52 @@ public class RyaTableMutationsFactory {
         return mutations;
     }
 
+    public Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, Collection<Mutation>> serializeDelete(
+            RyaStatement stmt) throws IOException {
+
+        Collection<Mutation> spo_muts = new ArrayList<Mutation>();
+        Collection<Mutation> po_muts = new ArrayList<Mutation>();
+        Collection<Mutation> osp_muts = new ArrayList<Mutation>();
+        /**
+         * TODO: If there are contexts, do we still replicate the information into the default graph as well
+         * as the named graphs?
+         */
+        try {
+            Map<TABLE_LAYOUT, TripleRow> rowMap = ryaContext.serializeTriple(stmt);
+            TripleRow tripleRow = rowMap.get(TABLE_LAYOUT.SPO);
+            spo_muts.add(deleteMutation(tripleRow));
+            tripleRow = rowMap.get(TABLE_LAYOUT.PO);
+            po_muts.add(deleteMutation(tripleRow));
+            tripleRow = rowMap.get(TABLE_LAYOUT.OSP);
+            osp_muts.add(deleteMutation(tripleRow));
+        } catch (TripleRowResolverException fe) {
+            throw new IOException(fe);
+        }
+
+        Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, Collection<Mutation>> mutations =
+                new HashMap<RdfCloudTripleStoreConstants.TABLE_LAYOUT, Collection<Mutation>>();
+        mutations.put(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO, spo_muts);
+        mutations.put(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO, po_muts);
+        mutations.put(RdfCloudTripleStoreConstants.TABLE_LAYOUT.OSP, osp_muts);
+
+        return mutations;
+
+    }
+
+    protected Mutation deleteMutation(TripleRow tripleRow) {
+        Mutation m = new Mutation(new Text(tripleRow.getRow()));
+
+        byte[] columnFamily = tripleRow.getColumnFamily();
+        Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);
+
+        byte[] columnQualifier = tripleRow.getColumnQualifier();
+        Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
+
+        m.putDelete(cfText, cqText, new ColumnVisibility(tripleRow.getColumnVisibility()),
+                tripleRow.getTimestamp());
+        return m;
+    }
+
     protected Mutation createMutation(TripleRow tripleRow) {
         Mutation mutation = new Mutation(new Text(tripleRow.getRow()));
         byte[] columnVisibility = tripleRow.getColumnVisibility();


[2/2] incubator-rya git commit: Merge branch 'delete_mutation_factory' of https://github.com/jej2003/incubator-rya into RYA-PR-30

Posted by pu...@apache.org.
Merge branch 'delete_mutation_factory' of https://github.com/jej2003/incubator-rya into RYA-PR-30


Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/1d92d199
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/1d92d199
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/1d92d199

Branch: refs/heads/develop
Commit: 1d92d1991f3989e07ed9c840fd99b4f2a0e0cbb0
Parents: d3323fa b6d271c
Author: pujav65 <pu...@gmail.com>
Authored: Wed Apr 6 16:32:33 2016 -0400
Committer: pujav65 <pu...@gmail.com>
Committed: Wed Apr 6 16:32:33 2016 -0400

----------------------------------------------------------------------
 .../java/mvm/rya/accumulo/AccumuloRyaDAO.java   | 27 +++---------
 .../rya/accumulo/RyaTableMutationsFactory.java  | 46 ++++++++++++++++++++
 2 files changed, 52 insertions(+), 21 deletions(-)
----------------------------------------------------------------------