Search in sources :

Example 1 with DataMapWriter

use of org.apache.carbondata.core.datamap.dev.DataMapWriter in project carbondata by apache.

the class DataMapWriterListener method register.

/**
 * Register a DataMapWriter
 */
private void register(DataMapFactory factory, String segmentId, String dataWritePath) {
    assert (factory != null);
    assert (segmentId != null);
    DataMapMeta meta = factory.getMeta();
    if (meta == null) {
        // if data map does not have meta, no need to register
        return;
    }
    List<String> columns = factory.getMeta().getIndexedColumns();
    List<DataMapWriter> writers = registry.get(columns);
    DataMapWriter writer = factory.createWriter(new Segment(segmentId, null), dataWritePath);
    if (writers != null) {
        writers.add(writer);
    } else {
        writers = new ArrayList<>();
        writers.add(writer);
        registry.put(columns, writers);
    }
    LOG.info("DataMapWriter " + writer + " added");
}
Also used : DataMapWriter(org.apache.carbondata.core.datamap.dev.DataMapWriter) DataMapMeta(org.apache.carbondata.core.datamap.DataMapMeta) Segment(org.apache.carbondata.core.datamap.Segment)

Example 2 with DataMapWriter

use of org.apache.carbondata.core.datamap.dev.DataMapWriter in project carbondata by apache.

the class DataMapWriterListener method onPageAdded.

/**
 * Pick corresponding column pages and add to all registered datamap
 *
 * @param pageId     sequence number of page, start from 0
 * @param tablePage  page data
 */
public void onPageAdded(int blockletId, int pageId, TablePage tablePage) throws IOException {
    Set<Map.Entry<List<String>, List<DataMapWriter>>> entries = registry.entrySet();
    for (Map.Entry<List<String>, List<DataMapWriter>> entry : entries) {
        List<String> indexedColumns = entry.getKey();
        ColumnPage[] pages = new ColumnPage[indexedColumns.size()];
        for (int i = 0; i < indexedColumns.size(); i++) {
            pages[i] = tablePage.getColumnPage(indexedColumns.get(i));
        }
        List<DataMapWriter> writers = entry.getValue();
        for (DataMapWriter writer : writers) {
            writer.onPageAdded(blockletId, pageId, pages);
        }
    }
}
Also used : DataMapWriter(org.apache.carbondata.core.datamap.dev.DataMapWriter) ColumnPage(org.apache.carbondata.core.datastore.page.ColumnPage) ArrayList(java.util.ArrayList) List(java.util.List) TableDataMap(org.apache.carbondata.core.datamap.TableDataMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map)

Aggregations

DataMapWriter (org.apache.carbondata.core.datamap.dev.DataMapWriter)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DataMapMeta (org.apache.carbondata.core.datamap.DataMapMeta)1 Segment (org.apache.carbondata.core.datamap.Segment)1 TableDataMap (org.apache.carbondata.core.datamap.TableDataMap)1 ColumnPage (org.apache.carbondata.core.datastore.page.ColumnPage)1