Search in sources :

Example 1 with DataMapMeta

use of org.apache.carbondata.core.datamap.DataMapMeta in project carbondata by apache.

the class LuceneDataMapFactoryBase method init.

@Override
public void init(AbsoluteTableIdentifier identifier, DataMapSchema dataMapSchema) throws IOException, MalformedDataMapCommandException {
    Objects.requireNonNull(identifier);
    Objects.requireNonNull(dataMapSchema);
    this.tableIdentifier = identifier;
    this.dataMapName = dataMapSchema.getDataMapName();
    // get carbonmetadata from carbonmetadata instance
    CarbonMetadata carbonMetadata = CarbonMetadata.getInstance();
    String tableUniqueName = identifier.getCarbonTableIdentifier().getTableUniqueName();
    // get carbon table
    CarbonTable carbonTable = carbonMetadata.getCarbonTable(tableUniqueName);
    if (carbonTable == null) {
        String errorMessage = String.format("failed to get carbon table with name %s", tableUniqueName);
        LOGGER.error(errorMessage);
        throw new IOException(errorMessage);
    }
    // validate DataMapSchema and get index columns
    List<String> indexedColumns = validateAndGetIndexedColumns(dataMapSchema, carbonTable);
    // add optimizedOperations
    List<ExpressionType> optimizedOperations = new ArrayList<ExpressionType>();
    // optimizedOperations.add(ExpressionType.EQUALS);
    // optimizedOperations.add(ExpressionType.GREATERTHAN);
    // optimizedOperations.add(ExpressionType.GREATERTHAN_EQUALTO);
    // optimizedOperations.add(ExpressionType.LESSTHAN);
    // optimizedOperations.add(ExpressionType.LESSTHAN_EQUALTO);
    // optimizedOperations.add(ExpressionType.NOT);
    optimizedOperations.add(ExpressionType.TEXT_MATCH);
    this.dataMapMeta = new DataMapMeta(indexedColumns, optimizedOperations);
    // get analyzer
    // TODO: how to get analyzer ?
    analyzer = new StandardAnalyzer();
}
Also used : CarbonTable(org.apache.carbondata.core.metadata.schema.table.CarbonTable) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) ArrayList(java.util.ArrayList) IOException(java.io.IOException) DataMapMeta(org.apache.carbondata.core.datamap.DataMapMeta) CarbonMetadata(org.apache.carbondata.core.metadata.CarbonMetadata) ExpressionType(org.apache.carbondata.core.scan.filter.intf.ExpressionType)

Example 2 with DataMapMeta

use of org.apache.carbondata.core.datamap.DataMapMeta 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)

Aggregations

DataMapMeta (org.apache.carbondata.core.datamap.DataMapMeta)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Segment (org.apache.carbondata.core.datamap.Segment)1 DataMapWriter (org.apache.carbondata.core.datamap.dev.DataMapWriter)1 CarbonMetadata (org.apache.carbondata.core.metadata.CarbonMetadata)1 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)1 ExpressionType (org.apache.carbondata.core.scan.filter.intf.ExpressionType)1 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)1