http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/markdown/querydata.md ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/markdown/querydata.md b/extras/rya.manual/src/site/markdown/querydata.md deleted file mode 100644 index a7e2a6d..0000000 --- a/extras/rya.manual/src/site/markdown/querydata.md +++ /dev/null @@ -1,137 +0,0 @@ - -<!-- - -[comment]: # Licensed to the Apache Software Foundation (ASF) under one -[comment]: # or more contributor license agreements. See the NOTICE file -[comment]: # distributed with this work for additional information -[comment]: # regarding copyright ownership. The ASF licenses this file -[comment]: # to you under the Apache License, Version 2.0 (the -[comment]: # "License"); you may not use this file except in compliance -[comment]: # with the License. You may obtain a copy of the License at -[comment]: # -[comment]: # http://www.apache.org/licenses/LICENSE-2.0 -[comment]: # -[comment]: # Unless required by applicable law or agreed to in writing, -[comment]: # software distributed under the License is distributed on an -[comment]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -[comment]: # KIND, either express or implied. See the License for the -[comment]: # specific language governing permissions and limitations -[comment]: # under the License. - ---> -# Query Data - -There are a few mechanisms to query data - -## Web JSP endpoint - -Open a url to `http://server/web.rya/sparqlQuery.jsp`. This simple form can run Sparql. - -## Web REST endpoint - -The War sets up a Web REST endpoint at `http://server/web.rya/queryrdf` that allows GET requests with queries. - -For this sample, we will assume you already loaded data from the [Load Data](loaddata.md) tutorial - -Save this file somewhere $RDF_DATA - -Second, use the following Java code to load data to the REST endpoint: - -``` JAVA -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; - -public class QueryDataServletRun { - - public static void main(String[] args) { - try { - String query = "select * where {\n" + - "<http://mynamespace/ProductType1> ?p ?o.\n" + - "}"; - - String queryenc = URLEncoder.encode(query, "UTF-8"); - - URL url = new URL("http://server/rdfTripleStore/queryrdf?query=" + queryenc); - URLConnection urlConnection = url.openConnection(); - urlConnection.setDoOutput(true); - - BufferedReader rd = new BufferedReader(new InputStreamReader( - urlConnection.getInputStream())); - String line; - while ((line = rd.readLine()) != null) { - System.out.println(line); - } - rd.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } -} -``` - -Compile and run this code above, changing the url that your Rdf War is running at. - -## Direct Code - -Here is a code snippet for directly running against Accumulo with the code. You will need at least accumulo.rya.jar, rya.api, rya.sail.impl on the classpath and transitive dependencies. I find that Maven is the easiest way to get a project dependency tree set up. - -``` JAVA -Connector connector = new ZooKeeperInstance("instance", "zoo1,zoo2,zoo3").getConnector("user", "password"); - -final RdfCloudTripleStore store = new RdfCloudTripleStore(); -AccumuloRyaDAO crdfdao = new AccumuloRyaDAO(); -crdfdao.setConnector(connector); - -AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); -conf.setTablePrefix("rts_"); -conf.setDisplayQueryPlan(true); -crdfdao.setConf(conf); -store.setRdfDao(crdfdao); - -ProspectorServiceEvalStatsDAO evalDao = new ProspectorServiceEvalStatsDAO(connector, conf); -evalDao.init(); -store.setRdfEvalStatsDAO(evalDao); - -InferenceEngine inferenceEngine = new InferenceEngine(); -inferenceEngine.setRdfDao(crdfdao); -inferenceEngine.setConf(conf); -store.setInferenceEngine(inferenceEngine); - -Repository myRepository = new RyaSailRepository(store); -myRepository.initialize(); - -String query = "select * where {\n" + - "<http://mynamespace/ProductType1> ?p ?o.\n" + - "}"; -RepositoryConnection conn = myRepository.getConnection(); -System.out.println(query); -TupleQuery tupleQuery = conn.prepareTupleQuery( - QueryLanguage.SPARQL, query); -ValueFactory vf = ValueFactoryImpl.getInstance(); - -TupleQueryResultHandler writer = new SPARQLResultsXMLWriter(System.out); -tupleQuery.evaluate(new TupleQueryResultHandler() { - - int count = 0; - - @Override - public void startQueryResult(List<String> strings) throws TupleQueryResultHandlerException { - } - - @Override - public void endQueryResult() throws TupleQueryResultHandlerException { - } - - @Override - public void handleSolution(BindingSet bindingSet) throws TupleQueryResultHandlerException { - System.out.println(bindingSet); - } -}); - -conn.close(); -myRepository.shutDown(); -``` -
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/markdown/quickstart.md ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/markdown/quickstart.md b/extras/rya.manual/src/site/markdown/quickstart.md deleted file mode 100644 index 4f0aa05..0000000 --- a/extras/rya.manual/src/site/markdown/quickstart.md +++ /dev/null @@ -1,62 +0,0 @@ - -<!-- - -[comment]: # Licensed to the Apache Software Foundation (ASF) under one -[comment]: # or more contributor license agreements. See the NOTICE file -[comment]: # distributed with this work for additional information -[comment]: # regarding copyright ownership. The ASF licenses this file -[comment]: # to you under the Apache License, Version 2.0 (the -[comment]: # "License"); you may not use this file except in compliance -[comment]: # with the License. You may obtain a copy of the License at -[comment]: # -[comment]: # http://www.apache.org/licenses/LICENSE-2.0 -[comment]: # -[comment]: # Unless required by applicable law or agreed to in writing, -[comment]: # software distributed under the License is distributed on an -[comment]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -[comment]: # KIND, either express or implied. See the License for the -[comment]: # specific language governing permissions and limitations -[comment]: # under the License. - ---> -# Quick Start - -This tutorial will outline the steps needed to get quickly started with the Rya store using the web based endpoint. - -## Prerequisites - -* Columnar Store (Accumulo) -* Rya code (Git: git://git.apache.org/incubator-rya.git) -* Maven 3.0 + - -## Building from Source - -Using Git, pull down the latest code from the url above. - -Run the command to build the code `mvn clean install` - -If all goes well, the build should be successful and a war should be produced in `web/web.rya/target/web.rya.war` - -## Deployment Using Tomcat - -Unwar the above war into the webapps directory. - -To point the web.rya war to the appropriate Accumulo instance, make a properties file `environment.properties` and put it in the classpath. Here is an example: - -``` -instance.name=accumulo #Accumulo instance name -instance.zk=localhost:2181 #Accumulo Zookeepers -instance.username=root #Accumulo username -instance.password=secret #Accumulo pwd -rya.tableprefix=triplestore_ #Rya Table Prefix -rya.displayqueryplan=true #To display the query plan -``` - -Start the Tomcat server. `./bin/startup.sh` - -## Usage - -First, we need to load data. See the [Load Data Section] (loaddata.md) - -Second, we need to query that data. See the [Query Data Section](querydata.md) - http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/markdown/sm-addauth.md ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/markdown/sm-addauth.md b/extras/rya.manual/src/site/markdown/sm-addauth.md deleted file mode 100644 index 2f32422..0000000 --- a/extras/rya.manual/src/site/markdown/sm-addauth.md +++ /dev/null @@ -1,119 +0,0 @@ - -<!-- - -[comment]: # Licensed to the Apache Software Foundation (ASF) under one -[comment]: # or more contributor license agreements. See the NOTICE file -[comment]: # distributed with this work for additional information -[comment]: # regarding copyright ownership. The ASF licenses this file -[comment]: # to you under the Apache License, Version 2.0 (the -[comment]: # "License"); you may not use this file except in compliance -[comment]: # with the License. You may obtain a copy of the License at -[comment]: # -[comment]: # http://www.apache.org/licenses/LICENSE-2.0 -[comment]: # -[comment]: # Unless required by applicable law or agreed to in writing, -[comment]: # software distributed under the License is distributed on an -[comment]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -[comment]: # KIND, either express or implied. See the License for the -[comment]: # specific language governing permissions and limitations -[comment]: # under the License. - ---> -# Add Authentication - -This tutorial will give a few examples on how to load and query data with authentication. - -This is only available for accumulo and Accumulo because they provide the security filters necessary to do row level authentication and visibility. - -## Load Data with Visibilities - -During the Load process, there are a few ways to set the Column Visibility you want set on each of the corresponding rdf rows. - -### Global Visibility - -You can set the Column Visibility globally on the RdfCloudTripleStore, and it will use that particular value for every row saved. - -To do this, once you create and set up the RdfCloudTripleStore, just set the property on the store configuration: - -``` JAVA -//setup -final RdfCloudTripleStore store = new RdfCloudTripleStore(); -AccumuloRyaDAO crdfdao = new AccumuloRyaDAO(); -crdfdao.setConnector(connector); - -AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); -conf.setTablePrefix("rts_"); -conf.setDisplayQueryPlan(true); - -//set global column Visibility -conf.setCv("AUTH1|AUTH2"); - -crdfdao.setConf(conf); -store.setRdfDao(crdfdao); -``` - -The format is simply the same as the Column Visibility format. - -### Per triple or document based Visibility - -TODO: Not available as of yet - -## Query Data with Authentication - -Attaching an Authentication to the query process is very simple. It requires just adding the property `RdfCloudTripleStoreConfiguration.CONF_QUERY_AUTH` to the query `BindingSet` -Example: - -``` JAVA -//setup -Connector connector = new ZooKeeperInstance("instance", "zoo1,zoo2,zoo3").getConnector("user", "password"); -final RdfCloudTripleStore store = new RdfCloudTripleStore(); -AccumuloRyaDAO crdfdao = new AccumuloRyaDAO(); -crdfdao.setConnector(connector); - -AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); -conf.setTablePrefix("rts_"); -conf.setDisplayQueryPlan(true); -crdfdao.setConf(conf); -//set global column Visibility -conf.setCv("1|2"); -store.setRdfDao(crdfdao); - -InferenceEngine inferenceEngine = new InferenceEngine(); -inferenceEngine.setRdfDao(crdfdao); -inferenceEngine.setConf(conf); -store.setInferenceEngine(inferenceEngine); - -Repository myRepository = new RyaSailRepository(store); -myRepository.initialize(); -RepositoryConnection conn = myRepository.getConnection(); - -//define and add statement -String litdupsNS = "urn:test:litdups#"; -URI cpu = vf.createURI(litdupsNS, "cpu"); -URI loadPerc = vf.createURI(litdupsNS, "loadPerc"); -URI uri1 = vf.createURI(litdupsNS, "uri1"); -conn.add(cpu, loadPerc, uri1); -conn.commit(); - -//query with auth -String query = "select * where {" + - "<" + cpu.toString() + "> ?p ?o1." + - "}"; -TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); -tupleQuery.setBinding(RdfCloudTripleStoreConfiguration.CONF_QUERY_AUTH, vf.createLiteral("2")); -TupleQueryResult result = tupleQuery.evaluate(); -while(result.hasNext()) { - System.out.println(result.next()); -} -result.close(); - -//close -conn.close(); -myRepository.shutDown(); -``` - -Or you can set a global auth using the configuration: - -``` JAVA -conf.setAuth("2") -``` \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/markdown/sm-firststeps.md ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/markdown/sm-firststeps.md b/extras/rya.manual/src/site/markdown/sm-firststeps.md deleted file mode 100644 index 34f995b..0000000 --- a/extras/rya.manual/src/site/markdown/sm-firststeps.md +++ /dev/null @@ -1,80 +0,0 @@ - -<!-- - -[comment]: # Licensed to the Apache Software Foundation (ASF) under one -[comment]: # or more contributor license agreements. See the NOTICE file -[comment]: # distributed with this work for additional information -[comment]: # regarding copyright ownership. The ASF licenses this file -[comment]: # to you under the Apache License, Version 2.0 (the -[comment]: # "License"); you may not use this file except in compliance -[comment]: # with the License. You may obtain a copy of the License at -[comment]: # -[comment]: # http://www.apache.org/licenses/LICENSE-2.0 -[comment]: # -[comment]: # Unless required by applicable law or agreed to in writing, -[comment]: # software distributed under the License is distributed on an -[comment]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -[comment]: # KIND, either express or implied. See the License for the -[comment]: # specific language governing permissions and limitations -[comment]: # under the License. - ---> -# Typical First Steps - -In this tutorial, I will give you a quick overview of some of the first steps I perform to get data loaded and read for query. - -## Prerequisites - - We are assuming Accumulo 1.5+ usage here. - - * Rya Source Code `web.rya.war`) - * Accumulo on top of Hadoop 0.20+ - * RDF Data (in N-Triples format, this format is the easiest to bulk load) - -## Building Source - -Skip this section if you already have the Map Reduce artifact and the WAR - -See the [Build From Source Section](build-source.md) to get the appropriate artifacts built - -## Load Data - -I find that the best way to load the data is through the Bulk Load Map Reduce job. - -* Save the RDF Data above onto HDFS. From now on we will refer to this location as `<RDF_HDFS_LOCATION>` -* Move the `accumulo.rya-<version>-job.jar` onto the hadoop cluster -* Bulk load the data. Here is a sample command line: - -``` -hadoop jar ../accumulo.rya-2.0.0-SNAPSHOT-job.jar BulkNtripsInputTool -Drdf.tablePrefix=lubm_ -Dcb.username=user -Dcb.pwd=cbpwd -Dcb.instance=instance -Dcb.zk=zookeeperLocation -Drdf.format=N-Triples <RDF_HDFS_LOCATION> -``` - -Once the data is loaded, it is actually a good practice to compact your tables. You can do this by opening the accumulo shell `shell` and running the `compact` command on the generated tables. Remember the generated tables will be prefixed by the `rdf.tablePrefix` property you assigned above. The default tablePrefix is `rts`. - -Here is a sample accumulo shell command: - -``` -compact -p lubm_(.*) -``` - -See the [Load Data Section](loaddata.md) for more options on loading rdf data - -## Run the Statistics Optimizer - -For the best query performance, it is recommended to run the Statistics Optimizer to create the Evaluation Statistics table. This job will read through your data and gather statistics on the distribution of the dataset. This table is then queried before query execution to reorder queries based on the data distribution. - -See the [Evaluation Statistics Table Section](eval.md) on how to do this. - -## Query data - -I find the easiest way to query is just to use the WAR. Load the WAR into your favorite web application container and go to the sparqlQuery.jsp page. Example: - -``` -http://localhost:8080/web.rya/sparqlQuery.jsp -``` - -This page provides a very simple text box for running queries against the store and getting data back. (SPARQL queries) - -Remember to update the connection information in the WAR: `WEB-INF/spring/spring-accumulo.xml` - -See the [Query data section](querydata.md) for more information. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/markdown/sm-infer.md ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/markdown/sm-infer.md b/extras/rya.manual/src/site/markdown/sm-infer.md deleted file mode 100644 index a2b0b66..0000000 --- a/extras/rya.manual/src/site/markdown/sm-infer.md +++ /dev/null @@ -1,353 +0,0 @@ - -<!-- - -[comment]: # Licensed to the Apache Software Foundation (ASF) under one -[comment]: # or more contributor license agreements. See the NOTICE file -[comment]: # distributed with this work for additional information -[comment]: # regarding copyright ownership. The ASF licenses this file -[comment]: # to you under the Apache License, Version 2.0 (the -[comment]: # "License"); you may not use this file except in compliance -[comment]: # with the License. You may obtain a copy of the License at -[comment]: # -[comment]: # http://www.apache.org/licenses/LICENSE-2.0 -[comment]: # -[comment]: # Unless required by applicable law or agreed to in writing, -[comment]: # software distributed under the License is distributed on an -[comment]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -[comment]: # KIND, either express or implied. See the License for the -[comment]: # specific language governing permissions and limitations -[comment]: # under the License. - ---> -# Inferencing - -Rya currently provides simple inferencing. The supported list of inferred relationships include: - -- rdfs:subClassOf -- rdfs:subPropertyOf -- owl:EquivalentProperty -- owl:inverseOf -- owl:SymmetricProperty -- owl:TransitiveProperty (This is currently in beta and will not work for every case) -- owl:sameAs - -## Setup - -The Inferencing Engine is a scheduled job that runs by default every 5 minutes, this is configurable, to query the relationships in the store and develop the inferred graphs necessary to answer inferencing questions. - -This also means that if you load a model into the store, it could take up to 5 minutes for the inferred relationships to be available. - -As usual you will need to set up your `RdfCloudTripleStore` with the correct DAO, notice we add an `InferencingEngine` as well to the store. If this is not added, then no inferencing will be done on the queries: - -``` JAVA -//setup -Connector connector = new ZooKeeperInstance("instance", "zoo1,zoo2,zoo3").getConnector("user", "password"); -final RdfCloudTripleStore store = new RdfCloudTripleStore(); -AccumuloRyaDAO crdfdao = new AccumuloRyaDAO(); -crdfdao.setConnector(connector); - -AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); -conf.setTablePrefix("rts_"); -conf.setDisplayQueryPlan(true); -crdfdao.setConf(conf); -store.setRdfDao(crdfdao); - -ProspectorServiceEvalStatsDAO evalDao = new ProspectorServiceEvalStatsDAO(connector, conf); -evalDao.init(); -store.setRdfEvalStatsDAO(evalDao); - -InferenceEngine inferenceEngine = new InferenceEngine(); -inferenceEngine.setRdfDao(crdfdao); -inferenceEngine.setConf(conf); -store.setInferenceEngine(inferenceEngine); - -Repository myRepository = new RyaSailRepository(store); -myRepository.initialize(); -RepositoryConnection conn = myRepository.getConnection(); - -//query code goes here - -//close -conn.close(); -myRepository.shutDown(); -``` - -## Samples - -We will go through some quick samples on loading inferred relationships, seeing and diagnosing the query plan, and checking the data - -### Rdfs:SubClassOf - -First the code, which will load the following subclassof relationship: `UndergraduateStudent subclassof Student subclassof Person`. Then we will load into the tables three triples defining `UgradA rdf:type UndergraduateStudent, StudentB rdf:type Student, PersonC rdf:type Person` - -``` JAVA -conn.add(new StatementImpl(vf.createURI(litdupsNS, "UndergraduateStudent"), RDFS.SUBCLASSOF, vf.createURI(litdupsNS, "Student"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "Student"), RDFS.SUBCLASSOF, vf.createURI(litdupsNS, "Person"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "UgradA"), RDF.TYPE, vf.createURI(litdupsNS, "UndergraduateStudent"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "StudentB"), RDF.TYPE, vf.createURI(litdupsNS, "Student"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "PersonC"), RDF.TYPE, vf.createURI(litdupsNS, "Person"))); -conn.commit(); -``` - -Remember that once the model is committed, it may take up to 5 minutes for the inferred relationships to be ready. Though you can override this property in the `InferencingEngine`. - -We shall run the following query: - -``` -PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> -PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> -PREFIX lit: <urn:test:litdups#> -select * where {?s rdf:type lit:Person.} -``` - -And should get back the following results: - -``` -[s=urn:test:litdups#StudentB] -[s=urn:test:litdups#PersonC] -[s=urn:test:litdups#UgradA] -``` - -#### How it works - -Let us look at the query plan: - -``` -QueryRoot - Projection - ProjectionElemList - ProjectionElem "s" - Join - FixedStatementPattern - Var (name=79f261ee-e930-4af1-bc09-e637cc0affef) - Var (name=c-79f261ee-e930-4af1-bc09-e637cc0affef, value=http://www.w3.org/2000/01/rdf-schema#subClassOf) - Var (name=-const-2, value=urn:test:litdups#Person, anonymous) - DoNotExpandSP - Var (name=s) - Var (name=-const-1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#type, anonymous) - Var (name=79f261ee-e930-4af1-bc09-e637cc0affef) -``` - -Basically, we first find out (through the InferencingEngine) what triples have subclassof with Person. The InferencingEngine will do the graph analysis to find the both Student and UndergraduateStudent are Person classes. -Then this information is joined with the statement pattern `(?s rdf:type ?inf)` where `?inf` is the results from the InferencingEngine. - -### Rdfs:SubPropertyOf - -SubPropertyOf defines that a property can be an instance of another property. For example, a `gradDegreeFrom subPropertyOf degreeFrom`. - -Also, EquivalentProperty can be thought of as specialized SubPropertyOf relationship where if `propA equivalentProperty propB` then that means that `propA subPropertyOf propB AND propB subPropertyOf propA` - -Sample Code: - -``` JAVA -conn.add(new StatementImpl(vf.createURI(litdupsNS, "undergradDegreeFrom"), RDFS.SUBPROPERTYOF, vf.createURI(litdupsNS, "degreeFrom"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "gradDegreeFrom"), RDFS.SUBPROPERTYOF, vf.createURI(litdupsNS, "degreeFrom"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "degreeFrom"), RDFS.SUBPROPERTYOF, vf.createURI(litdupsNS, "memberOf"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "memberOf"), RDFS.SUBPROPERTYOF, vf.createURI(litdupsNS, "associatedWith"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "UgradA"), vf.createURI(litdupsNS, "undergradDegreeFrom"), vf.createURI(litdupsNS, "Harvard"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "GradB"), vf.createURI(litdupsNS, "gradDegreeFrom"), vf.createURI(litdupsNS, "Yale"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "ProfessorC"), vf.createURI(litdupsNS, "memberOf"), vf.createURI(litdupsNS, "Harvard"))); -conn.commit(); -``` - -With query: - -``` -PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> -PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> -PREFIX lit: <urn:test:litdups#> -select * where {?s lit:memberOf lit:Harvard.} -``` - -Will return results: - -``` -[s=urn:test:litdups#UgradA] -[s=urn:test:litdups#ProfessorC] -``` - -Since UgradA has undergraduateDegreeFrom Harvard and ProfessorC is memberOf Harvard. - -#### How it works - -This is very similar to the subClassOf relationship above. Basically the InferencingEngine provides what properties are subPropertyOf relationships with memberOf, and the second part of the Join checks to see if those properties are predicates with object "Harvard". - -Query Plan: - -``` -QueryRoot - Projection - ProjectionElemList - ProjectionElem "s" - Join - FixedStatementPattern - Var (name=0bad69f3-4769-4293-8318-e828b23dc52a) - Var (name=c-0bad69f3-4769-4293-8318-e828b23dc52a, value=http://www.w3.org/2000/01/rdf-schema#subPropertyOf) - Var (name=-const-1, value=urn:test:litdups#memberOf, anonymous) - DoNotExpandSP - Var (name=s) - Var (name=0bad69f3-4769-4293-8318-e828b23dc52a) - Var (name=-const-2, value=urn:test:litdups#Harvard, anonymous) -``` - -### InverseOf - -InverseOf defines a property that is an inverse relation of another property. For example, a student who has a `degreeFrom` a University also means that the University `hasAlumnus` student. - -Code: - -``` JAVA -conn.add(new StatementImpl(vf.createURI(litdupsNS, "degreeFrom"), OWL.INVERSEOF, vf.createURI(litdupsNS, "hasAlumnus"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "UgradA"), vf.createURI(litdupsNS, "degreeFrom"), vf.createURI(litdupsNS, "Harvard"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "GradB"), vf.createURI(litdupsNS, "degreeFrom"), vf.createURI(litdupsNS, "Harvard"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "Harvard"), vf.createURI(litdupsNS, "hasAlumnus"), vf.createURI(litdupsNS, "AlumC"))); -conn.commit(); -``` - -Query: - -``` -PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> -PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> -PREFIX lit: <urn:test:litdups#> -select * where {lit:Harvard lit:hasAlumnus ?s.} -``` - -Result: - -``` -[s=urn:test:litdups#AlumC] -[s=urn:test:litdups#GradB] -[s=urn:test:litdups#UgradA] -``` - -#### How it works - -The query planner will expand the statement pattern `Harvard hasAlumnus ?s` to a Union between `Harvard hasAlumnus ?s. and ?s degreeFrom Harvard` - -As a caveat, it is important to note that in general Union queries do not have the best performance, so having a property that has an inverseOf and subPropertyOf, could cause a query plan that might take long depending on how the query planner orders the joins. - -Query Plan - -``` -QueryRoot - Projection - ProjectionElemList - ProjectionElem "s" - InferUnion - StatementPattern - Var (name=-const-1, value=urn:test:litdups#Harvard, anonymous) - Var (name=-const-2, value=urn:test:litdups#hasAlumnus, anonymous) - Var (name=s) - StatementPattern - Var (name=s) - Var (name=-const-2, value=urn:test:litdups#degreeFrom) - Var (name=-const-1, value=urn:test:litdups#Harvard, anonymous) -``` - -### SymmetricProperty - -SymmetricProperty defines a relationship where, for example, if Bob is a friendOf Jeff, then Jeff is a friendOf Bob. (Hopefully) - -Code: - -``` JAVA -conn.add(new StatementImpl(vf.createURI(litdupsNS, "friendOf"), RDF.TYPE, OWL.SYMMETRICPROPERTY)); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "Bob"), vf.createURI(litdupsNS, "friendOf"), vf.createURI(litdupsNS, "Jeff"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "James"), vf.createURI(litdupsNS, "friendOf"), vf.createURI(litdupsNS, "Jeff"))); -conn.commit(); -``` - -Query: - -``` -PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> -PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> -PREFIX lit: <urn:test:litdups#> -select * where {?s lit:friendOf lit:Bob.} -``` - -Results: - -``` -[s=urn:test:litdups#Jeff] -``` - -#### How it works - -The query planner will recognize that `friendOf` is a SymmetricProperty and devise a Union to find the specified relationship and inverse. - -Query Plan: - -``` -QueryRoot - Projection - ProjectionElemList - ProjectionElem "s" - InferUnion - StatementPattern - Var (name=s) - Var (name=-const-1, value=urn:test:litdups#friendOf, anonymous) - Var (name=-const-2, value=urn:test:litdups#Bob, anonymous) - StatementPattern - Var (name=-const-2, value=urn:test:litdups#Bob, anonymous) - Var (name=-const-1, value=urn:test:litdups#friendOf, anonymous) - Var (name=s) -``` - -### TransitiveProperty - -TransitiveProperty provides a transitive relationship between resources. For example, if Queens is subRegionOf NYC and NYC is subRegionOf NY, then Queens is transitively a subRegionOf NY. - -Code: - -``` JAVA -conn.add(new StatementImpl(vf.createURI(litdupsNS, "subRegionOf"), RDF.TYPE, OWL.TRANSITIVEPROPERTY)); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "Queens"), vf.createURI(litdupsNS, "subRegionOf"), vf.createURI(litdupsNS, "NYC"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "NYC"), vf.createURI(litdupsNS, "subRegionOf"), vf.createURI(litdupsNS, "NY"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "NY"), vf.createURI(litdupsNS, "subRegionOf"), vf.createURI(litdupsNS, "US"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "US"), vf.createURI(litdupsNS, "subRegionOf"), vf.createURI(litdupsNS, "NorthAmerica"))); -conn.add(new StatementImpl(vf.createURI(litdupsNS, "NorthAmerica"), vf.createURI(litdupsNS, "subRegionOf"), vf.createURI(litdupsNS, "World"))); -conn.commit(); -``` - -Query: - -``` -PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> -PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> -PREFIX lit: <urn:test:litdups#> -select * where {?s lit:subRegionOf lit:NorthAmerica.} -``` - -Results: - -``` -[s=urn:test:litdups#Queens] -[s=urn:test:litdups#NYC] -[s=urn:test:litdups#NY] -[s=urn:test:litdups#US] -``` - -#### How it works - -The TransitiveProperty relationship works by running recursive queries till all the results are returned. - -It is important to note that certain TransitiveProperty relationships will not work: -* Open ended property: ?s subRegionOf ?o (At least one of the properties must be filled or will be filled as the query gets answered) -* Closed property: Queens subRegionOf NY (At least one of the properties must be empty) - -We are working on fixing these issues. - -Query Plan: - -``` -QueryRoot - Projection - ProjectionElemList - ProjectionElem "s" - TransitivePropertySP - Var (name=s) - Var (name=-const-1, value=urn:test:litdups#subRegionOf, anonymous) - Var (name=-const-2, value=urn:test:litdups#NorthAmerica, anonymous) -``` \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/markdown/sm-namedgraph.md ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/markdown/sm-namedgraph.md b/extras/rya.manual/src/site/markdown/sm-namedgraph.md deleted file mode 100644 index 6826345..0000000 --- a/extras/rya.manual/src/site/markdown/sm-namedgraph.md +++ /dev/null @@ -1,157 +0,0 @@ - -<!-- - -[comment]: # Licensed to the Apache Software Foundation (ASF) under one -[comment]: # or more contributor license agreements. See the NOTICE file -[comment]: # distributed with this work for additional information -[comment]: # regarding copyright ownership. The ASF licenses this file -[comment]: # to you under the Apache License, Version 2.0 (the -[comment]: # "License"); you may not use this file except in compliance -[comment]: # with the License. You may obtain a copy of the License at -[comment]: # -[comment]: # http://www.apache.org/licenses/LICENSE-2.0 -[comment]: # -[comment]: # Unless required by applicable law or agreed to in writing, -[comment]: # software distributed under the License is distributed on an -[comment]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -[comment]: # KIND, either express or implied. See the License for the -[comment]: # specific language governing permissions and limitations -[comment]: # under the License. - ---> -# Named Graphs - -Named graphs are supported simply in the Rdf Store in a few ways. OpenRdf supports sending `contexts` as each triple is saved. - -## Simple Named Graph Load and Query - -Here is a very simple example of using the API to Insert data in named graphs and querying with Sparql - -First we will define a Trig document to load -Trig document - -``` -@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" . - :Monica ex:homepage <http://www.monicamurphy.org> . - :Monica ex:email <mailto:[email protected]> . - :Monica ex:hasSkill ex:Management } - -:G2 { :Monica rdf:type ex:Person . - :Monica ex:hasSkill ex:Programming } - -:G4 { :Phobe ex:name "Phobe Buffet" } - -:G3 { :G1 swp:assertedBy _:w1 . - _:w1 swp:authority :Chris . - _:w1 dc:date "2003-10-02"^^xsd:date . - :G2 swp:quotedBy _:w2 . - :G4 swp:assertedBy _:w2 . - _:w2 dc:date "2003-09-03"^^xsd:date . - _:w2 swp:authority :Tom . - :Chris rdf:type ex:Person . - :Chris ex:email <mailto:[email protected]>. - :Tom rdf:type ex:Person . - :Tom ex:email <mailto:[email protected]>} -``` - -We will assume that this file is saved on your classpath somewhere at `<TRIG_FILE>` - -Load data through API: - -``` JAVA -InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("namedgraphs.trig"); -RepositoryConnection conn = repository.getConnection(); -conn.add(stream, "", RDFFormat.TRIG); -conn.commit(); -``` - -Now that the data is loaded we can easily query it. For example, we will query to find what `hasSkill` is defined in graph G2, and relate that to someone defined in G1. - -**Query:** - -``` -PREFIX ex: <http://www.example.org/exampleDocument#> -PREFIX voc: <http://www.example.org/vocabulary#> -PREFIX foaf: <http://xmlns.com/foaf/0.1/> -PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> - -SELECT * -WHERE -{ - GRAPH ex:G1 - { - ?m voc:name ?name ; - voc:homepage ?hp . - } . - GRAPH ex:G2 - { - ?m voc:hasSkill ?skill . - } . -} -``` - -**Results:** - -``` -[hp=http://www.monicamurphy.org;m=http://www.example.org/exampleDocument#Monica;skill=http://www.example.org/vocabulary#Programming;name="Monica Murphy"] -``` - -**Here is the Query Plan as well:** - -``` -QueryRoot - Projection - ProjectionElemList - ProjectionElem "m" - ProjectionElem "name" - ProjectionElem "hp" - ProjectionElem "skill" - Join - Join - StatementPattern FROM NAMED CONTEXT - Var (name=m) - Var (name=-const-2, value=http://www.example.org/vocabulary#name, anonymous) - Var (name=name) - Var (name=-const-1, value=http://www.example.org/exampleDocument#G1, anonymous) - StatementPattern FROM NAMED CONTEXT - Var (name=m) - Var (name=-const-3, value=http://www.example.org/vocabulary#homepage, anonymous) - Var (name=hp) - Var (name=-const-1, value=http://www.example.org/exampleDocument#G1, anonymous) - StatementPattern FROM NAMED CONTEXT - Var (name=m) - Var (name=-const-5, value=http://www.example.org/vocabulary#hasSkill, anonymous) - Var (name=skill) - Var (name=-const-4, value=http://www.example.org/exampleDocument#G2, anonymous) -``` - -## Inserting named graph data through Sparql - -The new Sparql update standard provides another way to insert data, even into named graphs. - -First the insert update: - -``` -PREFIX dc: <http://purl.org/dc/elements/1.1/> -PREFIX ex: <http://example/addresses#> -INSERT DATA -{ - GRAPH ex:G1 { - <http://example/book3> dc:title "A new book" ; - dc:creator "A.N.Other" . - } -} -``` - -To perform this update, it requires different code than querying the data directly: - -``` -Update update = conn.prepareUpdate(QueryLanguage.SPARQL, insert); -update.execute(); -``` \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/markdown/sm-simpleaqr.md ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/markdown/sm-simpleaqr.md b/extras/rya.manual/src/site/markdown/sm-simpleaqr.md deleted file mode 100644 index cb8f068..0000000 --- a/extras/rya.manual/src/site/markdown/sm-simpleaqr.md +++ /dev/null @@ -1,75 +0,0 @@ - -<!-- - -[comment]: # Licensed to the Apache Software Foundation (ASF) under one -[comment]: # or more contributor license agreements. See the NOTICE file -[comment]: # distributed with this work for additional information -[comment]: # regarding copyright ownership. The ASF licenses this file -[comment]: # to you under the Apache License, Version 2.0 (the -[comment]: # "License"); you may not use this file except in compliance -[comment]: # with the License. You may obtain a copy of the License at -[comment]: # -[comment]: # http://www.apache.org/licenses/LICENSE-2.0 -[comment]: # -[comment]: # Unless required by applicable law or agreed to in writing, -[comment]: # software distributed under the License is distributed on an -[comment]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -[comment]: # KIND, either express or implied. See the License for the -[comment]: # specific language governing permissions and limitations -[comment]: # under the License. - ---> -# Simple Add Query and Remove of Statements - -This quick tutorial will give a small example on how to add, query, and remove statements from Rya - -## Code - -``` JAVA -//setup -Connector connector = new ZooKeeperInstance("instance", "zoo1,zoo2,zoo3").getConnector("user", "password"); -final RdfCloudTripleStore store = new RdfCloudTripleStore(); -AccumuloRyaDAO crdfdao = new AccumuloRyaDAO(); -crdfdao.setConnector(connector); - -AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); -conf.setTablePrefix("rts_"); -conf.setDisplayQueryPlan(true); -crdfdao.setConf(conf); -store.setRdfDao(crdfdao); - -ProspectorServiceEvalStatsDAO evalDao = new ProspectorServiceEvalStatsDAO(connector, conf); -evalDao.init(); -store.setRdfEvalStatsDAO(evalDao); - -InferenceEngine inferenceEngine = new InferenceEngine(); -inferenceEngine.setRdfDao(crdfdao); -inferenceEngine.setConf(conf); -store.setInferenceEngine(inferenceEngine); - -Repository myRepository = new RyaSailRepository(store); -myRepository.initialize(); -RepositoryConnection conn = myRepository.getConnection(); - -//define and add statement -String litdupsNS = "urn:test:litdups#"; -URI cpu = vf.createURI(litdupsNS, "cpu"); -URI loadPerc = vf.createURI(litdupsNS, "loadPerc"); -URI uri1 = vf.createURI(litdupsNS, "uri1"); -conn.add(cpu, loadPerc, uri1); -conn.commit(); - -//query for all statements that have subject=cpu and pred=loadPerc (wildcard object) -RepositoryResult<Statement> result = conn.getStatements(cpu, loadPerc, null, true) -while(result.hasNext()) { - System.out.println(result.next()); -} -result.close(); - -//remove statement -conn.remove(cpu, loadPerc, uri1); - -//close -conn.close(); -myRepository.shutDown(); -``` \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/markdown/sm-sparqlquery.md ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/markdown/sm-sparqlquery.md b/extras/rya.manual/src/site/markdown/sm-sparqlquery.md deleted file mode 100644 index 639ca02..0000000 --- a/extras/rya.manual/src/site/markdown/sm-sparqlquery.md +++ /dev/null @@ -1,79 +0,0 @@ - -<!-- - -[comment]: # Licensed to the Apache Software Foundation (ASF) under one -[comment]: # or more contributor license agreements. See the NOTICE file -[comment]: # distributed with this work for additional information -[comment]: # regarding copyright ownership. The ASF licenses this file -[comment]: # to you under the Apache License, Version 2.0 (the -[comment]: # "License"); you may not use this file except in compliance -[comment]: # with the License. You may obtain a copy of the License at -[comment]: # -[comment]: # http://www.apache.org/licenses/LICENSE-2.0 -[comment]: # -[comment]: # Unless required by applicable law or agreed to in writing, -[comment]: # software distributed under the License is distributed on an -[comment]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -[comment]: # KIND, either express or implied. See the License for the -[comment]: # specific language governing permissions and limitations -[comment]: # under the License. - ---> -# Simple Add Query and Remove of Statements - -This quick tutorial will give a small example on how to query data with SPARQL - -## Code - -``` JAVA -//setup -Connector connector = new ZooKeeperInstance("instance", "zoo1,zoo2,zoo3").getConnector("user", "password"); -final RdfCloudTripleStore store = new RdfCloudTripleStore(); -AccumuloRyaDAO crdfdao = new AccumuloRyaDAO(); -crdfdao.setConnector(connector); - -AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); -conf.setTablePrefix("rts_"); -conf.setDisplayQueryPlan(true); -crdfdao.setConf(conf); -store.setRdfDao(crdfdao); - -ProspectorServiceEvalStatsDAO evalDao = new ProspectorServiceEvalStatsDAO(connector, conf); -evalDao.init(); -store.setRdfEvalStatsDAO(evalDao); - -InferenceEngine inferenceEngine = new InferenceEngine(); -inferenceEngine.setRdfDao(crdfdao); -inferenceEngine.setConf(conf); -store.setInferenceEngine(inferenceEngine); - -Repository myRepository = new RyaSailRepository(store); -myRepository.initialize(); -RepositoryConnection conn = myRepository.getConnection(); - -//define and add statements -String litdupsNS = "urn:test:litdups#"; -URI cpu = vf.createURI(litdupsNS, "cpu"); -URI loadPerc = vf.createURI(litdupsNS, "loadPerc"); -URI uri1 = vf.createURI(litdupsNS, "uri1"); -URI pred2 = vf.createURI(litdupsNS, "pred2"); -URI uri2 = vf.createURI(litdupsNS, "uri2"); -conn.add(cpu, loadPerc, uri1); -conn.commit(); - -//query using sparql -String query = "select * where {" + - "?x <" + loadPerc.stringValue() + "> ?o1." + - "?x <" + pred2.stringValue() + "> ?o2." + - "}"; -TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); -TupleQueryResult result = tupleQuery.evaluate(); -while(result.hasNext()) { - System.out.println(result.next()); -} -result.close(); - -//close -conn.close(); -myRepository.shutDown(); -``` \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/markdown/sm-updatedata.md ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/markdown/sm-updatedata.md b/extras/rya.manual/src/site/markdown/sm-updatedata.md deleted file mode 100644 index f0fe664..0000000 --- a/extras/rya.manual/src/site/markdown/sm-updatedata.md +++ /dev/null @@ -1,83 +0,0 @@ - -<!-- - -[comment]: # Licensed to the Apache Software Foundation (ASF) under one -[comment]: # or more contributor license agreements. See the NOTICE file -[comment]: # distributed with this work for additional information -[comment]: # regarding copyright ownership. The ASF licenses this file -[comment]: # to you under the Apache License, Version 2.0 (the -[comment]: # "License"); you may not use this file except in compliance -[comment]: # with the License. You may obtain a copy of the License at -[comment]: # -[comment]: # http://www.apache.org/licenses/LICENSE-2.0 -[comment]: # -[comment]: # Unless required by applicable law or agreed to in writing, -[comment]: # software distributed under the License is distributed on an -[comment]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -[comment]: # KIND, either express or implied. See the License for the -[comment]: # specific language governing permissions and limitations -[comment]: # under the License. - ---> -# Sparql Update - -OpenRDF supports the Sparql Update functionality. Here are a few samples: - -Remember, you have to use `RepositoryConnection.prepareUpdate(..)` to perform these queries - -**Insert:** - -``` -PREFIX dc: <http://purl.org/dc/elements/1.1/> -INSERT DATA -{ <http://example/book3> dc:title "A new book" ; - dc:creator "A.N.Other" . -} -``` - -**Delete:** - -``` -PREFIX dc: <http://purl.org/dc/elements/1.1/> -DELETE DATA -{ <http://example/book3> dc:title "A new book" ; - dc:creator "A.N.Other" . -} -``` - -**Update:** - -``` -PREFIX dc: <http://purl.org/dc/elements/1.1/> -DELETE { ?book dc:title ?title } -INSERT { ?book dc:title "A newer book". ?book dc:add "Additional Info" } -WHERE - { ?book dc:creator "A.N.Other" . - } -``` - -**Insert Named Graph:** - -``` -PREFIX dc: <http://purl.org/dc/elements/1.1/> -PREFIX ex: <http://example/addresses#> -INSERT DATA -{ GRAPH ex:G1 { -<http://example/book3> dc:title "A new book" ; - dc:creator "A.N.Other" . -} -} -``` - -**Update Named Graph:** - -``` -PREFIX dc: <http://purl.org/dc/elements/1.1/> -WITH <http://example/addresses#G1> -DELETE { ?book dc:title ?title } -INSERT { ?book dc:title "A newer book". - ?book dc:add "Additional Info" } -WHERE - { ?book dc:creator "A.N.Other" . - } -``` http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/resources/js/fixmarkdownlinks.js ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/resources/js/fixmarkdownlinks.js b/extras/rya.manual/src/site/resources/js/fixmarkdownlinks.js deleted file mode 100644 index 7fe8834..0000000 --- a/extras/rya.manual/src/site/resources/js/fixmarkdownlinks.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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. - */ - -window.onload = function() { - var anchors = document.getElementsByTagName("a"); - for (var i = 0; i < anchors.length; i++) { - anchors[i].href = anchors[i].href.replace(/\.md$/,'\.html'); - } - } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.manual/src/site/site.xml ---------------------------------------------------------------------- diff --git a/extras/rya.manual/src/site/site.xml b/extras/rya.manual/src/site/site.xml deleted file mode 100644 index a671d3d..0000000 --- a/extras/rya.manual/src/site/site.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> - -<!-- -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. ---> - -<project name="Maven"> - <skin> - <groupId>org.apache.maven.skins</groupId> - <artifactId>maven-fluido-skin</artifactId> - <version>1.4</version> - </skin> - <custom> - <fluidoSkin> - <topBarEnabled>false</topBarEnabled> - <sideBarEnabled>true</sideBarEnabled> - <sourceLineNumbersEnabled>false</sourceLineNumbersEnabled> - </fluidoSkin> - </custom> - - <body> - <head> - <script src="./js/fixmarkdownlinks.js" type="text/javascript"></script> - </head> - <menu name="Rya"> - <item name="Overview" href="overview.html"/> - <item name="Quick Start" href="quickstart.html"/> - <item name="Load Data" href="loaddata.html"/> - <item name="Query Data" href="querydata.html"/> - <item name="Evaluation Table" href="eval.html"/> - <item name="Pre-computed Joins" href="loadPrecomputedJoin.html"/> - <item name="Inferencing" href="infer.html"/> - </menu> - - <menu name="Samples"> - <item name="Typical First Steps" href="sm-firststeps.html"/> - <item name="Simple Add/Query/Remove Statements" href="sm-simpleaqr.html"/> - <item name="Sparql query" href="sm-sparqlquery.html"/> - <item name="Adding Authentication" href="sm-addauth.html"/> - <item name="Inferencing" href="sm-infer.html"/> - <item name="Named Graph" href="sm-namedgraph.html"/> - <item name="Update data" href="sm-updatedata.html"/> - <item name="Alx" href="alx.html"/> - </menu> - - <menu name="Development"> - <item name="Building From Source" href="build-source.html"/> - </menu> - </body> -</project> http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/pom.xml ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/pom.xml b/extras/rya.prospector/pom.xml deleted file mode 100644 index a9b5c61..0000000 --- a/extras/rya.prospector/pom.xml +++ /dev/null @@ -1,109 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.rya</groupId> - <artifactId>rya.extras</artifactId> - <version>3.2.10-SNAPSHOT</version> - </parent> - - <artifactId>rya.prospector</artifactId> - <name>Apache Rya Prospector</name> - - <dependencies> - <dependency> - <groupId>org.apache.rya</groupId> - <artifactId>rya.api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.rya</groupId> - <artifactId>accumulo.rya</artifactId> - </dependency> - - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.mrunit</groupId> - <artifactId>mrunit</artifactId> - <classifier>hadoop2</classifier> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <compilerId>groovy-eclipse-compiler</compilerId> - </configuration> - <dependencies> - <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-eclipse-compiler</artifactId> - <version>2.9.1-01</version> - </dependency> - <!-- for 2.8.0-01 and later you must have an explicit - dependency on groovy-eclipse-batch --> - <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-eclipse-batch</artifactId> - <version>2.3.7-01</version> - </dependency> - </dependencies> - </plugin> - <plugin> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-eclipse-compiler</artifactId> - <version>2.9.1-01</version> - <extensions>true</extensions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-shade-plugin</artifactId> - <executions> - <execution> - <configuration> - <shadedArtifactAttached>true</shadedArtifactAttached> - <shadedClassifierName>map-reduce</shadedClassifierName> - <transformers> - <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> - </transformers> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/IndexEntry.groovy ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/IndexEntry.groovy b/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/IndexEntry.groovy deleted file mode 100644 index 6017da4..0000000 --- a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/IndexEntry.groovy +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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. - */ - -package mvm.rya.prospector.domain - -/** - * Date: 12/5/12 - * Time: 11:33 AM - */ -class IndexEntry { - def String index - def String data - def String dataType - def String tripleValueType - def String visibility - def Long count - def Long timestamp - - @Override - public String toString() { - return "IndexEntry{" + - "index='" + index + '\'' + - ", data='" + data + '\'' + - ", dataType='" + dataType + '\'' + - ", tripleValueType=" + tripleValueType + - ", visibility='" + visibility + '\'' + - ", timestamp='" + timestamp + '\'' + - ", count=" + count + - '}'; - } - - boolean equals(o) { - if (this.is(o)) return true - if (getClass() != o.class) return false - - IndexEntry that = (IndexEntry) o - - if (count != that.count) return false - if (timestamp != that.timestamp) return false - if (data != that.data) return false - if (dataType != that.dataType) return false - if (index != that.index) return false - if (tripleValueType != that.tripleValueType) return false - if (visibility != that.visibility) return false - - return true - } - - int hashCode() { - int result - result = (index != null ? index.hashCode() : 0) - result = 31 * result + (data != null ? data.hashCode() : 0) - result = 31 * result + (dataType != null ? dataType.hashCode() : 0) - result = 31 * result + (tripleValueType != null ? tripleValueType.hashCode() : 0) - result = 31 * result + (visibility != null ? visibility.hashCode() : 0) - result = 31 * result + (count != null ? count.hashCode() : 0) - result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0) - return result - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/IntermediateProspect.groovy ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/IntermediateProspect.groovy b/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/IntermediateProspect.groovy deleted file mode 100644 index fadf6e8..0000000 --- a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/IntermediateProspect.groovy +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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. - */ - -package mvm.rya.prospector.domain - -import org.apache.hadoop.io.WritableComparable - -import static mvm.rya.prospector.domain.TripleValueType.* - -/** - * Date: 12/3/12 - * Time: 11:15 AM - */ -class IntermediateProspect implements WritableComparable<IntermediateProspect> { - - def String index - def String data - def String dataType - def TripleValueType tripleValueType - def String visibility - - @Override - int compareTo(IntermediateProspect t) { - if(!index.equals(t.index)) - return index.compareTo(t.index); - if(!data.equals(t.data)) - return data.compareTo(t.data); - if(!dataType.equals(t.dataType)) - return dataType.compareTo(t.dataType); - if(!tripleValueType.equals(t.tripleValueType)) - return tripleValueType.compareTo(t.tripleValueType); - if(!visibility.equals(t.visibility)) - return visibility.compareTo(t.visibility); - return 0 - } - - @Override - void write(DataOutput dataOutput) { - dataOutput.writeUTF(index); - dataOutput.writeUTF(data); - dataOutput.writeUTF(dataType); - dataOutput.writeUTF(tripleValueType.name()); - dataOutput.writeUTF(visibility); - } - - @Override - void readFields(DataInput dataInput) { - index = dataInput.readUTF() - data = dataInput.readUTF() - dataType = dataInput.readUTF() - tripleValueType = TripleValueType.valueOf(dataInput.readUTF()) - visibility = dataInput.readUTF() - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/TripleValueType.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/TripleValueType.java b/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/TripleValueType.java deleted file mode 100644 index 183b0d2..0000000 --- a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/domain/TripleValueType.java +++ /dev/null @@ -1,26 +0,0 @@ -package mvm.rya.prospector.domain; - -/* - * 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. - */ - - -public enum TripleValueType { - - subject, predicate, object, entity, subjectpredicate, predicateobject, subjectobject -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/Prospector.groovy ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/Prospector.groovy b/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/Prospector.groovy deleted file mode 100644 index 6c4a055..0000000 --- a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/Prospector.groovy +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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. - */ - -package mvm.rya.prospector.mr - -import mvm.rya.prospector.utils.ProspectorUtils -import org.apache.accumulo.core.data.Mutation -import org.apache.accumulo.core.data.Value -import org.apache.accumulo.core.security.ColumnVisibility -import org.apache.hadoop.conf.Configured -import org.apache.hadoop.util.Tool -import org.apache.hadoop.util.ToolRunner -import org.apache.hadoop.conf.Configuration -import org.apache.hadoop.fs.Path -import org.apache.hadoop.mapreduce.Job - -import org.apache.hadoop.io.LongWritable -import org.apache.commons.lang.time.DateUtils - -import mvm.rya.prospector.domain.IntermediateProspect - -import com.google.common.collect.Lists - -import static mvm.rya.prospector.utils.ProspectorConstants.* -import static mvm.rya.prospector.utils.ProspectorUtils.* - -/** - * Date: 12/3/12 - * Time: 10:57 AM - */ -class Prospector extends Configured implements Tool { - - private static long NOW = System.currentTimeMillis(); - - private Date truncatedDate; - - public static void main(String[] args) { - int res = ToolRunner.run(new Prospector(), args); - System.exit(res); - } - - @Override - int run(String[] args) { - Configuration conf = getConf(); - - truncatedDate = DateUtils.truncate(new Date(NOW), Calendar.MINUTE); - - Path configurationPath = new Path(args[0]); - conf.addResource(configurationPath); - - def inTable = conf.get("prospector.intable") - def outTable = conf.get("prospector.outtable") - def auths_str = conf.get("prospector.auths") - assert inTable != null - assert outTable != null - assert auths_str != null - - Job job = new Job(getConf(), this.getClass().getSimpleName() + "_" + System.currentTimeMillis()); - job.setJarByClass(this.getClass()); - - String[] auths = auths_str.split(",") - ProspectorUtils.initMRJob(job, inTable, outTable, auths) - - job.getConfiguration().setLong("DATE", NOW); - - def performant = conf.get(PERFORMANT) - if (Boolean.parseBoolean(performant)) { - /** - * Apply some performance tuning - */ - ProspectorUtils.addMRPerformance(job.configuration) - } - - job.setMapOutputKeyClass(IntermediateProspect.class); - job.setMapOutputValueClass(LongWritable.class); - - job.setMapperClass(ProspectorMapper.class); - job.setCombinerClass(ProspectorCombiner.class); - job.setReducerClass(ProspectorReducer.class); - job.waitForCompletion(true); - - int success = job.isSuccessful() ? 0 : 1; - - if (success == 0) { - Mutation m = new Mutation(METADATA) - m.put(PROSPECT_TIME, getReverseIndexDateTime(truncatedDate), new ColumnVisibility(DEFAULT_VIS), truncatedDate.time, new Value(EMPTY)) - writeMutations(connector(instance(conf), conf), outTable, [m]) - } - - return success - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorCombiner.groovy ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorCombiner.groovy b/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorCombiner.groovy deleted file mode 100644 index fe1c5b2..0000000 --- a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorCombiner.groovy +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -package mvm.rya.prospector.mr - -import mvm.rya.prospector.plans.IndexWorkPlan -import mvm.rya.prospector.plans.IndexWorkPlanManager -import mvm.rya.prospector.plans.impl.ServicesBackedIndexWorkPlanManager -import org.apache.commons.lang.time.DateUtils -import org.apache.hadoop.mapreduce.Reducer -import mvm.rya.prospector.utils.ProspectorUtils - -/** - * Date: 12/3/12 - * Time: 11:06 AM - */ -class ProspectorCombiner extends Reducer { - - private Date truncatedDate; - private IndexWorkPlanManager manager = new ServicesBackedIndexWorkPlanManager() - Map<String, IndexWorkPlan> plans - - @Override - public void setup(Reducer.Context context) throws IOException, InterruptedException { - super.setup(context); - - long now = context.getConfiguration().getLong("DATE", System.currentTimeMillis()); - truncatedDate = DateUtils.truncate(new Date(now), Calendar.MINUTE); - - this.plans = ProspectorUtils.planMap(manager.plans) - } - - @Override - protected void reduce(def prospect, Iterable values, Reducer.Context context) { - def plan = plans.get(prospect.index) - if (plan != null) { - def coll = plan.combine(prospect, values) - if (coll != null) { - coll.each { entry -> - context.write(entry.key, entry.value) - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorMapper.groovy ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorMapper.groovy b/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorMapper.groovy deleted file mode 100644 index 18fa32b..0000000 --- a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorMapper.groovy +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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. - */ - -package mvm.rya.prospector.mr - -import mvm.rya.accumulo.AccumuloRdfConfiguration -import mvm.rya.api.RdfCloudTripleStoreConstants -import mvm.rya.api.domain.RyaStatement -import mvm.rya.api.resolver.RyaTripleContext -import mvm.rya.api.resolver.triple.TripleRow -import mvm.rya.prospector.plans.IndexWorkPlan -import mvm.rya.prospector.plans.IndexWorkPlanManager -import mvm.rya.prospector.plans.impl.ServicesBackedIndexWorkPlanManager - -import org.apache.commons.lang.time.DateUtils -import org.apache.hadoop.mapreduce.Mapper - -/** - * Date: 12/3/12 - * Time: 11:06 AM - */ -class ProspectorMapper extends Mapper { - - private Date truncatedDate; - private RyaTripleContext ryaContext; - private IndexWorkPlanManager manager = new ServicesBackedIndexWorkPlanManager() - private Collection<IndexWorkPlan> plans = manager.plans - - @Override - public void setup(Mapper.Context context) throws IOException, InterruptedException { - super.setup(context); - - long now = context.getConfiguration().getLong("DATE", System.currentTimeMillis()); - ryaContext = RyaTripleContext.getInstance(new AccumuloRdfConfiguration(context.getConfiguration())); - truncatedDate = DateUtils.truncate(new Date(now), Calendar.MINUTE); - } - - @Override - public void map(def row, def data, Mapper.Context context) { - RyaStatement ryaStatement = ryaContext.deserializeTriple(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO, - new TripleRow( - row.row.bytes, - row.columnFamily.bytes, - row.columnQualifier.bytes, - row.timestamp, - row.columnVisibility.bytes, - data.get() - ) - ) - plans.each { plan -> - def coll = plan.map(ryaStatement) - if (coll != null) { - coll.each { entry -> - context.write(entry.key, entry.value) - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorReducer.groovy ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorReducer.groovy b/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorReducer.groovy deleted file mode 100644 index 8b12aae..0000000 --- a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/mr/ProspectorReducer.groovy +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - -package mvm.rya.prospector.mr - -import mvm.rya.prospector.plans.IndexWorkPlan -import mvm.rya.prospector.plans.IndexWorkPlanManager -import mvm.rya.prospector.plans.impl.ServicesBackedIndexWorkPlanManager -import org.apache.commons.lang.time.DateUtils -import org.apache.hadoop.mapreduce.Reducer -import mvm.rya.prospector.utils.ProspectorUtils - -/** - * Date: 12/3/12 - * Time: 11:06 AM - */ -class ProspectorReducer extends Reducer { - - private Date truncatedDate; - private IndexWorkPlanManager manager = new ServicesBackedIndexWorkPlanManager() - Map<String, IndexWorkPlan> plans - - @Override - public void setup(Reducer.Context context) throws IOException, InterruptedException { - super.setup(context); - - def conf = context.getConfiguration() - long now = conf.getLong("DATE", System.currentTimeMillis()); - truncatedDate = DateUtils.truncate(new Date(now), Calendar.MINUTE); - - this.plans = ProspectorUtils.planMap(manager.plans) - } - - @Override - protected void reduce(def prospect, Iterable values, Reducer.Context context) { - def plan = plans.get(prospect.index) - if (plan != null) { - plan.reduce(prospect, values, truncatedDate, context) - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/plans/IndexWorkPlan.groovy ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/plans/IndexWorkPlan.groovy b/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/plans/IndexWorkPlan.groovy deleted file mode 100644 index d9ba719..0000000 --- a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/plans/IndexWorkPlan.groovy +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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. - */ - -package mvm.rya.prospector.plans - -import mvm.rya.api.domain.RyaStatement -import mvm.rya.prospector.domain.IntermediateProspect -import org.apache.hadoop.io.LongWritable -import org.apache.hadoop.mapreduce.Reducer -import org.openrdf.model.vocabulary.XMLSchema -import mvm.rya.prospector.domain.IndexEntry - -/** - * Date: 12/3/12 - * Time: 11:12 AM - */ -public interface IndexWorkPlan { - - public static final String URITYPE = XMLSchema.ANYURI.stringValue() - public static final LongWritable ONE = new LongWritable(1) - public static final String DELIM = "\u0000"; - - public Collection<Map.Entry<IntermediateProspect, LongWritable>> map(RyaStatement ryaStatement) - - public Collection<Map.Entry<IntermediateProspect, LongWritable>> combine(IntermediateProspect prospect, Iterable<LongWritable> counts); - - public void reduce(IntermediateProspect prospect, Iterable<LongWritable> counts, Date timestamp, Reducer.Context context) - - public String getIndexType() - - public String getCompositeValue(List<String> indices) - - public List<IndexEntry> query(def connector, String tableName, List<Long> prospectTimes, String type, String index, String dataType, String[] auths) - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/plans/IndexWorkPlanManager.groovy ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/plans/IndexWorkPlanManager.groovy b/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/plans/IndexWorkPlanManager.groovy deleted file mode 100644 index 555f84a..0000000 --- a/extras/rya.prospector/src/main/groovy/mvm/rya/prospector/plans/IndexWorkPlanManager.groovy +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -package mvm.rya.prospector.plans - -/** - * Date: 12/3/12 - * Time: 11:24 AM - */ -public interface IndexWorkPlanManager { - - public Collection<IndexWorkPlan> getPlans(); -}
