Search in sources :

Example 1 with MetricDTO

use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by axbaretto.

the class OpenTSDBGroupScan method getScanStats.

@Override
public ScanStats getScanStats() {
    ServiceImpl client = storagePlugin.getClient();
    Map<String, String> params = fromRowData(openTSDBScanSpec.getTableName());
    Set<MetricDTO> allMetrics = client.getAllMetrics(params);
    long numMetrics = allMetrics.size();
    float approxDiskCost = 0;
    if (numMetrics != 0) {
        MetricDTO metricDTO = allMetrics.iterator().next();
        // This method estimates the sizes of Java objects (number of bytes of memory they occupy).
        // more detailed information about how this estimation method work you can find in this article
        // http://www.javaworld.com/javaworld/javaqa/2003-12/02-qa-1226-sizeof.html
        approxDiskCost = SizeEstimator.estimate(metricDTO) * numMetrics;
    }
    return new ScanStats(ScanStats.GroupScanProperty.EXACT_ROW_COUNT, numMetrics, 1, approxDiskCost);
}
Also used : MetricDTO(org.apache.drill.exec.store.openTSDB.dto.MetricDTO) ServiceImpl(org.apache.drill.exec.store.openTSDB.client.services.ServiceImpl) ScanStats(org.apache.drill.exec.physical.base.ScanStats)

Example 2 with MetricDTO

use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by axbaretto.

the class ServiceImpl method getUnfixedColumns.

@Override
public List<ColumnDTO> getUnfixedColumns(Map<String, String> queryParam) {
    Set<MetricDTO> metrics = getAllMetricsByTags(queryParam);
    List<ColumnDTO> unfixedColumns = new ArrayList<>();
    for (MetricDTO metric : metrics) {
        for (String tag : metric.getTags().keySet()) {
            ColumnDTO tmp = new ColumnDTO(tag, OpenTSDBTypes.STRING);
            if (!unfixedColumns.contains(tmp)) {
                unfixedColumns.add(tmp);
            }
        }
    }
    return unfixedColumns;
}
Also used : MetricDTO(org.apache.drill.exec.store.openTSDB.dto.MetricDTO) ArrayList(java.util.ArrayList) ColumnDTO(org.apache.drill.exec.store.openTSDB.dto.ColumnDTO)

Example 3 with MetricDTO

use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by apache.

the class OpenTSDBRecordReader method processOpenTSDBTablesData.

private int processOpenTSDBTablesData() throws SchemaChangeException {
    int rowCounter = 0;
    while (tableIterator.hasNext() && rowCounter < TARGET_RECORD_COUNT) {
        MetricDTO metricDTO = tableIterator.next();
        rowCounter = addRowResult(metricDTO, rowCounter);
    }
    return rowCounter;
}
Also used : MetricDTO(org.apache.drill.exec.store.openTSDB.dto.MetricDTO)

Example 4 with MetricDTO

use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by apache.

the class ServiceImpl method getTagsFromMetrics.

private Set<String> getTagsFromMetrics(Set<MetricDTO> metrics) {
    Set<String> extractedTags = new HashSet<>();
    for (MetricDTO table : metrics) {
        extractedTags.addAll(table.getAggregateTags());
        extractedTags.addAll(table.getTags().keySet());
    }
    return extractedTags;
}
Also used : MetricDTO(org.apache.drill.exec.store.openTSDB.dto.MetricDTO) HashSet(java.util.HashSet)

Example 5 with MetricDTO

use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by apache.

the class ServiceImpl method getAllMetricsFromDBByTags.

private Set<MetricDTO> getAllMetricsFromDBByTags(Map<String, String> queryParams) throws IOException {
    Map<String, String> tags = new HashMap<>();
    DBQuery baseQuery = getConfiguredDbQuery(tags, queryParams);
    Set<MetricDTO> metrics = getBaseMetric(baseQuery);
    if (metrics == null || metrics.isEmpty()) {
        throw UserException.validationError().message(String.format("Table '%s' not found. Please check your query and params", queryParams.get(METRIC_PARAM))).build(log);
    }
    Set<String> extractedTags = getTagsFromMetrics(metrics);
    return getMetricsByTags(extractedTags, queryParams);
}
Also used : MetricDTO(org.apache.drill.exec.store.openTSDB.dto.MetricDTO) HashMap(java.util.HashMap) DBQuery(org.apache.drill.exec.store.openTSDB.client.query.DBQuery)

Aggregations

MetricDTO (org.apache.drill.exec.store.openTSDB.dto.MetricDTO)10 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ScanStats (org.apache.drill.exec.physical.base.ScanStats)2 DBQuery (org.apache.drill.exec.store.openTSDB.client.query.DBQuery)2 ServiceImpl (org.apache.drill.exec.store.openTSDB.client.services.ServiceImpl)2 ColumnDTO (org.apache.drill.exec.store.openTSDB.dto.ColumnDTO)2