7 |
8 | # Halyard
9 |
10 | [](https://travis-ci.org/Merck/Halyard)
11 | [](https://codecov.io/gh/Merck/Halyard/)
12 |
13 | Halyard is an extremely horizontally scalable [RDF store](https://en.wikipedia.org/wiki/Triplestore) with support for [named graphs](https://en.wikipedia.org/wiki/Named_graph), designed for storage and integration of extremely large [semantic data models](https://en.wikipedia.org/wiki/Semantic_data_model), and execution of [SPARQL 1.1](http://www.w3.org/TR/sparql11-query) queries of the whole [linked data](https://en.wikipedia.org/wiki/Linked_data) universe snapshots. The implementation of Halyard is based on [Eclipse RDF4J](http://rdf4j.org) framework and the [Apache HBase](http://hbase.apache.org) database, and it is completely written in Java.
14 |
15 |
16 |
17 |
18 |
19 |
20 | ## Run in Amazon EMR
21 |
22 | To get started with Halyard, try deploying it on an Amazon Elastic MapReduce (EMR) cluster.
23 |
24 | See the [Amazon EMR sample cluster setup](getting-started.html#amazon-emr-sample-cluster-setup).
25 |
26 | ## Run locally
27 |
28 | Download and unzip the latest `halyard-sdk-.zip` bundle from the [releases page](https://github.com/Merck/Halyard/releases) to a Apache Hadoop cluster node with a configured Apache HBase client.
29 |
30 | Halyard is expected to run on an Apache Hadoop cluster node with configured Apache HBase client. Apache Hadoop and Apache HBase components are not bundled with Halyard. The runtime requirements are:
31 |
32 | * Apache Hadoop version 2.5.1 or higher
33 | * Apache HBase version 1.1.2 or higher
34 | * Java 8 Runtime
35 |
36 | *Note: Recommended Apache Hadoop distribution is Hortonworks Data Platform (HDP) version 2.4.2 or Amazon Elastic MapReduce (EMR).*
37 |
38 |
39 |
40 |
41 |
42 | ## Get involved
43 |
44 | * Read the [documentation](https://merck.github.io/Halyard/getting-started.html)
45 | * Download the [binaries](https://github.com/Merck/Halyard/releases)
46 | * Clone the [GitHub repository](https://github.com/Merck/Halyard)
47 | * See the [open issues](https://github.com/Merck/Halyard/issues)
48 | * Join our [discussion group](https://groups.google.com/d/forum/halyard-users)
49 | * Contact the author: [Adam Sotona](mailto:adam.sotona@merck.com)
50 |
51 |
52 |
53 |
54 |
55 | ## Articles
56 |
57 | * [Inside Halyard: 1. Triples, Keys, Columns and Values - everything upside down](https://www.linkedin.com/pulse/inside-halyard-1-triples-keys-columns-values-upside-adam-sotona)
58 | * [Inside Halyard: 2. When one working thread is not enough (PUSH versus PULL)](https://www.linkedin.com/pulse/inside-halyard-2-when-one-working-thread-enough-push-versus-sotona)
59 | * [Inside Halyard: 3. Sipping a river through drinking straws](https://www.linkedin.com/pulse/inside-halyard-3-sipping-river-through-drinking-straws-adam-sotona)
60 | * [Inside Halyard: 4. Bulk operations - shifting a mountain](https://www.linkedin.com/pulse/inside-halyard-4-bulk-operations-shifting-mountain-adam-sotona)
61 | * [Inside Halyard: 5. SPARQL Federation without border controls](https://www.linkedin.com/pulse/inside-halyard-5-sparql-federation-without-border-controls-sotona)
62 | * [Inside Halyard: 6. Statistics-based acceleration of SPARQL queries](https://www.linkedin.com/pulse/inside-halyard-6-statistics-based-acceleration-sparql-adam-sotona)
63 | * [Sailing Halyard Over Three Major Clouds](https://www.linkedin.com/pulse/sailing-halyard-over-three-major-clouds-adam-sotona/)
64 | * [Halyard Tips&Tricks - Dynamically Scaled Cloud Cluster Disk Space Issue](https://www.linkedin.com/pulse/halyard-tipstricks-dynamically-scaled-cloud-cluster-adam-sotona)
65 | * [Halyard Tips&Tricks - Heavy Load-balanced SPARQL Endpoint](https://www.linkedin.com/pulse/halyard-tipstricks-heavy-load-balanced-sparql-endpoint-adam-sotona)
66 | * [Halyard Tips&Tricks - Advanced Literal Search Techniques](https://www.linkedin.com/pulse/halyard-tipstricks-advanced-literal-search-adam-sotona)
67 | * [Halyard Tips&Tricks - Jenkins as a Job Orchestrator](https://www.linkedin.com/pulse/halyard-tipstricks-jenkins-job-orchestrator-adam-sotona)
68 | * [Halyard Tips&Tricks - Trillion Statements Challenge](https://www.linkedin.com/pulse/halyard-tipstricks-trillion-statements-challenge-adam-sotona)
69 |
70 |
71 |
--------------------------------------------------------------------------------
/docs/ns.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Namespace
3 | layout: doc
4 | ---
5 |
6 | This is the home of the Halyard namespace:
7 |
8 | ```
9 | PREFIX halyard:
10 | ```
11 |
12 | ## In-data used identifiers
13 |
14 | ### `halyard:statsContext`
15 |
16 | A named graph context used by Halyard to store dataset statistics.
17 |
18 | ### `halyard:statsRoot`
19 |
20 | Statistics dataset root node within the [`halyard:statsContext`](#statsContext) named graph context.
21 |
22 | ### `halyard:namespacePrefix`
23 |
24 | Property used by Halyard to persist namespaces inside the datasets.
25 |
26 | ## Custom SPARQL filter functions
27 |
28 | ### `halyard:forkAndFilterBy(, ?var1 [,?varN...])`
29 |
30 | Custom SPARQL function used in [Halyard Bulk Update](tools#Halyard_Bulk_Update) and [Halyard Bulk Export](tools#Halyard_Bulk_Export).
31 |
32 | ### ~~`halyard:parallelSplitBy`~~
33 |
34 | ~~Custom SPARQL function used in [Halyard Parallel Export](tools#Halyard_Parallel_Export).~~
35 |
36 | ### ~~`halyard:decimateBy`~~
37 |
38 | ## Custom data types
39 |
40 | ### `halyard:search`
41 |
42 | Custom data type passing the value as a query string to Elastic Search index (when configured). The value is replaced with all matching values retrieved from Elastic Search index during SPARQL query, during direct API repository operations, or during RDF4J Workbench exploration of the datasets.
43 |
44 | ## SAIL configuration predicates
45 |
46 | ### `halyard:tableName`
47 |
48 | ### `halyard:splitBits`
49 |
50 | ### `halyard:createTable`
51 |
52 | ### `halyard:pushStrategy`
53 |
54 | ### `halyard:evaluationTimeout`
55 |
--------------------------------------------------------------------------------
/findbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Halyard
2 |
3 | [](https://travis-ci.org/Merck/Halyard)
4 | [](https://codecov.io/gh/Merck/Halyard/)
5 |
6 | Halyard is an extremely horizontally scalable triple store with support for named graphs, designed for integration of extremely large semantic data models and for storage and SPARQL 1.1 querying of complete Linked Data universe snapshots. Halyard implementation is based on Eclipse RDF4J framework and Apache HBase database, and it is completely written in Java.
7 |
8 | **Author: [Adam Sotona](mailto:adam.sotona@merck.com)**
9 |
10 | **Discussion group: **
11 |
12 | **Documentation: **
13 |
14 | ## Get started
15 |
16 | [Download](https://github.com/Merck/Halyard/releases) and unzip the latest `halyard-sdk-.zip` bundle to a Apache Hadoop cluster node with configured Apache HBase client.
17 |
18 | Halyard is expected to run on an Apache Hadoop cluster node with configured Apache HBase client. Apache Hadoop and Apache HBase components are not bundled with Halyard. The runtime requirements are:
19 |
20 | * Apache Hadoop version 2.5.1 or higher
21 | * Apache HBase version 1.1.2 or higher
22 | * Java 8 Runtime
23 |
24 | *Note: Recommended Apache Hadoop distribution is the latest version of Hortonworks Data Platform (HDP) or Amazon Elastic Map Reduce (EMR).*
25 |
26 | See [Documentation](https://merck.github.io/Halyard) for usage examples, architecture information, and more.
27 |
28 | ## Repository contents
29 |
30 | * `common` - a library for direct mapping between an RDF data model and Apache HBase
31 | * `strategy` - a generic parallel asynchronous implementation of RDF4J Evaluation Strategy
32 | * `sail` - an implementation of the RDF4J Storage and Inference Layer on top of Apache HBase
33 | * `tools` - a set of command line and Apache Hadoop MapReduce tools for loading, updating, querying, and exporting the data with maximum performance
34 | * `sdk` - a distributable bundle of Eclipse RDF4J and Halyard for command line use on an Apache Hadoop cluster with configured HBase
35 | * `webapps` - a re-distribution of Eclipse RDF4J Web Applications (RDF4J-Server and RDF4J-Workbench), patched and enhanced to include Halyard as another RDF repository option
36 |
--------------------------------------------------------------------------------
/rio/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | halyard-rio
5 | jar
6 |
7 | com.msd.gin.halyard
8 | halyard
9 | 2.5
10 |
11 |
12 |
13 | org.eclipse.rdf4j
14 | rdf4j-runtime
15 | ${rdf4j.version}
16 | pom
17 |
18 |
19 | junit
20 | junit
21 | 4.12
22 | test
23 |
24 |
25 |
--------------------------------------------------------------------------------
/rio/src/main/java/com/msd/gin/halyard/rio/NDJSONLDParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Merck Sharp & Dohme Corp. a subsidiary of Merck & Co.,
3 | * Inc., Kenilworth, NJ, USA.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.msd.gin.halyard.rio;
18 |
19 | import java.io.BufferedReader;
20 | import java.io.IOException;
21 | import java.io.InputStream;
22 | import java.io.InputStreamReader;
23 | import java.io.Reader;
24 | import java.io.StringReader;
25 | import java.nio.charset.StandardCharsets;
26 | import java.util.Arrays;
27 | import org.eclipse.rdf4j.rio.RDFFormat;
28 | import org.eclipse.rdf4j.rio.RDFHandlerException;
29 | import org.eclipse.rdf4j.rio.RDFParseException;
30 | import org.eclipse.rdf4j.rio.RDFParser;
31 | import org.eclipse.rdf4j.rio.RDFParserFactory;
32 | import org.eclipse.rdf4j.rio.jsonld.JSONLDParser;
33 |
34 | /**
35 | *
36 | * @author Adam Sotona (MSD)
37 | */
38 | public class NDJSONLDParser extends JSONLDParser {
39 |
40 | public static class Factory implements RDFParserFactory {
41 |
42 | @Override
43 | public RDFFormat getRDFFormat() {
44 | return NDJSONLD;
45 | }
46 |
47 | @Override
48 | public RDFParser getParser() {
49 | return new NDJSONLDParser();
50 | }
51 | }
52 |
53 | public static final RDFFormat NDJSONLD = new RDFFormat("ND-JSON-LD", Arrays.asList("application/x-nd-json-ld"),
54 | StandardCharsets.UTF_8, Arrays.asList("ndjsonld"),
55 | RDFFormat.SUPPORTS_NAMESPACES, RDFFormat.SUPPORTS_CONTEXTS);
56 |
57 | @Override
58 | public RDFFormat getRDFFormat() {
59 | return NDJSONLD;
60 | }
61 |
62 | @Override
63 | public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
64 | parse(new InputStreamReader(in, StandardCharsets.UTF_8), baseURI);
65 | }
66 |
67 | @Override
68 | public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
69 | BufferedReader br = new BufferedReader(reader);
70 | String line;
71 | while ((line = br.readLine()) != null) {
72 | super.parse(new StringReader(line), baseURI);
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/rio/src/main/resources/META-INF/services/org.eclipse.rdf4j.rio.RDFParserFactory:
--------------------------------------------------------------------------------
1 | com.msd.gin.halyard.rio.JSONParser$Factory
2 | com.msd.gin.halyard.rio.NDJSONLDParser$Factory
3 |
--------------------------------------------------------------------------------
/rio/src/test/java/com/msd/gin/halyard/rio/JSONParserParseTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Merck Sharp & Dohme Corp. a subsidiary of Merck & Co.,
3 | * Inc., Kenilworth, NJ, USA.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.msd.gin.halyard.rio;
18 |
19 | import java.io.StringReader;
20 | import java.util.Iterator;
21 | import java.util.TreeMap;
22 | import org.eclipse.rdf4j.model.Model;
23 | import org.eclipse.rdf4j.model.Statement;
24 | import org.eclipse.rdf4j.model.impl.LinkedHashModel;
25 | import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
26 | import org.eclipse.rdf4j.rio.RDFFormat;
27 | import org.eclipse.rdf4j.rio.RDFParser;
28 | import org.eclipse.rdf4j.rio.Rio;
29 | import org.eclipse.rdf4j.rio.WriterConfig;
30 | import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
31 | import org.eclipse.rdf4j.rio.helpers.ContextStatementCollector;
32 | import org.junit.Assert;
33 | import org.junit.Test;
34 | import org.junit.runner.RunWith;
35 | import org.junit.runners.Parameterized;
36 |
37 | /**
38 | *
39 | * @author Adam Sotona (MSD)
40 | */
41 | @RunWith(Parameterized.class)
42 | public class JSONParserParseTest {
43 |
44 | @Parameterized.Parameters
45 | public static String[] data() {
46 | return new String[] {"empty", "emptyObj", "primitives", "rootArray", "nestedArrays", "example"};
47 | }
48 |
49 | @Parameterized.Parameter
50 | public String parameter;
51 |
52 | @Test
53 | public void testParse() throws Exception {
54 | Model transformedModel = new LinkedHashModel();
55 | RDFParser parser = new JSONParser();
56 | parser.setValueFactory(SimpleValueFactory.getInstance());
57 | parser.set(JSONParser.GENERATE_ONTOLOGY, true);
58 | parser.setRDFHandler(new ContextStatementCollector(transformedModel, SimpleValueFactory.getInstance()));
59 | parser.parse(JSONParserParseTest.class.getResourceAsStream(parameter + ".json"), "http://testParse/"+parameter + "/");
60 |
61 | WriterConfig wc = new WriterConfig();
62 | wc.set(BasicWriterSettings.PRETTY_PRINT, true);
63 | System.out.println("-------------- " + parameter + " ------------------");
64 | Rio.write(transformedModel, System.out, RDFFormat.TURTLE, wc);
65 |
66 | Model expectedModel = Rio.parse(JSONParserParseTest.class.getResourceAsStream(parameter + ".ttl"), "http://testParse/" + parameter + "/", RDFFormat.TURTLE);
67 |
68 | JSONParserParseTest.assertEquals(expectedModel, transformedModel);
69 | }
70 |
71 | public static void assertEquals(Model expectedModel, Model transformedModel) {
72 | TreeMap fail = new TreeMap<>();
73 | Iterator it = expectedModel.iterator();
74 | while (it.hasNext()) {
75 | Statement st = it.next();
76 | if (!transformedModel.contains(st)) {
77 | fail.put(st.toString(), "-" + st.toString());
78 | }
79 | }
80 | it = transformedModel.iterator();
81 | while (it.hasNext()) {
82 | Statement st = it.next();
83 | if (!expectedModel.contains(st)) {
84 | fail.put(st.toString(), "+" + st.toString());
85 | }
86 | }
87 | if (fail.size() > 0) {
88 | StringBuilder sb = new StringBuilder();
89 | sb.append('\n');
90 | for (String line : fail.values()) {
91 | sb.append(line).append('\n');
92 | }
93 | Assert.fail(sb.toString());
94 | }
95 | Assert.assertEquals(expectedModel.size(), transformedModel.size());
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/rio/src/test/java/com/msd/gin/halyard/rio/JSONParserTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Merck Sharp & Dohme Corp. a subsidiary of Merck & Co.,
3 | * Inc., Kenilworth, NJ, USA.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.msd.gin.halyard.rio;
18 |
19 | import java.io.IOException;
20 | import java.io.StringReader;
21 | import java.util.Collection;
22 | import org.eclipse.rdf4j.model.Model;
23 | import org.eclipse.rdf4j.model.impl.LinkedHashModel;
24 | import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
25 | import org.eclipse.rdf4j.rio.ParserConfig;
26 | import org.eclipse.rdf4j.rio.RDFParser;
27 | import org.eclipse.rdf4j.rio.Rio;
28 | import org.eclipse.rdf4j.rio.RioSetting;
29 | import org.eclipse.rdf4j.rio.helpers.ContextStatementCollector;
30 | import org.junit.Assert;
31 | import static org.junit.Assert.assertNotNull;
32 | import org.junit.Test;
33 |
34 | /**
35 | *
36 | * @author Adam Sotona (MSD)
37 | */
38 | public class JSONParserTest {
39 |
40 | @Test
41 | public void testJSONParserFactory() {
42 | assertNotNull(Rio.createParser(JSONParser.JSON));
43 | }
44 |
45 | @Test
46 | public void testGetRDFFormat() {
47 | Assert.assertEquals(JSONParser.JSON, new JSONParser().getRDFFormat());
48 | }
49 |
50 | @Test
51 | public void testGetSupportedSettings() {
52 | Collection> set = new JSONParser().getSupportedSettings();
53 | Assert.assertTrue(set.contains(JSONParser.GENERATE_DATA));
54 | Assert.assertTrue(set.contains(JSONParser.GENERATE_ONTOLOGY));
55 | }
56 |
57 | @Test
58 | public void testMethodsThatDoNothing() {
59 | RDFParser p = new JSONParser();
60 | p.setVerifyData(true);
61 | p.setPreserveBNodeIDs(true);
62 | p.setStopAtFirstError(true);
63 | p.setDatatypeHandling(RDFParser.DatatypeHandling.NORMALIZE);
64 | p.setParseErrorListener(null);
65 | p.setParseLocationListener(null);
66 | }
67 |
68 | @Test
69 | public void testParserSettings() {
70 | RDFParser p = new JSONParser();
71 | ParserConfig pc = new ParserConfig();
72 | Assert.assertSame(pc, p.setParserConfig(pc).getParserConfig());
73 | }
74 |
75 | @Test (expected = IllegalArgumentException.class)
76 | public void testParseWrongJSON() throws IOException {
77 | new JSONParser().parse(new StringReader("true"), "http://test/");
78 | }
79 |
80 | @Test (expected = IllegalArgumentException.class)
81 | public void testParseInvalidURI() throws IOException {
82 | new JSONParser().parse(new StringReader("[]"), "invalid_uri");
83 | }
84 |
85 | @Test (expected = IllegalArgumentException.class)
86 | public void testParserMultiObj() throws IOException {
87 | Model transformedModel = new LinkedHashModel();
88 | RDFParser parser = new JSONParser();
89 | parser.setRDFHandler(new ContextStatementCollector(transformedModel, SimpleValueFactory.getInstance()));
90 | parser.parse(new StringReader("{}{}"), "http://test/");
91 | }
92 |
93 | @Test
94 | public void testParse() throws Exception {
95 | JSONParser p = new JSONParser();
96 | p.set(JSONParser.GENERATE_DATA, false);
97 | p.set(JSONParser.GENERATE_ONTOLOGY, false);
98 | p.parse(new StringReader("{\"a\": [\"b\", \"c\", \"d\"],\"e\": [{\"f\": \"g\"}, {\"h\": \"i\"}]}"), "http://test/");
99 | }
100 |
101 | @Test (expected = RuntimeException.class)
102 | public void testInvalidMDAlgorithm() {
103 | new JSONParser("invalid");
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/rio/src/test/java/com/msd/gin/halyard/rio/NDJSONLDParserTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Merck Sharp & Dohme Corp. a subsidiary of Merck & Co.,
3 | * Inc., Kenilworth, NJ, USA.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.msd.gin.halyard.rio;
18 |
19 | import org.eclipse.rdf4j.model.Model;
20 | import org.eclipse.rdf4j.model.impl.LinkedHashModel;
21 | import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
22 | import org.eclipse.rdf4j.rio.RDFFormat;
23 | import org.eclipse.rdf4j.rio.RDFParser;
24 | import org.eclipse.rdf4j.rio.Rio;
25 | import org.eclipse.rdf4j.rio.helpers.ContextStatementCollector;
26 | import org.junit.Assert;
27 | import static org.junit.Assert.assertNotNull;
28 | import org.junit.Test;
29 |
30 | /**
31 | *
32 | * @author Adam Sotona (MSD)
33 | */
34 | public class NDJSONLDParserTest {
35 |
36 | @Test
37 | public void testNDJSONLDParserFactory() {
38 | assertNotNull(Rio.createParser(NDJSONLDParser.NDJSONLD));
39 | }
40 |
41 | @Test
42 | public void testNDJSONLDParser() throws Exception {
43 | Model transformedModel = new LinkedHashModel();
44 | RDFParser parser = new NDJSONLDParser();
45 | parser.setRDFHandler(new ContextStatementCollector(transformedModel, SimpleValueFactory.getInstance()));
46 | parser.parse(NDJSONLDParserTest.class.getResourceAsStream("efo_test.ndjsonld"), "http://test/");
47 |
48 | Model expectedModel = Rio.parse(NDJSONLDParserTest.class.getResourceAsStream("efo_test.ttl"), "http://test/", RDFFormat.TURTLE);
49 |
50 | JSONParserParseTest.assertEquals(expectedModel, transformedModel);
51 | }
52 |
53 | @Test
54 | public void testGetRDFFormat() {
55 | Assert.assertEquals(NDJSONLDParser.NDJSONLD, new NDJSONLDParser().getRDFFormat());
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/efo_test.ndjsonld:
--------------------------------------------------------------------------------
1 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0007123","label":{"@language":"en","@value":"So-Eum"},"parents":["http://www.ebi.ac.uk/efo/EFO_0007119"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
2 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0006347","alternative_terms":["PAE"],"label":{"@language":"en","@value":"pulmonary artery enlargement"},"parents":["http://www.ebi.ac.uk/efo/EFO_0003765"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
3 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0004827","label":"economic and social preference","parents":["http://www.ifomis.org/bfo/1.1/snap#Quality"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
4 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0001270","alternative_terms":["alpha","alpha mating type (yeast)","mating_type_alpha"],"label":"mating type alpha","parents":["http://www.ebi.ac.uk/efo/EFO_0001268"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
5 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0007120","label":{"@language":"en","@value":"Tae-Yang"},"parents":["http://www.ebi.ac.uk/efo/EFO_0007119"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
6 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0002614","alternative_terms":["Drug resistance to insulin (disorder)"],"label":"insulin resistance","parents":["http://purl.obolibrary.org/obo/HP_0001939"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
7 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0003847","alternative_terms":["Idiocy","MENTAL DEFIC","Deficiency, Mental","Disabilities, Intellectual","Disability, Intellectual","Mental Retardations, Psychosocial","Retardations, Psychosocial Mental","Retardation, Mental","Mental Retardation, Psychosocial","Intellectual Disabilities","Psychosocial Mental Retardation","Intellectual Disability","Retardation, Psychosocial Mental","Mental Deficiency","Deficiencies, Mental","DEFIC MENTAL","Psychosocial Mental Retardations","Mental Deficiencies"],"label":"mental retardation","parents":["http://purl.obolibrary.org/obo/HP_0000707"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
8 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0006852","label":{"@language":"en","@value":"metastatic"},"parents":["http://purl.obolibrary.org/obo/HP_0012823"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
9 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0007654","label":"clinical and behavioural ideal cardiovascular health","parents":["http://www.ebi.ac.uk/efo/EFO_0007652"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
10 | {"@id":"http://www.ebi.ac.uk/efo/EFO_0007063","label":"organism status","parents":["http://www.ifomis.org/bfo/1.1/snap#Quality"],"@context":{"@vocab":"http://www.ebi.ac.uk/efo/","rdfs":"http://www.w3.org/2000/01/rdf-schema#","label":"rdfs:label","parents":{"@id":"rdfs:subClassOf","@type":"@id","@container":"@set"},"alternative_terms":{"@id":"alternative_term","@container":"@set"}}}
11 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/efo_test.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdfs: .
2 |
3 | rdfs:label "So-Eum"@en ;
4 | rdfs:subClassOf .
5 |
6 | "PAE" ;
7 | rdfs:label "pulmonary artery enlargement"@en ;
8 | rdfs:subClassOf .
9 |
10 | rdfs:label "economic and social preference" ;
11 | rdfs:subClassOf .
12 |
13 | "alpha" , "alpha mating type (yeast)" , "mating_type_alpha" ;
14 | rdfs:label "mating type alpha" ;
15 | rdfs:subClassOf .
16 |
17 | rdfs:label "Tae-Yang"@en ;
18 | rdfs:subClassOf .
19 |
20 | "Drug resistance to insulin (disorder)" ;
21 | rdfs:label "insulin resistance" ;
22 | rdfs:subClassOf .
23 |
24 | "Idiocy" , "MENTAL DEFIC" , "Deficiency, Mental" , "Disabilities, Intellectual" , "Disability, Intellectual" , "Mental Retardations, Psychosocial" , "Retardations, Psychosocial Mental" , "Retardation, Mental" , "Mental Retardation, Psychosocial" , "Intellectual Disabilities" , "Psychosocial Mental Retardation" , "Intellectual Disability" , "Retardation, Psychosocial Mental" , "Mental Deficiency" , "Deficiencies, Mental" , "DEFIC MENTAL" , "Psychosocial Mental Retardations" , "Mental Deficiencies" ;
25 | rdfs:label "mental retardation" ;
26 | rdfs:subClassOf .
27 |
28 | rdfs:label "metastatic"@en ;
29 | rdfs:subClassOf .
30 |
31 | rdfs:label "clinical and behavioural ideal cardiovascular health" ;
32 | rdfs:subClassOf .
33 |
34 | rdfs:label "organism status" ;
35 | rdfs:subClassOf .
36 |
37 |
38 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/empty.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Merck/Halyard/fabb338edb14276aa7ef9f5f9b59f680335b22d3/rio/src/test/resources/com/msd/gin/halyard/rio/empty.json
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/empty.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix owl: .
4 | @prefix : .
5 |
6 | a owl:Ontology .
7 |
8 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/emptyObj.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/emptyObj.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix owl: .
4 | @prefix : .
5 |
6 | a owl:Ontology .
7 |
8 | :K1gB0IYDwNX021i3HcX_IuHj07iKxD3MRGjRy7rzxGMcBmqEiBjE7VL7Mp7Iqep3qkcNOXBA8tk40anI2m-pbA a ::Node .
9 |
10 | ::Node a rdfs:Class .
11 |
12 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/example.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "0001",
4 | "type": "donut",
5 | "name": "Cake",
6 | "ppu": 0.55,
7 | "batters":
8 | {
9 | "batter":
10 | [
11 | {
12 | "id": "1001",
13 | "type": "Regular"
14 | },
15 | {
16 | "id": "1002",
17 | "type": "Chocolate"
18 | },
19 | {
20 | "id": "1003",
21 | "type": "Blueberry"
22 | },
23 | {
24 | "id": "1004",
25 | "type": "Devil's Food"
26 | }
27 | ]
28 | },
29 | "topping":
30 | [
31 | {
32 | "id": "5001",
33 | "type": "None"
34 | },
35 | {
36 | "id": "5002",
37 | "type": "Glazed"
38 | },
39 | {
40 | "id": "5005",
41 | "type": "Sugar"
42 | },
43 | {
44 | "id": "5007",
45 | "type": "Powdered Sugar"
46 | },
47 | {
48 | "id": "5006",
49 | "type": "Chocolate with Sprinkles"
50 | },
51 | {
52 | "id": "5003",
53 | "type": "Chocolate"
54 | },
55 | {
56 | "id": "5004",
57 | "type": "Maple"
58 | }
59 | ]
60 | },
61 | {
62 | "id": "0002",
63 | "type": "donut",
64 | "name": "Raised",
65 | "ppu": 0.55,
66 | "batters":
67 | {
68 | "batter":
69 | [
70 | {
71 | "id": "1001",
72 | "type": "Regular"
73 | }
74 | ]
75 | },
76 | "topping":
77 | [
78 | {
79 | "id": "5001",
80 | "type": "None"
81 | },
82 | {
83 | "id": "5002",
84 | "type": "Glazed"
85 | },
86 | {
87 | "id": "5005",
88 | "type": "Sugar"
89 | },
90 | {
91 | "id": "5003",
92 | "type": "Chocolate"
93 | },
94 | {
95 | "id": "5004",
96 | "type": "Maple"
97 | }
98 | ]
99 | },
100 | {
101 | "id": "0003",
102 | "type": "donut",
103 | "name": "Old Fashioned",
104 | "ppu": 0.55,
105 | "batters":
106 | {
107 | "batter":
108 | [
109 | {
110 | "id": "1001",
111 | "type": "Regular"
112 | },
113 | {
114 | "id": "1002",
115 | "type": "Chocolate"
116 | }
117 | ]
118 | },
119 | "topping":
120 | [
121 | {
122 | "id": "5001",
123 | "type": "None"
124 | },
125 | {
126 | "id": "5002",
127 | "type": "Glazed"
128 | },
129 | {
130 | "id": "5003",
131 | "type": "Chocolate"
132 | },
133 | {
134 | "id": "5004",
135 | "type": "Maple"
136 | }
137 | ]
138 | }
139 | ]
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/nestedArrays.json:
--------------------------------------------------------------------------------
1 | {
2 | "a": ["b", "c", "d"],
3 | "e": [{"f": "g"}, {"h": "i"}]
4 | }
5 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/nestedArrays.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix owl: .
4 | @prefix : .
5 |
6 | a owl:Ontology .
7 |
8 | :m4sUtoNKHXvHoyAbBEDOWeDENVFnt5CtRsNvsWebfVRUZKlhqOYv_oA-puVj4ZUD8qc5KbAmHx_zfUZGeQNRYA a ::Node ;
9 | :a "b" , "c" , "d" ;
10 | :e :m4sUtoNKHXvHoyAbBEDOWeDENVFnt5CtRsNvsWebfVRUZKlhqOYv_oA-puVj4ZUD8qc5KbAmHx_zfUZGeQNRYA.e:0 , :m4sUtoNKHXvHoyAbBEDOWeDENVFnt5CtRsNvsWebfVRUZKlhqOYv_oA-puVj4ZUD8qc5KbAmHx_zfUZGeQNRYA.e:1 .
11 |
12 | ::Node a rdfs:Class .
13 |
14 | :a a owl:DatatypeProperty ;
15 | rdfs:label "a" ;
16 | rdfs:domain ::Node .
17 |
18 | :e a owl:ObjectProperty ;
19 | rdfs:label "e" ;
20 | rdfs:domain ::Node ;
21 | rdfs:range :e:Node .
22 |
23 | :m4sUtoNKHXvHoyAbBEDOWeDENVFnt5CtRsNvsWebfVRUZKlhqOYv_oA-puVj4ZUD8qc5KbAmHx_zfUZGeQNRYA.e:0 a :e:Node ;
24 | :e:index 0 ;
25 | :e.f "g" .
26 |
27 | :e:Node a rdfs:Class .
28 |
29 | :e:index a owl:DatatypeProperty ;
30 | rdfs:label "index" ;
31 | rdfs:domain :e:Node .
32 |
33 | :e.f a owl:DatatypeProperty ;
34 | rdfs:label "f" ;
35 | rdfs:domain :e:Node .
36 |
37 | :m4sUtoNKHXvHoyAbBEDOWeDENVFnt5CtRsNvsWebfVRUZKlhqOYv_oA-puVj4ZUD8qc5KbAmHx_zfUZGeQNRYA.e:1 a :e:Node ;
38 | :e:index 1 ;
39 | :e.h "i" .
40 |
41 | :e.h a owl:DatatypeProperty ;
42 | rdfs:label "h" ;
43 | rdfs:domain :e:Node .
44 |
45 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/primitives.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": "text",
3 | "boolean": true,
4 | "integer": 42,
5 | "double": 3.14,
6 | "boolArray": [true, false, true, false],
7 | "intArray": [1, 2, 3, 4, 5],
8 | "doubleArray": [1.1, 2.2, 3.3],
9 | "mixedArray": ["string", true, 47, 3.15, {}]
10 | }
11 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/primitives.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix owl: .
4 | @prefix : .
5 |
6 | a owl:Ontology .
7 |
8 | :aZcwCir_UAqtD78F_Y_-m_9mrm65EvIUkCh9uT3-in9ek3p8Oa2GJi4nl-3RjoieUoNEI_crpvDuNuGZ02w2BA a ::Node ;
9 | :string "text" ;
10 | :integer "42" ;
11 | :double "3.14" ;
12 | :intArray "1" , "2" , "3" , "4" , "5" ;
13 | :doubleArray "1.1" , "2.2" , "3.3" ;
14 | :mixedArray "string" , "47" , "3.15" , :aZcwCir_UAqtD78F_Y_-m_9mrm65EvIUkCh9uT3-in9ek3p8Oa2GJi4nl-3RjoieUoNEI_crpvDuNuGZ02w2BA.mixedArray:4 .
15 |
16 | ::Node a rdfs:Class .
17 |
18 | :string a owl:DatatypeProperty ;
19 | rdfs:label "string" ;
20 | rdfs:domain ::Node .
21 |
22 | :boolean a owl:DatatypeProperty ;
23 | rdfs:label "boolean" ;
24 | rdfs:domain ::Node .
25 |
26 | :integer a owl:DatatypeProperty ;
27 | rdfs:label "integer" ;
28 | rdfs:domain ::Node .
29 |
30 | :double a owl:DatatypeProperty ;
31 | rdfs:label "double" ;
32 | rdfs:domain ::Node .
33 |
34 | :boolArray a owl:DatatypeProperty ;
35 | rdfs:label "boolArray" ;
36 | rdfs:domain ::Node .
37 |
38 | :intArray a owl:DatatypeProperty ;
39 | rdfs:label "intArray" ;
40 | rdfs:domain ::Node .
41 |
42 | :doubleArray a owl:DatatypeProperty ;
43 | rdfs:label "doubleArray" ;
44 | rdfs:domain ::Node .
45 |
46 | :mixedArray a owl:DatatypeProperty , owl:ObjectProperty ;
47 | rdfs:label "mixedArray" ;
48 | rdfs:domain ::Node ;
49 | rdfs:range :mixedArray:Node .
50 |
51 | :aZcwCir_UAqtD78F_Y_-m_9mrm65EvIUkCh9uT3-in9ek3p8Oa2GJi4nl-3RjoieUoNEI_crpvDuNuGZ02w2BA.mixedArray:4 a :mixedArray:Node ;
52 | :mixedArray:index 4 .
53 |
54 | :mixedArray:Node a rdfs:Class .
55 |
56 | :mixedArray:index a owl:DatatypeProperty ;
57 | rdfs:label "index" ;
58 | rdfs:domain :mixedArray:Node .
59 |
60 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/rootArray.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "a": "b"
4 | },
5 | {
6 | "c": "d"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/rio/src/test/resources/com/msd/gin/halyard/rio/rootArray.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix owl: .
4 | @prefix : .
5 |
6 | a owl:Ontology .
7 |
8 | a ::Node ;
9 | :a "b" .
10 |
11 | ::Node a rdfs:Class .
12 |
13 | :a a owl:DatatypeProperty ;
14 | rdfs:label "a" ;
15 | rdfs:domain ::Node .
16 |
17 | :nYQMyuwHhEx7iPAlnw1vWUU4Ww7NDfKdZ9jBX6pkZ3htlU09GEWIe4p1Tpgn3jHPTqxoYWu2QyRJMdzuCEPniw a ::Node ;
18 | :c "d" .
19 |
20 | :c a owl:DatatypeProperty ;
21 | rdfs:label "c" ;
22 | rdfs:domain ::Node .
23 |
24 |
--------------------------------------------------------------------------------
/sail/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | halyard-sail
5 | jar
6 |
7 | com.msd.gin.halyard
8 | halyard
9 | 2.5
10 |
11 |
12 |
13 | ${project.groupId}
14 | halyard-common
15 | ${project.version}
16 |
17 |
18 | ${project.groupId}
19 | halyard-strategy
20 | ${project.version}
21 |
22 |
23 | org.apache.hbase
24 | hbase-server
25 | ${hbase.version}
26 | provided
27 |
28 |
29 | org.eclipse.rdf4j
30 | rdf4j-console
31 | ${rdf4j.version}
32 |
33 |
34 | ch.qos.logback
35 | logback-classic
36 |
37 |
38 |
39 |
40 | ${project.groupId}
41 | halyard-common
42 | ${project.version}
43 | test-jar
44 | test
45 |
46 |
47 | org.apache.hadoop
48 | hadoop-mapreduce-client-jobclient
49 | ${hadoop.version}
50 | test
51 | tests
52 |
53 |
54 | org.apache.hadoop
55 | hadoop-common
56 | ${hadoop.version}
57 | test
58 | tests
59 |
60 |
61 | org.apache.hadoop
62 | hadoop-mapreduce-client-hs
63 | ${hadoop.version}
64 | test
65 |
66 |
67 | org.apache.hadoop
68 | hadoop-yarn-server-resourcemanager
69 | ${hadoop.version}
70 | test
71 |
72 |
73 | org.apache.hadoop
74 | hadoop-yarn-server-tests
75 | ${hadoop.version}
76 | test
77 | tests
78 |
79 |
80 | org.json
81 | json
82 | 20140107
83 |
84 |
85 | commons-codec
86 | commons-codec
87 | 1.9
88 |
89 |
90 |
--------------------------------------------------------------------------------
/sail/src/main/java/com/msd/gin/halyard/sail/HBaseSailFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Merck Sharp & Dohme Corp. a subsidiary of Merck & Co.,
3 | * Inc., Kenilworth, NJ, USA.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.msd.gin.halyard.sail;
18 |
19 | import org.apache.hadoop.hbase.HBaseConfiguration;
20 | import org.eclipse.rdf4j.sail.Sail;
21 | import org.eclipse.rdf4j.sail.config.SailConfigException;
22 | import org.eclipse.rdf4j.sail.config.SailFactory;
23 | import org.eclipse.rdf4j.sail.config.SailImplConfig;
24 |
25 | /**
26 | * Factory for constructing an HBaseSail instance.
27 | * @author Adam Sotona (MSD)
28 | */
29 | public final class HBaseSailFactory implements SailFactory {
30 |
31 | /**
32 | * String HBaseSail type identification
33 | */
34 | public static final String SAIL_TYPE = "openrdf:HBaseStore";
35 |
36 | @Override
37 | public String getSailType() {
38 | return SAIL_TYPE;
39 | }
40 |
41 | /**
42 | * Factory method for instantiating an HBaseSailConfig
43 | * @return new HBaseSailConfig instance
44 | */
45 | @Override
46 | public SailImplConfig getConfig() {
47 | return new HBaseSailConfig();
48 | }
49 |
50 | @Override
51 | public Sail getSail(SailImplConfig config) throws SailConfigException {
52 | if (!SAIL_TYPE.equals(config.getType())) {
53 | throw new SailConfigException("Invalid Sail type: " + config.getType());
54 | }
55 | if (config instanceof HBaseSailConfig) {
56 | HBaseSailConfig hconfig = (HBaseSailConfig) config;
57 | //instantiate the sail
58 | HBaseSail sail = new HBaseSail(HBaseConfiguration.create(), hconfig.getTablespace(), hconfig.isCreate(), hconfig.getSplitBits(), hconfig.isPush(), hconfig.getEvaluationTimeout(), hconfig.getElasticIndexURL(), null);
59 | return sail;
60 | } else {
61 | throw new SailConfigException("Invalid configuration: " + config);
62 | }
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/sail/src/main/java/com/msd/gin/halyard/sail/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes that support the Storage And Inference Layer (SAIL) interface between RDF4J and HBase
3 | */
4 | package com.msd.gin.halyard.sail;
--------------------------------------------------------------------------------
/sail/src/main/resources/META-INF/services/org.eclipse.rdf4j.sail.config.SailFactory:
--------------------------------------------------------------------------------
1 | com.msd.gin.halyard.sail.HBaseSailFactory
--------------------------------------------------------------------------------
/sail/src/test/java/com/msd/gin/halyard/sail/HBaseRepositoryManagerTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Merck Sharp & Dohme Corp. a subsidiary of Merck & Co.,
3 | * Inc., Kenilworth, NJ, USA.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.msd.gin.halyard.sail;
18 |
19 | import com.msd.gin.halyard.common.HBaseServerTestInstance;
20 | import java.net.MalformedURLException;
21 | import java.util.Collection;
22 | import org.apache.http.client.HttpClient;
23 | import org.apache.http.impl.client.DefaultHttpClient;
24 | import org.eclipse.rdf4j.repository.Repository;
25 | import org.eclipse.rdf4j.repository.config.RepositoryConfig;
26 | import org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig;
27 | import org.eclipse.rdf4j.sail.memory.config.MemoryStoreConfig;
28 | import org.junit.Test;
29 | import static org.junit.Assert.*;
30 |
31 | /**
32 | *
33 | * @author Adam Sotona (MSD)
34 | */
35 | public class HBaseRepositoryManagerTest {
36 |
37 | @Test (expected = MalformedURLException.class)
38 | public void testGetLocation() throws Exception {
39 | new HBaseRepositoryManager().getLocation();
40 | }
41 |
42 | @Test
43 | public void testHttpClient() {
44 | HBaseRepositoryManager rm = new HBaseRepositoryManager();
45 | assertNull(rm.getHttpClient());
46 | @SuppressWarnings("deprecation")
47 | HttpClient cl = new DefaultHttpClient();
48 | rm.setHttpClient(cl);
49 | assertEquals(cl, rm.getHttpClient());
50 | }
51 |
52 | @Test
53 | public void testAddRepositoryPersists() throws Exception {
54 | HBaseRepositoryManager rm = new HBaseRepositoryManager();
55 | rm.overrideConfiguration(HBaseServerTestInstance.getInstanceConfig());
56 | rm.init();
57 | rm.addRepositoryConfig(new RepositoryConfig("repoTest", new SailRepositoryConfig(new MemoryStoreConfig(false))));
58 | assertTrue(rm.getAllRepositories().contains(rm.getRepository("repoTest")));
59 | rm.shutDown();
60 | //test persistence
61 | rm = new HBaseRepositoryManager();
62 | rm.overrideConfiguration(HBaseServerTestInstance.getInstanceConfig());
63 | rm.init();
64 | assertTrue(rm.getAllRepositories().contains(rm.getRepository("repoTest")));
65 | rm.shutDown();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/sail/src/test/java/com/msd/gin/halyard/sail/HBaseSailAddRemoveTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Merck Sharp & Dohme Corp. a subsidiary of Merck & Co.,
3 | * Inc., Kenilworth, NJ, USA.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.msd.gin.halyard.sail;
18 |
19 | import com.msd.gin.halyard.common.HBaseServerTestInstance;
20 | import java.util.Arrays;
21 | import java.util.Collection;
22 | import org.eclipse.rdf4j.common.iteration.CloseableIteration;
23 | import org.eclipse.rdf4j.model.IRI;
24 | import org.eclipse.rdf4j.model.Resource;
25 | import org.eclipse.rdf4j.model.Statement;
26 | import org.eclipse.rdf4j.model.Value;
27 | import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
28 | import org.eclipse.rdf4j.sail.SailException;
29 | import org.junit.AfterClass;
30 | import org.junit.Test;
31 | import static org.junit.Assert.*;
32 | import org.junit.BeforeClass;
33 | import org.junit.runner.RunWith;
34 | import org.junit.runners.Parameterized;
35 |
36 | /**
37 | *
38 | * @author Adam Sotona (MSD)
39 | */
40 | @RunWith(Parameterized.class)
41 | public class HBaseSailAddRemoveTest {
42 | private static final Resource SUBJ = SimpleValueFactory.getInstance().createIRI("http://whatever/subject/");
43 | private static final IRI PRED = SimpleValueFactory.getInstance().createIRI("http://whatever/pred/");
44 | private static final Value OBJ = SimpleValueFactory.getInstance().createLiteral("whatever literal");
45 | private static final IRI CONTEXT = SimpleValueFactory.getInstance().createIRI("http://whatever/cont/");
46 |
47 | private static HBaseSail explicitSail;
48 |
49 | @Parameterized.Parameters
50 | public static Collection