use of com.mapr.db.index.IndexDesc 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;
}
use of com.mapr.db.index.IndexDesc in project drill by apache.
the class JsonTableGroupScan method getAverageRowSizeStats.
/**
* Get the estimated average rowsize. DO NOT call this API directly.
* Call the stats API instead which modifies the counts based on preference options.
* @param index to use for generating the estimate
* @return row count post filtering
*/
public MapRDBStatisticsPayload getAverageRowSizeStats(IndexDescriptor index) {
IndexDesc indexDesc = null;
double avgRowSize = AVG_ROWSIZE_UNKNOWN;
if (index != null) {
indexDesc = (IndexDesc) ((MapRDBIndexDescriptor) index).getOriginalDesc();
}
// If no index is specified, get it from the primary table
if (indexDesc == null && scanSpec.isSecondaryIndex()) {
throw new UnsupportedOperationException("getAverageRowSizeStats should be invoked on primary table");
}
// Get the index table or primary table and use the DB API to get the estimated number of rows. For size estimates,
// we assume that all the columns would be read from the disk.
final Table table = this.formatPlugin.getJsonTableCache().getTable(scanSpec.getTableName(), indexDesc, getUserName());
if (table != null) {
final MetaTable metaTable = table.getMetaTable();
if (metaTable != null) {
avgRowSize = metaTable.getAverageRowSize();
}
}
logger.debug("index_plan_info: getEstimatedRowCount obtained from DB Client for {}: indexName: {}, indexInfo: {}, " + "avgRowSize: {}, estimatedSize {}", this, (indexDesc == null ? "null" : indexDesc.getIndexName()), (indexDesc == null ? "null" : indexDesc.getIndexInfo()), avgRowSize, fullTableEstimatedSize);
return new MapRDBStatisticsPayload(ROWCOUNT_UNKNOWN, ROWCOUNT_UNKNOWN, avgRowSize);
}
use of com.mapr.db.index.IndexDesc in project drill by apache.
the class MapRDBFormatMatcher method isReadableIndex.
/**
* Get an instance of DrillTable for a particular native secondary index
* @param fs
* @param selection
* @param fsPlugin
* @param storageEngineName
* @param userName
* @param secondaryIndexDesc
* @return
* @throws IOException
*/
public DrillTable isReadableIndex(DrillFileSystem fs, FileSelection selection, FileSystemPlugin fsPlugin, String storageEngineName, String userName, IndexDescriptor secondaryIndexDesc) throws IOException {
FileStatus status = selection.getFirstPath(fs);
if (!isFileReadable(fs, status)) {
return null;
}
MapRDBFormatPlugin fp = (MapRDBFormatPlugin) getFormatPlugin();
DrillTable dt = new DynamicDrillTable(fsPlugin, storageEngineName, userName, new FormatSelection(fp.getConfig(), selection));
// TODO: Create groupScan using index descriptor
dt.setGroupScan(fp.getGroupScan(userName, selection, null, /* columns */
(IndexDesc) ((MapRDBIndexDescriptor) secondaryIndexDesc).getOriginalDesc(), null));
return dt;
}
Aggregations