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");
}
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);
}
}
}
Aggregations