use of org.apache.carbondata.core.index.dev.IndexWriter in project carbondata by apache.
the class IndexWriterListener method onPageAdded.
/**
* Pick corresponding column pages and add to all registered index
*
* @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<CarbonColumn>, List<IndexWriter>>> entries = registry.entrySet();
for (Map.Entry<List<CarbonColumn>, List<IndexWriter>> entry : entries) {
List<CarbonColumn> indexedColumns = entry.getKey();
ColumnPage[] pages = new ColumnPage[indexedColumns.size()];
for (int i = 0; i < indexedColumns.size(); i++) {
pages[i] = tablePage.getColumnPage(indexedColumns.get(i).getColName());
}
List<IndexWriter> writers = entry.getValue();
int pageSize = pages[0].getPageSize();
for (IndexWriter writer : writers) {
writer.onPageAdded(blockletId, pageId, pageSize, pages);
}
}
}
use of org.apache.carbondata.core.index.dev.IndexWriter 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");
}
Aggregations