Search in sources :

Example 1 with MapRDBIndexDescriptor

use of org.apache.drill.exec.planner.index.MapRDBIndexDescriptor 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);
}
Also used : Table(com.mapr.db.Table) MetaTable(com.mapr.db.MetaTable) MapRDBStatisticsPayload(org.apache.drill.exec.planner.index.MapRDBStatisticsPayload) IndexDesc(com.mapr.db.index.IndexDesc) MetaTable(com.mapr.db.MetaTable) MapRDBIndexDescriptor(org.apache.drill.exec.planner.index.MapRDBIndexDescriptor)

Aggregations

MetaTable (com.mapr.db.MetaTable)1 Table (com.mapr.db.Table)1 IndexDesc (com.mapr.db.index.IndexDesc)1 MapRDBIndexDescriptor (org.apache.drill.exec.planner.index.MapRDBIndexDescriptor)1 MapRDBStatisticsPayload (org.apache.drill.exec.planner.index.MapRDBStatisticsPayload)1