use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by apache.
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);
}
use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by axbaretto.
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;
}
use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by axbaretto.
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);
}
use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by axbaretto.
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;
}
use of org.apache.drill.exec.store.openTSDB.dto.MetricDTO in project drill by apache.
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;
}
Aggregations