You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by mi...@apache.org on 2016/08/26 00:06:30 UTC
[09/52] [abbrv] incubator-rya git commit: Consolidated MapReduce API
and applications into toplevel project.
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/42895eac/mapreduce/src/test/java/mvm/rya/accumulo/mr/TestUtils.java
----------------------------------------------------------------------
diff --git a/mapreduce/src/test/java/mvm/rya/accumulo/mr/TestUtils.java b/mapreduce/src/test/java/mvm/rya/accumulo/mr/TestUtils.java
new file mode 100644
index 0000000..3bb35d9
--- /dev/null
+++ b/mapreduce/src/test/java/mvm/rya/accumulo/mr/TestUtils.java
@@ -0,0 +1,113 @@
+package mvm.rya.accumulo.mr;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.accumulo.core.client.Connector;
+import org.calrissian.mango.collect.CloseableIterable;
+import org.junit.Assert;
+
+import mvm.rya.accumulo.AccumuloRdfConfiguration;
+import mvm.rya.accumulo.AccumuloRyaDAO;
+import mvm.rya.accumulo.query.AccumuloRyaQueryEngine;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.persist.RyaDAOException;
+import mvm.rya.api.persist.query.RyaQuery;
+
+public class TestUtils {
+ public static void verify(Connector connector, AccumuloRdfConfiguration conf, RyaStatement... ryaStatements)
+ throws RyaDAOException, IOException {
+ AccumuloRyaDAO dao = new AccumuloRyaDAO();
+ dao.setConnector(connector);
+ dao.setConf(conf);
+ dao.init();
+ AccumuloRyaQueryEngine engine = dao.getQueryEngine();
+ for (RyaStatement ryaStatement : ryaStatements) {
+ verify(ryaStatement, engine);
+ }
+ dao.destroy();
+ }
+
+ public static RyaStatement verify(RyaStatement ryaStatement, AccumuloRyaQueryEngine queryEngine)
+ throws RyaDAOException, IOException {
+ //check osp
+ CloseableIterable<RyaStatement> statements =
+ queryEngine.query(RyaQuery.builder(new RyaStatement(null, null, ryaStatement.getObject()))
+ .build());
+ try {
+ verifyFirstStatement(ryaStatement, statements);
+ } finally {
+ statements.close();
+ }
+
+ //check po
+ statements = queryEngine.query(RyaQuery.builder(
+ new RyaStatement(null, ryaStatement.getPredicate(),
+ ryaStatement.getObject())).build());
+ try {
+ verifyFirstStatement(ryaStatement, statements);
+ } finally {
+ statements.close();
+ }
+
+ //check spo
+ RyaStatement result;
+ statements = queryEngine.query(RyaQuery.builder(
+ new RyaStatement(ryaStatement.getSubject(),
+ ryaStatement.getPredicate(),
+ ryaStatement.getObject())).build());
+ try {
+ result = verifyFirstStatement(ryaStatement, statements);
+ } finally {
+ statements.close();
+ }
+ return result;
+ }
+
+ private static RyaStatement verifyFirstStatement(
+ RyaStatement ryaStatement, CloseableIterable<RyaStatement> statements) {
+ final Iterator<RyaStatement> iterator = statements.iterator();
+ Assert.assertTrue(iterator.hasNext());
+ final RyaStatement first = iterator.next();
+ Assert.assertEquals(ryaStatement.getSubject(), first.getSubject());
+ Assert.assertEquals(ryaStatement.getPredicate(), first.getPredicate());
+ Assert.assertEquals(ryaStatement.getObject(), first.getObject());
+ Assert.assertEquals(ryaStatement.getContext(), first.getContext());
+ Assert.assertEquals(ryaStatement.getQualifer(), first.getQualifer());
+ // Test for equality if provided, otherwise test that these are empty
+ if (ryaStatement.getColumnVisibility() == null) {
+ Assert.assertEquals("Expected empty visibility.", 0, first.getColumnVisibility().length);
+ }
+ else {
+ Assert.assertArrayEquals("Mismatched visibilities.",
+ ryaStatement.getColumnVisibility(), first.getColumnVisibility());
+ }
+ if (ryaStatement.getValue() == null) {
+ Assert.assertEquals("Expected empty value array.", 0, first.getValue().length);
+ }
+ else {
+ Assert.assertArrayEquals("Mismatched values.", ryaStatement.getValue(), first.getValue());
+ }
+ Assert.assertFalse(iterator.hasNext());
+ return first;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/42895eac/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/AccumuloRdfCountToolTest.java
----------------------------------------------------------------------
diff --git a/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/AccumuloRdfCountToolTest.java b/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/AccumuloRdfCountToolTest.java
new file mode 100644
index 0000000..837457a
--- /dev/null
+++ b/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/AccumuloRdfCountToolTest.java
@@ -0,0 +1,283 @@
+package mvm.rya.accumulo.mr.tools;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import mvm.rya.accumulo.AccumuloRdfConfiguration;
+import mvm.rya.accumulo.AccumuloRyaDAO;
+import mvm.rya.accumulo.mr.tools.AccumuloRdfCountTool;
+import mvm.rya.api.RdfCloudTripleStoreConstants;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaURI;
+import mvm.rya.api.resolver.RdfToRyaConversions;
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.admin.SecurityOperations;
+import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.PartialKey;
+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.TablePermission;
+import org.apache.hadoop.io.Text;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Created by IntelliJ IDEA.
+ * Date: 4/24/12
+ * Time: 5:05 PM
+ * To change this template use File | Settings | File Templates.
+ */
+//@Ignore
+public class AccumuloRdfCountToolTest {
+
+ private String user = "user";
+ private String pwd = "pwd";
+ private String instance = AccumuloRdfCountToolTest.class.getSimpleName() + ".myinstance";
+ private String tablePrefix = "t_";
+ private Authorizations auths = Constants.NO_AUTHS;
+ private Connector connector;
+
+ private AccumuloRyaDAO dao;
+ private ValueFactory vf = new ValueFactoryImpl();
+ private AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
+ static String litdupsNS = "urn:test:litdups#";
+
+ @Before
+ public void setUp() throws Exception {
+ connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
+ SecurityOperations secOps = connector.securityOperations();
+ secOps.createUser(user, pwd.getBytes(), auths);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.WRITE);
+
+ dao = new AccumuloRyaDAO();
+ dao.setConnector(connector);
+ conf.setTablePrefix(tablePrefix);
+ dao.setConf(conf);
+ dao.init();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ dao.destroy();
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
+ }
+
+ @Test
+ public void testMR() throws Exception {
+ RyaURI test1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "test1"));
+ RyaURI pred1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "pred1"));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(0))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(1))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(2))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(3))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(4))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(5))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(6))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(7))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(8))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(9))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(10))));
+
+ AccumuloRdfCountTool.main(new String[]{
+ "-Dac.mock=true",
+ "-Dac.instance=" + instance,
+ "-Dac.username=" + user,
+ "-Dac.pwd=" + pwd,
+ "-Drdf.tablePrefix=" + tablePrefix,
+ });
+
+ Map<String, Key> expectedValues = new HashMap<String, Key>();
+ String row = test1.getData();
+ expectedValues.put(row,
+ new Key(new Text(row),
+ RdfCloudTripleStoreConstants.SUBJECT_CF_TXT,
+ RdfCloudTripleStoreConstants.EMPTY_TEXT));
+ row = pred1.getData();
+ expectedValues.put(row,
+ new Key(new Text(row),
+ RdfCloudTripleStoreConstants.PRED_CF_TXT,
+ RdfCloudTripleStoreConstants.EMPTY_TEXT));
+ Scanner scanner = connector.createScanner(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, auths);
+ scanner.setRange(new Range());
+ int count = 0;
+ for (Map.Entry<Key, Value> entry : scanner) {
+ assertTrue(expectedValues.get(entry.getKey().getRow().toString()).equals(entry.getKey(), PartialKey.ROW_COLFAM_COLQUAL));
+ assertEquals(11, Long.parseLong(entry.getValue().toString()));
+ count++;
+ }
+ assertEquals(2, count);
+ }
+
+// public void testMRObject() throws Exception {
+// URI pred1 = vf.createURI(litdupsNS, "pred1");
+// Literal literal = vf.createLiteral(0);
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test0"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test1"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test2"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test3"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test4"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test5"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test6"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test7"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test8"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test9"), pred1, literal));
+// dao.add(new StatementImpl(vf.createURI(litdupsNS, "test10"), pred1, literal));
+// dao.commit();
+//
+// AccumuloRdfCountTool.main(new String[]{
+// "-Dac.mock=true",
+// "-Dac.instance=" + instance,
+// "-Dac.username=" + user,
+// "-Dac.pwd=" + pwd,
+// "-Drdf.tablePrefix=" + tablePrefix,
+// });
+//
+// Map<String, Key> expectedValues = new HashMap<String, Key>();
+// byte[] row_bytes = RdfCloudTripleStoreUtils.writeValue(literal);
+// expectedValues.put(new String(row_bytes),
+// new Key(new Text(row_bytes),
+// RdfCloudTripleStoreConstants.OBJ_CF_TXT,
+// RdfCloudTripleStoreConstants.INFO_TXT));
+// row_bytes = RdfCloudTripleStoreUtils.writeValue(pred1);
+// expectedValues.put(new String(row_bytes),
+// new Key(new Text(row_bytes),
+// RdfCloudTripleStoreConstants.PRED_CF_TXT,
+// RdfCloudTripleStoreConstants.INFO_TXT));
+// Scanner scanner = connector.createScanner(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, auths);
+// scanner.setRange(new Range());
+// int count = 0;
+// for (Map.Entry<Key, Value> entry : scanner) {
+// assertTrue(expectedValues.get(entry.getKey().getRow().toString()).equals(entry.getKey(), PartialKey.ROW_COLFAM_COLQUAL));
+// assertEquals(11, Long.parseLong(entry.getValue().toString()));
+// count++;
+// }
+// assertEquals(2, count);
+// }
+
+ @Test
+ public void testTTL() throws Exception {
+ RyaURI test1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "test1"));
+ RyaURI pred1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "pred1"));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(0))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(1))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(2))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(3))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(4))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(5))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(6))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(7))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(8))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(9))));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(10))));
+
+ AccumuloRdfCountTool.main(new String[]{
+ "-Dac.mock=true",
+ "-Dac.instance=" + instance,
+ "-Dac.username=" + user,
+ "-Dac.pwd=" + pwd,
+ "-Dac.ttl=0",
+ "-Drdf.tablePrefix=" + tablePrefix,
+ });
+
+ Scanner scanner = connector.createScanner(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, auths);
+ scanner.setRange(new Range());
+ int count = 0;
+ for (Map.Entry<Key, Value> entry : scanner) {
+ count++;
+ }
+ assertEquals(0, count);
+ }
+
+ @Test
+ public void testContext() throws Exception {
+ RyaURI test1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "test1"));
+ RyaURI pred1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "pred1"));
+ RyaURI cntxt = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "cntxt"));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(0)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(1)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(2)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(3)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(4)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(5)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(6)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(7)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(8)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(9)), cntxt));
+ dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(vf.createLiteral(10)), cntxt));
+
+ AccumuloRdfCountTool.main(new String[]{
+ "-Dac.mock=true",
+ "-Dac.instance=" + instance,
+ "-Dac.username=" + user,
+ "-Dac.pwd=" + pwd,
+ "-Drdf.tablePrefix=" + tablePrefix,
+ });
+
+ Map<String, Key> expectedValues = new HashMap<String, Key>();
+ String row = test1.getData();
+ expectedValues.put(row,
+ new Key(new Text(row),
+ RdfCloudTripleStoreConstants.SUBJECT_CF_TXT,
+ new Text(cntxt.getData())));
+ row = pred1.getData();
+ expectedValues.put(row,
+ new Key(new Text(row),
+ RdfCloudTripleStoreConstants.PRED_CF_TXT,
+ new Text(cntxt.getData())));
+ Scanner scanner = connector.createScanner(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, auths);
+ scanner.setRange(new Range());
+ int count = 0;
+ for (Map.Entry<Key, Value> entry : scanner) {
+ assertTrue(expectedValues.get(entry.getKey().getRow().toString()).equals(entry.getKey(), PartialKey.ROW_COLFAM_COLQUAL));
+ assertEquals(11, Long.parseLong(entry.getValue().toString()));
+ count++;
+ }
+ assertEquals(2, count);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/42895eac/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/RdfFileInputToolTest.java
----------------------------------------------------------------------
diff --git a/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/RdfFileInputToolTest.java b/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/RdfFileInputToolTest.java
new file mode 100644
index 0000000..13c7d6d
--- /dev/null
+++ b/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/RdfFileInputToolTest.java
@@ -0,0 +1,131 @@
+package mvm.rya.accumulo.mr.tools;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.admin.SecurityOperations;
+import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.TablePermission;
+import org.junit.Test;
+import org.openrdf.rio.RDFFormat;
+
+import junit.framework.TestCase;
+import mvm.rya.accumulo.AccumuloRdfConfiguration;
+import mvm.rya.accumulo.mr.TestUtils;
+import mvm.rya.accumulo.mr.tools.RdfFileInputTool;
+import mvm.rya.api.RdfCloudTripleStoreConstants;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaType;
+import mvm.rya.api.domain.RyaURI;
+
+/**
+ * Created by IntelliJ IDEA.
+ * Date: 4/25/12
+ * Time: 10:51 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class RdfFileInputToolTest extends TestCase {
+
+ private String user = "user";
+ private String pwd = "pwd";
+ private String instance = RdfFileInputToolTest.class.getSimpleName() + ".myinstance";
+ private String tablePrefix = "t_";
+ private Authorizations auths = new Authorizations("test_auths");
+ private Connector connector;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ connector = new MockInstance(instance).getConnector(user, new PasswordToken(pwd));
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
+ SecurityOperations secOps = connector.securityOperations();
+ secOps.createLocalUser(user, new PasswordToken(pwd));
+ secOps.changeUserAuthorizations(user, auths);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.WRITE);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
+ }
+
+ @Test
+ public void testNTriplesInput() throws Exception {
+ RdfFileInputTool.main(new String[]{
+ "-Dac.mock=true",
+ "-Dac.instance=" + instance,
+ "-Dac.username=" + user,
+ "-Dac.pwd=" + pwd,
+ "-Dac.auth=" + auths.toString(),
+ "-Dac.cv=" + auths.toString(),
+ "-Drdf.tablePrefix=" + tablePrefix,
+ "-Drdf.format=" + RDFFormat.NTRIPLES.getName(),
+ "src/test/resources/test.ntriples",
+ });
+ RyaStatement rs = new RyaStatement(new RyaURI("urn:lubm:rdfts#GraduateStudent01"),
+ new RyaURI("urn:lubm:rdfts#hasFriend"),
+ new RyaURI("urn:lubm:rdfts#GraduateStudent02"));
+ rs.setColumnVisibility(auths.toString().getBytes());
+ AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
+ conf.setTablePrefix(tablePrefix);
+ conf.setAuths(auths.toString());
+ TestUtils.verify(connector, conf, rs);
+ }
+
+ @Test
+ public void testInputContext() throws Exception {
+ RdfFileInputTool.main(new String[]{
+ "-Dac.mock=true",
+ "-Dac.instance=" + instance,
+ "-Dac.username=" + user,
+ "-Dac.pwd=" + pwd,
+ "-Dac.auth=" + auths.toString(),
+ "-Dac.cv=" + auths.toString(),
+ "-Drdf.tablePrefix=" + tablePrefix,
+ "-Drdf.format=" + RDFFormat.TRIG.getName(),
+ "src/test/resources/namedgraphs.trig",
+ });
+ RyaStatement rs = new RyaStatement(new RyaURI("http://www.example.org/exampleDocument#Monica"),
+ new RyaURI("http://www.example.org/vocabulary#name"),
+ new RyaType("Monica Murphy"),
+ new RyaURI("http://www.example.org/exampleDocument#G1"));
+ rs.setColumnVisibility(auths.toString().getBytes());
+ AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
+ conf.setTablePrefix(tablePrefix);
+ conf.setAuths(auths.toString());
+ TestUtils.verify(connector, conf, rs);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/42895eac/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/Upgrade322ToolTest.java
----------------------------------------------------------------------
diff --git a/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/Upgrade322ToolTest.java b/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/Upgrade322ToolTest.java
new file mode 100644
index 0000000..a6b22e9
--- /dev/null
+++ b/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/Upgrade322ToolTest.java
@@ -0,0 +1,275 @@
+package mvm.rya.accumulo.mr.tools;
+
+import java.util.Map;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.admin.SecurityOperations;
+import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.data.Key;
+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.TablePermission;
+import org.openrdf.model.vocabulary.XMLSchema;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import junit.framework.TestCase;
+import mvm.rya.accumulo.AccumuloRdfConfiguration;
+import mvm.rya.accumulo.AccumuloRyaDAO;
+import mvm.rya.accumulo.mr.TestUtils;
+import mvm.rya.accumulo.mr.tools.Upgrade322Tool;
+import mvm.rya.accumulo.query.AccumuloRyaQueryEngine;
+import mvm.rya.api.RdfCloudTripleStoreConstants;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaType;
+import mvm.rya.api.domain.RyaURI;
+
+/**
+ * Created by IntelliJ IDEA.
+ * Date: 4/25/12
+ * Time: 10:51 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Upgrade322ToolTest extends TestCase {
+
+ private String user = "user";
+ private String pwd = "pwd";
+ private String instance = Upgrade322ToolTest.class.getSimpleName() + ".myinstance";
+ private String tablePrefix = "t_";
+ private Authorizations auths = Constants.NO_AUTHS;
+ private Connector connector;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ final String spoTable = tablePrefix +
+ RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX;
+ final String poTable = tablePrefix +
+ RdfCloudTripleStoreConstants.TBL_PO_SUFFIX;
+ final String ospTable = tablePrefix +
+ RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX;
+
+ connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
+
+ connector.tableOperations().create(spoTable);
+ connector.tableOperations().create(poTable);
+ connector.tableOperations().create(ospTable);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
+ connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
+ SecurityOperations secOps = connector.securityOperations();
+ secOps.createUser(user, pwd.getBytes(), auths);
+ secOps.grantTablePermission(user, spoTable, TablePermission.READ);
+ secOps.grantTablePermission(user, poTable, TablePermission.READ);
+ secOps.grantTablePermission(user, ospTable, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.READ);
+ secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.WRITE);
+
+ //load data
+ final BatchWriter ospWriter = connector
+ .createBatchWriter(ospTable, new BatchWriterConfig());
+ ospWriter.addMutation(getMutation("00000000000000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0000http://here/2010/tracked-data-provenance/ns#longLit\u0001\u0004"));
+ ospWriter.addMutation(getMutation("00000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#intLit\u0001\u0005"));
+ ospWriter.addMutation(getMutation("00000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#byteLit\u0001\t"));
+ ospWriter.addMutation(getMutation("00001 1.0\u0000http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#doubleLit\u0001\u0006"));
+ ospWriter.addMutation(getMutation("10\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0000http" +
+ "://here/2010/tracked-data-provenance/ns#shortLit\u0001http://www.w3" +
+ ".org/2001/XMLSchema#short\u0001\b"));
+ ospWriter.addMutation(getMutation("10.0\u0000http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#floatLit\u0001http" +
+ "://www.w3.org/2001/XMLSchema#float\u0001\b"));
+ ospWriter.addMutation(getMutation("3.0.0\u0000urn:mvm.rya/2012/05#rts\u0000urn:mvm" +
+ ".rya/2012/05#version\u0001\u0003"));
+ ospWriter.addMutation(getMutation("9223370726404375807\u0000http://here/2010/tracked-data-provenance/ns" +
+ "#uuid10\u0000http://here/2010/tracked-data-provenance/ns#dateLit" +
+ "\u0001\u0007"));
+ ospWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#Created\u0000http://here" +
+ "/2010/tracked-data-provenance/ns#uuid10\u0000http://www.w3" +
+ ".org/1999/02/22-rdf-syntax-ns#type\u0001\u0002"));
+ ospWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#objectuuid1\u0000http" +
+ "://here/2010/tracked-data-provenance/ns#uuid10\u0000http://here/2010" +
+ "/tracked-data-provenance/ns#uriLit\u0001\u0002"));
+ ospWriter.addMutation(getMutation("stringLit\u0000http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#stringLit\u0001" +
+ "\u0003"));
+ ospWriter.addMutation(getMutation("true\u0000http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#booleanLit\u0001\n"));
+ ospWriter.flush();
+ ospWriter.close();
+
+ final BatchWriter spoWriter = connector
+ .createBatchWriter(spoTable, new BatchWriterConfig());
+ spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10\u0000http://here/2010/tracked-data-provenance/ns#longLit\u000000000000000000000010\u0001\u0004"));
+ spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#intLit\u000000000000010\u0001\u0005"));
+ spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#byteLit\u000000000010\u0001\t"));
+ spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#doubleLit\u000000001 1.0\u0001\u0006"));
+ spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10\u0000http" +
+ "://here/2010/tracked-data-provenance/ns#shortLit\u000010\u0001http://www.w3" +
+ ".org/2001/XMLSchema#short\u0001\b"));
+ spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#floatLit\u0001http" +
+ "://www.w3.org/2001/XMLSchema#float\u000010.0\u0001\b"));
+ spoWriter.addMutation(getMutation("urn:mvm.rya/2012/05#rts\u0000urn:mvm" +
+ ".rya/2012/05#version\u00003.0.0\u0001\u0003"));
+ spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns" +
+ "#uuid10\u0000http://here/2010/tracked-data-provenance/ns#dateLit" +
+ "\u00009223370726404375807\u0001\u0007"));
+ spoWriter.addMutation(getMutation("http://here" +
+ "/2010/tracked-data-provenance/ns#uuid10\u0000http://www.w3" +
+ ".org/1999/02/22-rdf-syntax-ns#type\u0000http://here/2010/tracked-data-provenance/ns#Created\u0001\u0002"));
+ spoWriter.addMutation(getMutation("http" +
+ "://here/2010/tracked-data-provenance/ns#uuid10\u0000http://here/2010" +
+ "/tracked-data-provenance/ns#uriLit\u0000http://here/2010/tracked-data-provenance/ns#objectuuid1\u0001\u0002"));
+ spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#stringLit\u0000stringLit\u0001" +
+ "\u0003"));
+ spoWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#uuid10" +
+ "\u0000http://here/2010/tracked-data-provenance/ns#booleanLit\u0000true\u0001\n"));
+ spoWriter.flush();
+ spoWriter.close();
+
+ final BatchWriter poWriter = connector
+ .createBatchWriter(poTable, new BatchWriterConfig());
+ poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#longLit\u000000000000000000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0004"));
+ poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#intLit\u000000000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0005"));
+ poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#byteLit\u000000000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\t"));
+ poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#doubleLit\u000000001 1.0\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0006"));
+ poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#shortLit\u000010\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001http://www.w3" +
+ ".org/2001/XMLSchema#short\u0001\b"));
+ poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#floatLit\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001http" +
+ "://www.w3.org/2001/XMLSchema#float\u000010.0\u0001\b"));
+ poWriter.addMutation(getMutation("urn:mvm" +
+ ".rya/2012/05#version\u00003.0.0\u0000urn:mvm.rya/2012/05#rts\u0001\u0003"));
+ poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#dateLit" +
+ "\u00009223370726404375807\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0007"));
+ poWriter.addMutation(getMutation("http://www.w3" +
+ ".org/1999/02/22-rdf-syntax-ns#type\u0000http://here/2010/tracked-data-provenance/ns#Created\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0002"));
+ poWriter.addMutation(getMutation("http://here/2010" +
+ "/tracked-data-provenance/ns#uriLit\u0000http://here/2010/tracked-data-provenance/ns#objectuuid1\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\u0002"));
+ poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#stringLit\u0000stringLit\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001" +
+ "\u0003"));
+ poWriter.addMutation(getMutation("http://here/2010/tracked-data-provenance/ns#booleanLit\u0000true\u0000http://here/2010/tracked-data-provenance/ns#uuid10\u0001\n"));
+ poWriter.flush();
+ poWriter.close();
+ }
+
+ public Mutation getMutation(String row) {
+ final Mutation mutation = new Mutation(row);
+ mutation.put("", "", "");
+ return mutation;
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
+ connector.tableOperations().delete(
+ tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
+ connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
+ connector.tableOperations().delete(
+ tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
+ }
+
+ public void testUpgrade() throws Exception {
+ Upgrade322Tool.main(new String[]{
+ "-Dac.mock=true",
+ "-Dac.instance=" + instance,
+ "-Dac.username=" + user,
+ "-Dac.pwd=" + pwd,
+ "-Drdf.tablePrefix=" + tablePrefix,
+ });
+
+ final AccumuloRdfConfiguration configuration = new AccumuloRdfConfiguration();
+ configuration.setTablePrefix(tablePrefix);
+ final AccumuloRyaDAO ryaDAO = new AccumuloRyaDAO();
+ ryaDAO.setConnector(connector);
+ ryaDAO.setConf(configuration);
+ ryaDAO.init();
+
+ final AccumuloRyaQueryEngine queryEngine = ryaDAO.getQueryEngine();
+
+ TestUtils.verify(new RyaStatement(
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"),
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#booleanLit"),
+ new RyaType(XMLSchema.BOOLEAN, "true")), queryEngine);
+ TestUtils.verify(new RyaStatement(
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"),
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#longLit"),
+ new RyaType(XMLSchema.LONG, "10")), queryEngine);
+ TestUtils.verify(new RyaStatement(
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"),
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#intLit"),
+ new RyaType(XMLSchema.INTEGER, "10")), queryEngine);
+ TestUtils.verify(new RyaStatement(
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"),
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#byteLit"),
+ new RyaType(XMLSchema.BYTE, "10")), queryEngine);
+ TestUtils.verify(new RyaStatement(
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"),
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#doubleLit"),
+ new RyaType(XMLSchema.DOUBLE, "10.0")), queryEngine);
+ TestUtils.verify(new RyaStatement(
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"),
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#dateLit"),
+ new RyaType(XMLSchema.DATETIME, "2011-07-12T06:00:00.000Z")), queryEngine);
+ TestUtils.verify(new RyaStatement(
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"),
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#stringLit"),
+ new RyaType("stringLit")), queryEngine);
+ TestUtils.verify(new RyaStatement(
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"),
+ new RyaURI("http://here/2010/tracked-data-provenance/ns#uriLit"),
+ new RyaURI("http://here/2010/tracked-data-provenance/ns" +
+ "#objectuuid1")), queryEngine);
+ TestUtils.verify(new RyaStatement(
+ new RyaURI("urn:mvm.rya/2012/05#rts"),
+ new RyaURI("urn:mvm.rya/2012/05#version"),
+ new RyaType("3.0.0")), queryEngine);
+ }
+
+ public void printTableData(String tableName)
+ throws TableNotFoundException{
+ Scanner scanner = connector.createScanner(tableName, auths);
+ scanner.setRange(new Range());
+ for(Map.Entry<Key, Value> entry : scanner) {
+ final Key key = entry.getKey();
+ final Value value = entry.getValue();
+ System.out.println(key.getRow() + " " + key.getColumnFamily() + " " + key.getColumnQualifier() + " " + key.getTimestamp() + " " + value.toString());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/42895eac/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/UpgradeObjectSerializationTest.java
----------------------------------------------------------------------
diff --git a/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/UpgradeObjectSerializationTest.java b/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/UpgradeObjectSerializationTest.java
new file mode 100644
index 0000000..e5fd293
--- /dev/null
+++ b/mapreduce/src/test/java/mvm/rya/accumulo/mr/tools/UpgradeObjectSerializationTest.java
@@ -0,0 +1,119 @@
+package mvm.rya.accumulo.mr.tools;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import mvm.rya.api.resolver.impl.*;
+import org.junit.Test;
+
+import static mvm.rya.accumulo.mr.tools.Upgrade322Tool.UpgradeObjectSerialization;
+import static org.junit.Assert.*;
+
+public class UpgradeObjectSerializationTest {
+
+ @Test
+ public void testBooleanUpgrade() throws Exception {
+ String object = "true";
+ final UpgradeObjectSerialization upgradeObjectSerialization
+ = new UpgradeObjectSerialization();
+ final String upgrade = upgradeObjectSerialization
+ .upgrade(object, BooleanRyaTypeResolver.BOOLEAN_LITERAL_MARKER);
+
+ assertEquals("1", upgrade);
+ }
+
+ @Test
+ public void testBooleanUpgradeFalse() throws Exception {
+ String object = "false";
+ final UpgradeObjectSerialization upgradeObjectSerialization
+ = new UpgradeObjectSerialization();
+ final String upgrade = upgradeObjectSerialization
+ .upgrade(object, BooleanRyaTypeResolver.BOOLEAN_LITERAL_MARKER);
+
+ assertEquals("0", upgrade);
+ }
+
+ @Test
+ public void testByteUpgradeLowest() throws Exception {
+ String object = "-127";
+ final UpgradeObjectSerialization upgradeObjectSerialization
+ = new UpgradeObjectSerialization();
+ final String upgrade = upgradeObjectSerialization
+ .upgrade(object, ByteRyaTypeResolver.LITERAL_MARKER);
+
+ assertEquals("81", upgrade);
+ }
+
+ @Test
+ public void testByteUpgradeHighest() throws Exception {
+ String object = "127";
+ final UpgradeObjectSerialization upgradeObjectSerialization
+ = new UpgradeObjectSerialization();
+ final String upgrade = upgradeObjectSerialization
+ .upgrade(object, ByteRyaTypeResolver.LITERAL_MARKER);
+
+ assertEquals("7f", upgrade);
+ }
+
+ @Test
+ public void testLongUpgrade() throws Exception {
+ String object = "00000000000000000010";
+ final UpgradeObjectSerialization upgradeObjectSerialization
+ = new UpgradeObjectSerialization();
+ final String upgrade = upgradeObjectSerialization
+ .upgrade(object, LongRyaTypeResolver.LONG_LITERAL_MARKER);
+
+ assertEquals("800000000000000a", upgrade);
+ }
+
+ @Test
+ public void testIntUpgrade() throws Exception {
+ String object = "00000000010";
+ final UpgradeObjectSerialization upgradeObjectSerialization
+ = new UpgradeObjectSerialization();
+ final String upgrade = upgradeObjectSerialization
+ .upgrade(object, IntegerRyaTypeResolver.INTEGER_LITERAL_MARKER);
+
+ assertEquals("8000000a", upgrade);
+ }
+
+ @Test
+ public void testDateTimeUpgrade() throws Exception {
+ String object = "9223370726404375807";
+ final UpgradeObjectSerialization upgradeObjectSerialization
+ = new UpgradeObjectSerialization();
+ final String upgrade = upgradeObjectSerialization
+ .upgrade(object, DateTimeRyaTypeResolver.DATETIME_LITERAL_MARKER);
+
+ assertEquals("800001311cee3b00", upgrade);
+ }
+
+ @Test
+ public void testDoubleUpgrade() throws Exception {
+ String object = "00001 1.0";
+ final UpgradeObjectSerialization upgradeObjectSerialization
+ = new UpgradeObjectSerialization();
+ final String upgrade = upgradeObjectSerialization
+ .upgrade(object, DoubleRyaTypeResolver.DOUBLE_LITERAL_MARKER);
+
+ assertEquals("c024000000000000", upgrade);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/42895eac/mapreduce/src/test/resources/namedgraphs.trig
----------------------------------------------------------------------
diff --git a/mapreduce/src/test/resources/namedgraphs.trig b/mapreduce/src/test/resources/namedgraphs.trig
new file mode 100644
index 0000000..b647632
--- /dev/null
+++ b/mapreduce/src/test/resources/namedgraphs.trig
@@ -0,0 +1,7 @@
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+@prefix swp: <http://www.w3.org/2004/03/trix/swp-1/> .
+@prefix dc: <http://purl.org/dc/elements/1.1/> .
+@prefix ex: <http://www.example.org/vocabulary#> .
+@prefix : <http://www.example.org/exampleDocument#> .
+:G1 { :Monica ex:name "Monica Murphy" . }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/42895eac/mapreduce/src/test/resources/test.ntriples
----------------------------------------------------------------------
diff --git a/mapreduce/src/test/resources/test.ntriples b/mapreduce/src/test/resources/test.ntriples
new file mode 100644
index 0000000..1ac8116
--- /dev/null
+++ b/mapreduce/src/test/resources/test.ntriples
@@ -0,0 +1,3 @@
+<urn:lubm:rdfts#GraduateStudent01> <urn:lubm:rdfts#hasFriend> <urn:lubm:rdfts#GraduateStudent02> .
+<urn:lubm:rdfts#GraduateStudent02> <urn:lubm:rdfts#hasFriend> <urn:lubm:rdfts#GraduateStudent03> .
+<urn:lubm:rdfts#GraduateStudent03> <urn:lubm:rdfts#hasFriend> <urn:lubm:rdfts#GraduateStudent04> .
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/42895eac/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 62238ff..ec4bf1c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,7 @@ under the License.
<module>common</module>
<module>dao</module>
<module>extras</module>
+ <module>mapreduce</module>
<module>osgi</module>
<module>pig</module>
<module>sail</module>
@@ -149,6 +150,11 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.rya</groupId>
+ <artifactId>rya.mapreduce</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.rya</groupId>
<artifactId>rya.prospector</artifactId>
<version>${project.version}</version>
</dependency>