You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@rya.apache.org by meiercaleb <gi...@git.apache.org> on 2017/08/22 00:01:08 UTC

[GitHub] incubator-rya pull request #155: Resolves Rya 271

Github user meiercaleb commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/155#discussion_r134358157
  
    --- Diff: extras/indexing/src/test/java/org/apache/rya/indexing/accumulo/customfunction/AccumuloCustomSparqlFunctionTest.java ---
    @@ -0,0 +1,81 @@
    +package org.apache.rya.indexing.accumulo.customfunction;
    +
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * 
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + * 
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +import org.apache.rya.accumulo.AccumuloRdfConfiguration;
    +import org.apache.rya.indexing.accumulo.ConfigUtils;
    +import org.apache.rya.indexing.accumulo.freetext.SimpleTokenizer;
    +import org.apache.rya.indexing.accumulo.freetext.Tokenizer;
    +import org.apache.rya.sail.config.RyaSailFactory;
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.openrdf.query.QueryLanguage;
    +import org.openrdf.query.TupleQuery;
    +import org.openrdf.query.TupleQueryResult;
    +import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
    +import org.openrdf.repository.Repository;
    +import org.openrdf.repository.sail.SailRepository;
    +import org.openrdf.sail.Sail;
    +import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
    +import org.openrdf.repository.RepositoryConnection;
    +import org.junit.*;
    +
    +public class AccumuloCustomSparqlFunctionTest {
    +    private AccumuloRdfConfiguration conf;
    +    private Repository repository = null;
    +    private Sail sail = null;
    +    private RepositoryConnection conn = null;
    +
    +    @Before
    +    public void before() throws Exception {
    +        conf = new AccumuloRdfConfiguration();
    +        conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true);
    +        conf.set(AccumuloRdfConfiguration.CLOUDBASE_USER, "USERNAME");
    +        conf.set(AccumuloRdfConfiguration.CLOUDBASE_PASSWORD, "PASS");
    +        conf.set(RdfCloudTripleStoreConfiguration.CONF_QUERY_AUTH, "U");
    +        conf.setClass(ConfigUtils.TOKENIZER_CLASS, SimpleTokenizer.class, Tokenizer.class);
    +        conf.setTablePrefix("triplestore_");
    +
    +        this.sail = RyaSailFactory.getInstance(conf);
    +        this.repository = new SailRepository(this.sail);
    +        this.conn = this.repository.getConnection();
    +    }
    +
    +    @Test
    +    public void customFunction() {
    --- End diff --
    
    This test passes without incorporating the changes to the IndexingFunctionRegistry above, so there is no need to merge the changes.  I think that you have have confused the IndexingFunctionRegistry with the FunctionRegistry.
    The IndexingFunctionRegistry handles a very specific collection of "Filter Functions" that Rya uses for specific types of Indexing.   The reason I put "Filter Functions" in quotes is that an optimizer keys off of specific URIs that are passed in via SPARQL Filters.  These URIs are affiliated with specific indexes, and the IndexingFunctionRegistry is used to inform the optimizer which index to use based on the URI that is sees.  This particular subset of Functions that is tracked by the IndexingFunctionRegistry is not evaluated like normal RDF4J Functions.
    To register custom Functions with RDF4J (and Rya), you simply create the Function and register it with the FunctionRegistry, which you did in your test below.  That is all that is required, and your test passes without the above changes to the IndexingFunctionRegistry.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---