/** * Instantiate a ResultToSolrMapper based on a configuration supplied through an input stream. * * @param indexName name of the index for which the mapper is to be created * @param indexerConf configuration containing the index definition * @return configured ResultToSolrMapper */ public static ResultToSolrMapper createResultToSolrMapper(String indexName, IndexerConf indexerConf) { ResultToSolrMapper mapper = null; try { if (indexerConf.getMapperClass().equals(DefaultResultToSolrMapper.class)) { // FIXME: this is cheating. Knowledge about mapper implementations should be handled by IndexerComponentFactory mapper = new DefaultResultToSolrMapper(indexName, indexerConf.getFieldDefinitions(), indexerConf.getDocumentExtractDefinitions()); } else { mapper = indexerConf.getMapperClass().newInstance(); ConfigureUtil.configure(mapper, indexerConf.getGlobalParams()); } } catch (Exception e) { LOG.error("Error instantiating ResultToSolrMapper for " + indexName, e); throw new RuntimeException(e); } return mapper; }
/** * Instantiate a ResultToSolrMapper based on a configuration supplied through an input stream. * * @param indexName name of the index for which the mapper is to be created * @param indexerConf configuration containing the index definition * @return configured ResultToSolrMapper */ public static ResultToSolrMapper createResultToSolrMapper(String indexName, IndexerConf indexerConf) { ResultToSolrMapper mapper = null; try { if (indexerConf.getMapperClass().equals(DefaultResultToSolrMapper.class)) { // FIXME: this is cheating. Knowledge about mapper implementations should be handled by IndexerComponentFactory mapper = new DefaultResultToSolrMapper(indexName, indexerConf.getFieldDefinitions(), indexerConf.getDocumentExtractDefinitions()); } else { mapper = indexerConf.getMapperClass().newInstance(); ConfigureUtil.configure(mapper, indexerConf.getGlobalParams()); } } catch (Exception e) { LOG.error("Error instantiating ResultToSolrMapper for " + indexName, e); throw new RuntimeException(e); } return mapper; }
addParams(params, indexerEl); if (conf.getMapperClass() != null) indexerEl.setAttribute("mapper", conf.getMapperClass().getName()); if (conf.getUniqueKeyFormatterClass() != null) indexerEl.setAttribute("unique-key-formatter", conf.getUniqueKeyFormatterClass().getName());
addParams(params, indexerEl); if (conf.getMapperClass() != null) indexerEl.setAttribute("mapper", conf.getMapperClass().getName()); if (conf.getUniqueKeyFormatterClass() != null) indexerEl.setAttribute("unique-key-formatter", conf.getUniqueKeyFormatterClass().getName());
/** * Construct based on an existing {@code IndexerConf}. All initial settings are * copied from the supplied configuration * * @param indexerConf indexer configuration containing default values */ public IndexerConfBuilder(IndexerConf indexerConf) { this.table = indexerConf.getTable(); this.uniqueKeyField = indexerConf.getUniqueKeyField(); this.rowField = indexerConf.getRowField(); this.columnFamilyField = indexerConf.getColumnFamilyField(); this.tableNameField = indexerConf.getTableNameField(); this.mapperClass = indexerConf.getMapperClass(); this.uniqueKeyFormatterClass = indexerConf.getUniqueKeyFormatterClass(); this.rowReadMode = indexerConf.getRowReadMode(); this.mappingType = indexerConf.getMappingType(); this.fieldDefinitions = Lists.newArrayList(indexerConf.getFieldDefinitions()); this.documentExtractDefinitions = Lists.newArrayList(indexerConf.getDocumentExtractDefinitions()); this.globalParams = Maps.newHashMap(indexerConf.getGlobalParams()); }
/** * Construct based on an existing {@code IndexerConf}. All initial settings are * copied from the supplied configuration * * @param indexerConf indexer configuration containing default values */ public IndexerConfBuilder(IndexerConf indexerConf) { this.table = indexerConf.getTable(); this.uniqueKeyField = indexerConf.getUniqueKeyField(); this.rowField = indexerConf.getRowField(); this.columnFamilyField = indexerConf.getColumnFamilyField(); this.tableNameField = indexerConf.getTableNameField(); this.mapperClass = indexerConf.getMapperClass(); this.uniqueKeyFormatterClass = indexerConf.getUniqueKeyFormatterClass(); this.rowReadMode = indexerConf.getRowReadMode(); this.mappingType = indexerConf.getMappingType(); this.fieldDefinitions = Lists.newArrayList(indexerConf.getFieldDefinitions()); this.documentExtractDefinitions = Lists.newArrayList(indexerConf.getDocumentExtractDefinitions()); this.globalParams = Maps.newHashMap(indexerConf.getGlobalParams()); }