[ 
https://issues.apache.org/jira/browse/RYA-303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16119995#comment-16119995
 ] 

ASF GitHub Bot commented on RYA-303:
------------------------------------

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

    https://github.com/apache/incubator-rya/pull/172#discussion_r132173821
  
    --- Diff: 
extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjIndexSetProvider.java
 ---
    @@ -0,0 +1,125 @@
    +/*
    + * 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 org.apache.rya.indexing.mongodb.pcj;
    +
    +import static java.util.Objects.requireNonNull;
    +
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
    +import org.apache.rya.api.instance.RyaDetailsRepository;
    +import 
org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException;
    +import org.apache.rya.indexing.external.tupleSet.ExternalTupleSet;
    +import 
org.apache.rya.indexing.pcj.matching.provider.AbstractPcjIndexSetProvider;
    +import org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage;
    +import org.apache.rya.indexing.pcj.storage.accumulo.PcjTableNameFactory;
    +import org.apache.rya.indexing.pcj.storage.mongo.MongoPcjDocuments;
    +import org.apache.rya.indexing.pcj.storage.mongo.MongoPcjStorage;
    +import org.apache.rya.mongodb.MongoDBRdfConfiguration;
    +import org.apache.rya.mongodb.instance.MongoRyaInstanceDetailsRepository;
    +
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.mongodb.MongoClient;
    +
    +/**
    + * Implementation of {@link AbstractPcjIndexSetProvider} for MongoDB.
    + */
    +public class MongoPcjIndexSetProvider extends AbstractPcjIndexSetProvider {
    +    private final MongoClient client;
    +    private final MongoDBRdfConfiguration mongoConf;
    +
    +    public MongoPcjIndexSetProvider(final Configuration conf, final 
MongoClient client) {
    +        super(conf);
    +        this.client = client;
    +        mongoConf = new MongoDBRdfConfiguration(conf);
    +    }
    +
    +    public MongoPcjIndexSetProvider(final Configuration conf, final 
List<ExternalTupleSet> indices, final MongoClient client) {
    +        super(conf, indices);
    +        this.client = client;
    +        mongoConf = new MongoDBRdfConfiguration(conf);
    +    }
    +
    +    @Override
    +    protected List<ExternalTupleSet> getIndices() throws Exception {
    +        requireNonNull(conf);
    +        final MongoPcjDocuments pcjTables = new MongoPcjDocuments(client, 
mongoConf.getMongoDBName());
    +        final String pcjPrefix = 
requireNonNull(conf.get(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX));
    +        List<String> tables = null;
    +
    +        tables = mongoConf.getPcjTables();
    +        // this maps associates pcj table name with pcj sparql query
    +        final Map<String, String> indexTables = Maps.newLinkedHashMap();
    +
    +        try(final PrecomputedJoinStorage storage = new 
MongoPcjStorage(client, mongoConf.getMongoInstance(), null)) {
    +            final PcjTableNameFactory pcjFactory = new 
PcjTableNameFactory();
    +
    +            final boolean tablesProvided = tables != null && 
!tables.isEmpty();
    +
    +            if (tablesProvided) {
    +                // if tables provided, associate table name with sparql
    +                for (final String table : tables) {
    +                    indexTables.put(table, 
storage.getPcjMetadata(pcjFactory.getPcjId(table)).getSparql());
    +                }
    +            } else if (hasRyaDetails(mongoConf.getMongoDBName())) {
    +                // If this is a newer install of Rya, and it has PCJ 
Details,
    +                // then
    +                // use those.
    +                final List<String> ids = storage.listPcjs();
    +                for (final String id : ids) {
    +                    indexTables.put(pcjFactory.makeTableName(pcjPrefix, 
id), storage.getPcjMetadata(id).getSparql());
    +                }
    +            } else {
    +                // Otherwise figure it out by getting document IDs.
    +                tables = pcjTables.listPcjDocuments();
    +                for (final String table : tables) {
    +                    if (table.startsWith(pcjPrefix + "INDEX")) {
    +                        indexTables.put(table, 
pcjTables.getPcjMetadata(table).getSparql());
    +                    }
    +                }
    +            }
    +        }
    +
    +        // use table name sparql map (indexTables) to create {@link
    +        // AccumuloIndexSet}
    --- End diff --
    
    Why are you referencing AccumuloIndexSet here?  Is this a C&P job :)


> Mongo PCJ indexer support
> -------------------------
>
>                 Key: RYA-303
>                 URL: https://issues.apache.org/jira/browse/RYA-303
>             Project: Rya
>          Issue Type: Improvement
>            Reporter: Andrew Smith
>            Assignee: Andrew Smith
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to