apply factor based on sampling
This commit is contained in:
parent
7c2d0b353a
commit
c660bc8fe7
@ -618,7 +618,9 @@ var Profiler = require('../profiler');
|
|||||||
return f.nrows < 50000 && f.cost < 30000;
|
return f.nrows < 50000 && f.cost < 30000;
|
||||||
})
|
})
|
||||||
table = table.length ? table[0].table_name: this.options.overview_tables[this.options.overview_tables.length - 1]
|
table = table.length ? table[0].table_name: this.options.overview_tables[this.options.overview_tables.length - 1]
|
||||||
this._getHistogramForTiles(varName, start, end, bins, tiles, table, own_filter, callback)
|
// get multiplicator factor from table name
|
||||||
|
var factor = (+_.last(table.split('_')));
|
||||||
|
this._getHistogramForTiles(varName, start, end, bins, tiles, table, own_filter, factor, callback)
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -634,7 +636,7 @@ var Profiler = require('../profiler');
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_getHistogramForTiles: function(varName, start, end, bins, tiles, table, own_filter, callback){
|
_getHistogramForTiles: function(varName, start, end, bins, tiles, table, own_filter, factor, callback){
|
||||||
|
|
||||||
var sql = [
|
var sql = [
|
||||||
'with source as (',
|
'with source as (',
|
||||||
@ -709,6 +711,11 @@ var Profiler = require('../profiler');
|
|||||||
this.sql(query, function (data) {
|
this.sql(query, function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
var rows = JSON.parse(data.responseText).rows;
|
var rows = JSON.parse(data.responseText).rows;
|
||||||
|
// multiply by factor
|
||||||
|
rows.forEach(function(r) {
|
||||||
|
r.freq = r.freq * factor;
|
||||||
|
})
|
||||||
|
|
||||||
callback(rows);
|
callback(rows);
|
||||||
} else {
|
} else {
|
||||||
callback(null);
|
callback(null);
|
||||||
@ -724,11 +731,23 @@ var Profiler = require('../profiler');
|
|||||||
return f.nrows < 50000 && f.cost < 30000;
|
return f.nrows < 50000 && f.cost < 30000;
|
||||||
})
|
})
|
||||||
table = table.length ? table[0].table_name: this.options.overview_tables[this.options.overview_tables.length - 1]
|
table = table.length ? table[0].table_name: this.options.overview_tables[this.options.overview_tables.length - 1]
|
||||||
this._getCategoriesForTiles(varName, tiles, table, callback)
|
var factor = (+_.last(table.split('_')));
|
||||||
|
this._getCategoriesForTiles(varName, tiles, table, factor, callback)
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
_getCategoriesForTiles: function(varName, tiles, table, callback){
|
_getCategoriesForTiles: function(varName, tiles, table, factor, callback){
|
||||||
|
|
||||||
|
/*var sql = [
|
||||||
|
'SELECT CAST(category AS text), value, false as agg, nulls_count, min_val, max_val, count, categories_count',
|
||||||
|
' FROM categories, summary, categories_summary',
|
||||||
|
' WHERE rank < {{=it._limit}}',
|
||||||
|
'UNION ALL',
|
||||||
|
'SELECT \'Other\' category, sum(value), true as agg, nulls_count, min_val, max_val, count, categories_count',
|
||||||
|
' FROM categories, summary, categories_summary',
|
||||||
|
' WHERE rank >= {{=it._limit}}',
|
||||||
|
'GROUP BY nulls_count, min_val, max_val, count, categories_count'
|
||||||
|
]*/
|
||||||
|
|
||||||
var sql = [
|
var sql = [
|
||||||
'select {varName} category, count(1) as "value" from {table} {tiles} where {bounds} {filters} group by 1 order by 2 desc limit {num_cats}',
|
'select {varName} category, count(1) as "value" from {table} {tiles} where {bounds} {filters} group by 1 order by 2 desc limit {num_cats}',
|
||||||
@ -765,6 +784,9 @@ var Profiler = require('../profiler');
|
|||||||
this.sql(query, function (data) {
|
this.sql(query, function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
var rows = JSON.parse(data.responseText).rows;
|
var rows = JSON.parse(data.responseText).rows;
|
||||||
|
rows.forEach(function(r) {
|
||||||
|
r.value = factor * r.value;
|
||||||
|
});
|
||||||
callback(rows);
|
callback(rows);
|
||||||
} else {
|
} else {
|
||||||
callback(null);
|
callback(null);
|
||||||
|
Loading…
Reference in New Issue
Block a user