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

    https://github.com/apache/incubator-rya/pull/149#discussion_r136104402
  
    --- Diff: 
extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/temporal/AccumuloTemporalIndexer.java
 ---
    @@ -102,42 +103,50 @@
         private boolean isInit = false;
     
     
    +    /**
    +     * intilize the temporal index.
    +     * This is dependent on a few set method calls before init:
    +     * >  Connector = ConfigUtils.getConnector(conf);
    +     * >  MultiTableBatchWriter mtbw = 
connector.createMultiTableBatchWriter(new BatchWriterConfig());
    +     * >  // optional: temporal.setConnector(connector);
    +     * >  temporal.setMultiTableBatchWriter(mtbw);
    +     * >  temporal.init();
    +     */
    +    @Override
    +    public void init() {
    +        if (!isInit) {
    +            try {
    +                initInternal();
    +                isInit = true;
    +            } catch (final AccumuloException | AccumuloSecurityException | 
TableNotFoundException | TableExistsException | RyaClientException e) {
    +                logger.warn("Unable to initialize index.  Throwing Runtime 
Exception. ", e);
    +                throw new RuntimeException(e);
    +            }
    +        }
    +    }
     
         private void initInternal() throws AccumuloException, 
AccumuloSecurityException, TableNotFoundException,
    -            TableExistsException {
    +                    TableExistsException, RyaClientException {
    +        if (mtbw == null)
    +            throw new RyaClientException("Failed to initialize temporal 
index, setMultiTableBatchWriter() was not set.");
    +        if (conf == null)
    +            throw new RyaClientException("Failed to initialize temporal 
index, setConf() was not set.");
    +
             temporalIndexTableName = getTableName();
             // Create one index table on first run.
    -        ConfigUtils.createTableIfNotExists(conf, temporalIndexTableName);
    -
    -        mtbw = ConfigUtils.createMultitableBatchWriter(conf);
    -
    +        Boolean isCreated = ConfigUtils.createTableIfNotExists(conf, 
temporalIndexTableName);
    +        if (isCreated) {
    +            logger.info("First run, created temporal index table: " + 
temporalIndexTableName);
    +        }
             temporalIndexBatchWriter = 
mtbw.getBatchWriter(temporalIndexTableName);
    -
             validPredicates = ConfigUtils.getTemporalPredicates(conf);
         }
     
         //initialization occurs in setConf because index is created using 
reflection
         @Override
         public void setConf(final Configuration conf) {
             this.conf = conf;
    -        if (!isInit) {
    --- End diff --
    
    After looking at this a bit more, you are right.  I think this is the way 
to go.  I was confusing how we construct our Indexes with how we construct our 
optimizers.  I think this is fine.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to