Search in sources :

Example 1 with DBException

use of com.mapr.db.exceptions.DBException in project drill by axbaretto.

the class MaprDBJsonRecordReader method setup.

@Override
public void setup(OperatorContext context, OutputMutator output) throws ExecutionSetupException {
    this.vectorWriter = new VectorContainerWriter(output, unionEnabled);
    this.operatorContext = context;
    try {
        table = MapRDB.getTable(tableName);
        table.setOption(TableOption.EXCLUDEID, !includeId);
        documentStream = table.find(condition, projectedFields);
        documentReaderIterators = documentStream.documentReaders().iterator();
    } catch (DBException e) {
        throw new ExecutionSetupException(e);
    }
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) DBException(com.mapr.db.exceptions.DBException) VectorContainerWriter(org.apache.drill.exec.vector.complex.impl.VectorContainerWriter)

Example 2 with DBException

use of com.mapr.db.exceptions.DBException in project drill by apache.

the class MapRDBIndexDiscover method getTableIndexFromMFS.

/**
 * For a given table name get the list of indexes defined on the table according to the visibility of
 * the indexes based on permissions.
 * @param tableName table name
 * @return an IndexCollection representing the list of indexes for that table
 */
private IndexCollection getTableIndexFromMFS(String tableName) {
    try {
        Set<DrillIndexDescriptor> idxSet = new HashSet<>();
        Collection<IndexDesc> indexes = admin().getTableIndexes(new Path(tableName));
        if (indexes.size() == 0) {
            logger.error("No index returned from Admin.getTableIndexes for table {}", tableName);
            return null;
        }
        for (IndexDesc idx : indexes) {
            DrillIndexDescriptor hbaseIdx = buildIndexDescriptor(tableName, idx);
            if (hbaseIdx == null) {
                // not able to build a valid index based on the index info from MFS
                logger.error("Not able to build index for {}", idx.toString());
                continue;
            }
            idxSet.add(hbaseIdx);
        }
        if (idxSet.size() == 0) {
            logger.error("No index found for table {}.", tableName);
            return null;
        }
        return new DrillIndexCollection(getOriginalScanRel(), idxSet);
    } catch (DBException ex) {
        logger.error("Could not get table index from File system.", ex);
    } catch (InvalidIndexDefinitionException ex) {
        logger.error("Invalid index definition detected.", ex);
    }
    return null;
}
Also used : Path(org.apache.hadoop.fs.Path) SchemaPath(org.apache.drill.common.expression.SchemaPath) FieldPath(org.ojai.FieldPath) DBException(com.mapr.db.exceptions.DBException) IndexDesc(com.mapr.db.index.IndexDesc) HashSet(java.util.HashSet)

Example 3 with DBException

use of com.mapr.db.exceptions.DBException in project drill by apache.

the class MaprDBJsonRecordReader method setup.

@Override
public void setup(OperatorContext context, OutputMutator output) throws ExecutionSetupException {
    this.vectorWriter = new VectorContainerWriter(output, unionEnabled);
    this.vectorWriterMutator = output;
    this.operatorContext = context;
    try {
        table.setOption(TableOption.EXCLUDEID, !includeId);
        documentStream = table.find(condition, scannedFields);
        documentIterator = documentStream.iterator();
        setupWriter();
    } catch (DBException ex) {
        throw new ExecutionSetupException(ex);
    }
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) DBException(com.mapr.db.exceptions.DBException) VectorContainerWriter(org.apache.drill.exec.vector.complex.impl.VectorContainerWriter)

Aggregations

DBException (com.mapr.db.exceptions.DBException)3 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)2 VectorContainerWriter (org.apache.drill.exec.vector.complex.impl.VectorContainerWriter)2 IndexDesc (com.mapr.db.index.IndexDesc)1 HashSet (java.util.HashSet)1 SchemaPath (org.apache.drill.common.expression.SchemaPath)1 Path (org.apache.hadoop.fs.Path)1 FieldPath (org.ojai.FieldPath)1