Search in sources :

Example 1 with IndexMeta

use of org.apache.carbondata.core.index.IndexMeta in project carbondata by apache.

the class IndexWriterListener method register.

/**
 * Register a IndexWriter
 */
private void register(IndexFactory factory, String segmentId, String taskNo, SegmentProperties segmentProperties) {
    assert (factory != null);
    assert (segmentId != null);
    IndexMeta meta = factory.getMeta();
    if (meta == null) {
        // if index does not have meta, no need to register
        return;
    }
    List<CarbonColumn> columns = factory.getMeta().getIndexedColumns();
    List<IndexWriter> writers = registry.get(columns);
    IndexWriter writer = null;
    try {
        writer = factory.createWriter(new Segment(segmentId), taskNo, segmentProperties);
    } catch (IOException e) {
        LOG.error("Failed to create IndexWriter: " + e.getMessage(), e);
        throw new IndexWriterException(e);
    }
    if (writers != null) {
        writers.add(writer);
    } else {
        writers = new ArrayList<>();
        writers.add(writer);
        registry.put(columns, writers);
    }
    LOG.info("IndexWriter " + writer + " added");
}
Also used : CarbonColumn(org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn) IndexWriter(org.apache.carbondata.core.index.dev.IndexWriter) IndexMeta(org.apache.carbondata.core.index.IndexMeta) IOException(java.io.IOException) Segment(org.apache.carbondata.core.index.Segment)

Aggregations

IOException (java.io.IOException)1 IndexMeta (org.apache.carbondata.core.index.IndexMeta)1 Segment (org.apache.carbondata.core.index.Segment)1 IndexWriter (org.apache.carbondata.core.index.dev.IndexWriter)1 CarbonColumn (org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn)1