ui: Convert all queries to use slowlyCountRows
To convert the UI to use the new query result format we first need to move
the queries to the new iterator. This will be done in a few parts:
1. Stop depending on rowCount (this CL)
2. Move all queries to using iter().
3. Implement iter for new query result format
4. Switch query to return the new result format
Change-Id: Ic2fecdde2c224261e56e3ae10279335fc563010d
diff --git a/ui/src/common/engine.ts b/ui/src/common/engine.ts
index e470a92..c270010 100644
--- a/ui/src/common/engine.ts
+++ b/ui/src/common/engine.ts
@@ -18,6 +18,7 @@
RawQueryArgs,
RawQueryResult
} from './protos';
+import {slowlyCountRows} from './query_iterator';
import {TimeSpan} from './time';
export interface LoadingTracker {
@@ -126,7 +127,7 @@
async queryOneRow(query: string): Promise<number[]> {
const result = await this.query(query);
const res: number[] = [];
- if (result.numRecords === 0) return res;
+ if (slowlyCountRows(result) === 0) return res;
for (const col of result.columns) {
if (col.longValues!.length === 0) {
console.error(
@@ -146,7 +147,7 @@
if (!this._cpus) {
const result =
await this.query('select distinct(cpu) from sched order by cpu;');
- if (result.numRecords === 0) return [];
+ if (slowlyCountRows(result) === 0) return [];
this._cpus = result.columns[0].longValues!.map(n => +n);
}
return this._cpus;
diff --git a/ui/src/common/protos.ts b/ui/src/common/protos.ts
index 52160fd..be1da62 100644
--- a/ui/src/common/protos.ts
+++ b/ui/src/common/protos.ts
@@ -14,6 +14,7 @@
import {assertFalse, assertTrue} from '../base/logging';
import * as protos from '../gen/protos';
+import {slowlyCountRows} from './query_iterator';
// Aliases protos to avoid the super nested namespaces.
// See https://www.typescriptlang.org/docs/handbook/namespaces.html#aliases
@@ -104,7 +105,7 @@
export function* rawQueryResultIter(result: RawQueryResult) {
const columns: Array<[string, number]> = rawQueryResultColumns(result).map(
(name, i): [string, number] => [name, i]);
- for (let rowNum = 0; rowNum < result.numRecords; rowNum++) {
+ for (let rowNum = 0; rowNum < slowlyCountRows(result); rowNum++) {
const row: Row = {};
for (const [name, colNum] of columns) {
const cell = getCell(result, colNum, rowNum);
@@ -154,7 +155,7 @@
const columnType = raw.columnDescriptors[i].type;
if (columnSpec === NUM || columnSpec === STR) {
- for (let j = 0; j < raw.numRecords; j++) {
+ for (let j = 0; j < slowlyCountRows(raw); j++) {
assertFalse(column.isNulls![i], `Unexpected null in ${key} row ${j}`);
}
}
@@ -195,7 +196,7 @@
columns.push([key, accessor]);
}
- for (let i = 0; i < raw.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(raw); i++) {
const row: {[_: string]: number | string | null} = {};
for (const [name, accessor] of columns) {
row[name] = accessor(i);
diff --git a/ui/src/common/query_iterator.ts b/ui/src/common/query_iterator.ts
index 1e41c41..c180d31 100644
--- a/ui/src/common/query_iterator.ts
+++ b/ui/src/common/query_iterator.ts
@@ -77,7 +77,7 @@
}
if (disallowNulls) {
- for (let j = 0; j < result.numRecords; ++j) {
+ for (let j = 0; j < slowlyCountRows(result); ++j) {
if (column.isNulls![j] === true) {
throw new Error(`Column ${name} contains nulls`);
}
@@ -106,7 +106,7 @@
const row: Row = querySpec;
this.row = row;
this.i_ = 0;
- this.rowCount_ = +queryResult.numRecords;
+ this.rowCount_ = slowlyCountRows(queryResult);
this.columnCount_ = 0;
this.columnNames_ = [];
this.columns_ = [];
diff --git a/ui/src/controller/aggregation/aggregation_controller.ts b/ui/src/controller/aggregation/aggregation_controller.ts
index 4f608f9..7b2d941 100644
--- a/ui/src/controller/aggregation/aggregation_controller.ts
+++ b/ui/src/controller/aggregation/aggregation_controller.ts
@@ -19,6 +19,7 @@
ThreadStateExtra,
} from '../../common/aggregation_data';
import {Engine} from '../../common/engine';
+import {slowlyCountRows} from '../../common/query_iterator';
import {Area, Sorting} from '../../common/state';
import {Controller} from '../controller';
import {globals} from '../globals';
@@ -118,7 +119,7 @@
const query = `select ${colIds} from ${this.kind} order by ${sorting}`;
const result = await this.args.engine.query(query);
- const numRows = +result.numRecords;
+ const numRows = slowlyCountRows(result);
const columns = defs.map(def => this.columnFromColumnDef(def, numRows));
const columnSums = await Promise.all(defs.map(def => this.getSum(def)));
const extraData = await this.getExtra(this.args.engine, area);
diff --git a/ui/src/controller/aggregation/thread_aggregation_controller.ts b/ui/src/controller/aggregation/thread_aggregation_controller.ts
index 2648f64..03eb935 100644
--- a/ui/src/controller/aggregation/thread_aggregation_controller.ts
+++ b/ui/src/controller/aggregation/thread_aggregation_controller.ts
@@ -14,6 +14,7 @@
import {ColumnDef, ThreadStateExtra} from '../../common/aggregation_data';
import {Engine} from '../../common/engine';
+import {slowlyCountRows} from '../../common/query_iterator';
import {Area, Sorting} from '../../common/state';
import {translateState} from '../../common/thread_state';
import {toNs} from '../../common/time';
@@ -80,7 +81,7 @@
thread_state.ts < ${toNs(area.endSec)}
GROUP BY state, io_wait`;
const result = await engine.query(query);
- const numRows = +result.numRecords;
+ const numRows = slowlyCountRows(result);
const summary: ThreadStateExtra = {
kind: 'THREAD_STATE',
diff --git a/ui/src/controller/cpu_profile_controller.ts b/ui/src/controller/cpu_profile_controller.ts
index 1733a5c..1450e94 100644
--- a/ui/src/controller/cpu_profile_controller.ts
+++ b/ui/src/controller/cpu_profile_controller.ts
@@ -13,6 +13,7 @@
// limitations under the License.
import {Engine} from '../common/engine';
+import {slowlyCountRows} from '../common/query_iterator';
import {CallsiteInfo, CpuProfileSampleSelection} from '../common/state';
import {CpuProfileDetails} from '../frontend/globals';
@@ -150,12 +151,12 @@
const callsites = await this.args.engine.query(sampleQuery);
- if (callsites.numRecords < 1) {
+ if (slowlyCountRows(callsites) < 1) {
return undefined;
}
const sampleData: CallsiteInfo[] = new Array();
- for (let i = 0; i < callsites.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(callsites); i++) {
const id = +callsites.columns[0].longValues![i];
const name = callsites.columns[1].stringValues![i];
const mapping = callsites.columns[2].stringValues![i];
diff --git a/ui/src/controller/flow_events_controller.ts b/ui/src/controller/flow_events_controller.ts
index 8bbfcd2..86c50da 100644
--- a/ui/src/controller/flow_events_controller.ts
+++ b/ui/src/controller/flow_events_controller.ts
@@ -13,6 +13,7 @@
// limitations under the License.
import {Engine} from '../common/engine';
+import {slowlyCountRows} from '../common/query_iterator';
import {Area} from '../common/state';
import {fromNs, toNs} from '../common/time';
import {Flow} from '../frontend/globals';
@@ -37,7 +38,7 @@
queryFlowEvents(query: string, callback: (flows: Flow[]) => void) {
this.args.engine.query(query).then(res => {
const flows: Flow[] = [];
- for (let i = 0; i < res.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(res); i++) {
const beginSliceId = res.columns[0].longValues![i];
const beginTrackId = res.columns[1].longValues![i];
const beginSliceName = res.columns[2].stringValues![i];
diff --git a/ui/src/controller/heap_profile_controller.ts b/ui/src/controller/heap_profile_controller.ts
index 0f99db3..c152590 100644
--- a/ui/src/controller/heap_profile_controller.ts
+++ b/ui/src/controller/heap_profile_controller.ts
@@ -23,6 +23,7 @@
OBJECTS_ALLOCATED_NOT_FREED_KEY,
SPACE_MEMORY_ALLOCATED_NOT_FREED_KEY
} from '../common/flamegraph_util';
+import {slowlyCountRows} from '../common/query_iterator';
import {CallsiteInfo, HeapProfileFlamegraph} from '../common/state';
import {fromNs} from '../common/time';
import {HeapProfileDetails} from '../frontend/globals';
@@ -273,7 +274,7 @@
const flamegraphData: CallsiteInfo[] = new Array();
const hashToindex: Map<number, number> = new Map();
- for (let i = 0; i < callsites.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(callsites); i++) {
const hash = callsites.columns[0].longValues![i];
let name = callsites.columns[1].stringValues![i];
const parentHash = callsites.columns[2].longValues![i];
diff --git a/ui/src/controller/logs_controller.ts b/ui/src/controller/logs_controller.ts
index de9824f..7d1d49f 100644
--- a/ui/src/controller/logs_controller.ts
+++ b/ui/src/controller/logs_controller.ts
@@ -20,6 +20,7 @@
LogEntriesKey,
LogExistsKey
} from '../common/logs';
+import {slowlyCountRows} from '../common/query_iterator';
import {fromNs, TimeSpan, toNsCeil, toNsFloor} from '../common/time';
import {Controller} from './controller';
@@ -73,7 +74,7 @@
order by ts
limit ${pagination.start}, ${pagination.count}`);
- if (!rowsResult.numRecords) {
+ if (!slowlyCountRows(rowsResult)) {
return {
offset: pagination.start,
timestamps: [],
diff --git a/ui/src/controller/query_controller.ts b/ui/src/controller/query_controller.ts
index e8f930d..c4bd9d4 100644
--- a/ui/src/controller/query_controller.ts
+++ b/ui/src/controller/query_controller.ts
@@ -17,6 +17,7 @@
import {Engine} from '../common/engine';
import {rawQueryResultColumns, rawQueryResultIter, Row} from '../common/protos';
import {QueryResponse} from '../common/queries';
+import {slowlyCountRows} from '../common/query_iterator';
import {Controller} from './controller';
import {globals} from './globals';
@@ -65,7 +66,7 @@
query: sqlQuery,
durationMs,
error: rawResult.error,
- totalRowCount: +rawResult.numRecords,
+ totalRowCount: slowlyCountRows(rawResult),
columns,
rows,
};
diff --git a/ui/src/controller/search_controller.ts b/ui/src/controller/search_controller.ts
index 7ec474f..c5ee827 100644
--- a/ui/src/controller/search_controller.ts
+++ b/ui/src/controller/search_controller.ts
@@ -13,6 +13,7 @@
// limitations under the License.
import {Engine} from '../common/engine';
+import {slowlyCountRows} from '../common/query_iterator';
import {CurrentSearchResults, SearchSummary} from '../common/search_data';
import {TimeSpan} from '../common/time';
@@ -171,7 +172,7 @@
group by quantum_ts
order by quantum_ts;`);
- const numRows = +rawResult.numRecords;
+ const numRows = slowlyCountRows(rawResult);
const summary = {
tsStarts: new Float64Array(numRows),
tsEnds: new Float64Array(numRows),
@@ -247,7 +248,7 @@
where string_value like ${searchLiteral}
order by ts`);
- const numRows = +rawResult.numRecords;
+ const numRows = slowlyCountRows(rawResult);
const searchResults: CurrentSearchResults = {
sliceIds: [],
diff --git a/ui/src/controller/selection_controller.ts b/ui/src/controller/selection_controller.ts
index eaf5d6c..562fd29 100644
--- a/ui/src/controller/selection_controller.ts
+++ b/ui/src/controller/selection_controller.ts
@@ -13,6 +13,7 @@
// limitations under the License.
import {Engine} from '../common/engine';
+import {slowlyCountRows} from '../common/query_iterator';
import {translateState} from '../common/thread_state';
import {fromNs, toNs} from '../common/time';
import {
@@ -92,7 +93,7 @@
this.args.engine.query(sqlQuery).then(result => {
// Check selection is still the same on completion of query.
const selection = globals.state.currentSelection;
- if (result.numRecords === 1 && selection &&
+ if (slowlyCountRows(result) === 1 && selection &&
selection.kind === selectedKind && selection.id === selectedId) {
const ts = result.columns[0].longValues![0];
const timeFromStart = fromNs(ts) - globals.state.traceTime.startSec;
@@ -131,7 +132,7 @@
where slice_id = ${id}
`;
const result = await this.args.engine.query(query);
- for (let i = 0; i < result.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(result); i++) {
const description = result.columns[0].stringValues![i];
const docLink = result.columns[1].stringValues![i];
map.set('Description', description);
@@ -150,7 +151,7 @@
WHERE arg_set_id = ${argId}
`;
const result = await this.args.engine.query(query);
- for (let i = 0; i < result.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(result); i++) {
const name = result.columns[0].stringValues![i];
const value = result.columns[1].stringValues![i];
if (name === 'destination slice id' && !isNaN(Number(value))) {
@@ -190,7 +191,7 @@
this.args.engine.query(query).then(result => {
const selection = globals.state.currentSelection;
const cols = result.columns;
- if (result.numRecords === 1 && selection) {
+ if (slowlyCountRows(result) === 1 && selection) {
const ts = cols[0].longValues![0];
const timeFromStart = fromNs(ts) - globals.state.traceTime.startSec;
const dur = fromNs(cols[1].longValues![0]);
@@ -216,7 +217,7 @@
this.args.engine.query(sqlQuery).then(result => {
// Check selection is still the same on completion of query.
const selection = globals.state.currentSelection;
- if (result.numRecords === 1 && selection) {
+ if (slowlyCountRows(result) === 1 && selection) {
const ts = result.columns[0].longValues![0];
const timeFromStart = fromNs(ts) - globals.state.traceTime.startSec;
const dur = fromNs(result.columns[1].longValues![0]);
@@ -271,8 +272,8 @@
`select * from instants where name = 'sched_waking' limit 1`);
const wakeup = await this.args.engine.query(
`select * from instants where name = 'sched_wakeup' limit 1`);
- if (waking.numRecords === 0) {
- if (wakeup.numRecords === 0) return undefined;
+ if (slowlyCountRows(waking) === 0) {
+ if (slowlyCountRows(wakeup) === 0) return undefined;
// Only use sched_wakeup if waking is not in the trace.
event = 'sched_wakeup';
}
diff --git a/ui/src/controller/trace_controller.ts b/ui/src/controller/trace_controller.ts
index ef1db38..cc8a5a1 100644
--- a/ui/src/controller/trace_controller.ts
+++ b/ui/src/controller/trace_controller.ts
@@ -21,6 +21,7 @@
} from '../common/actions';
import {Engine, QueryError} from '../common/engine';
import {HttpRpcEngine} from '../common/http_rpc_engine';
+import {slowlyCountRows} from '../common/query_iterator';
import {EngineMode} from '../common/state';
import {toNs, toNsCeil, toNsFloor} from '../common/time';
import {TimeSpan} from '../common/time';
@@ -30,6 +31,7 @@
WasmEngineProxy
} from '../common/wasm_engine_proxy';
import {QuantizedLoad, ThreadDesc} from '../frontend/globals';
+
import {
CounterAggregationController
} from './aggregation/counter_aggregation_controller';
@@ -328,7 +330,7 @@
using(upid)`;
const threadRows = await assertExists(this.engine).query(sqlQuery);
const threads: ThreadDesc[] = [];
- for (let i = 0; i < threadRows.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(threadRows); i++) {
const utid = threadRows.columns[0].longValues![i];
const tid = threadRows.columns[1].longValues![i];
const pid = threadRows.columns[2].longValues![i];
@@ -360,7 +362,7 @@
`where ts >= ${startNs} and ts < ${endNs} and utid != 0 ` +
'group by cpu order by cpu');
const schedData: {[key: string]: QuantizedLoad} = {};
- for (let i = 0; i < schedRows.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(schedRows); i++) {
const load = schedRows.columns[0].doubleValues![i];
const cpu = schedRows.columns[1].longValues![i];
schedData[cpu] = {startSec, endSec, load};
@@ -393,7 +395,7 @@
group by bucket, upid`);
const slicesData: {[key: string]: QuantizedLoad[]} = {};
- for (let i = 0; i < sliceSummaryQuery.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(sliceSummaryQuery); i++) {
const bucket = sliceSummaryQuery.columns[0].longValues![i];
const upid = sliceSummaryQuery.columns[1].longValues![i];
const load = sliceSummaryQuery.columns[2].doubleValues![i];
diff --git a/ui/src/controller/track_decider.ts b/ui/src/controller/track_decider.ts
index 6d1edfd..655a99d 100644
--- a/ui/src/controller/track_decider.ts
+++ b/ui/src/controller/track_decider.ts
@@ -21,6 +21,7 @@
} from '../common/actions';
import {Engine} from '../common/engine';
import {NUM, NUM_NULL, rawQueryToRows, STR_NULL} from '../common/protos';
+import {slowlyCountRows} from '../common/query_iterator';
import {SCROLLING_TRACK_GROUP} from '../common/state';
import {ANDROID_LOGS_TRACK_KIND} from '../tracks/android_log/common';
import {ASYNC_SLICE_TRACK_KIND} from '../tracks/async_slices/common';
@@ -133,7 +134,7 @@
where name = 'cpufreq' and cpu = ${cpu}
limit 1;
`);
- if (cpuFreqIdle.numRecords > 0) {
+ if (slowlyCountRows(cpuFreqIdle) > 0) {
const freqTrackId = +cpuFreqIdle.columns[0].longValues![0];
const idleTrackExists: boolean = !cpuFreqIdle.columns[1].isNulls![0];
@@ -169,7 +170,7 @@
WHERE t.track_ids = experimental_slice_layout.filter_track_ids
GROUP BY t.track_ids;
`);
- for (let i = 0; i < rawGlobalAsyncTracks.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(rawGlobalAsyncTracks); i++) {
const name = rawGlobalAsyncTracks.columns[0].stringValues![i];
const rawTrackIds = rawGlobalAsyncTracks.columns[1].stringValues![i];
const trackIds = rawTrackIds.split(',').map(v => Number(v));
@@ -193,7 +194,7 @@
FROM process_track
GROUP BY upid, name
`);
- for (let i = 0; i < rawProcessTracks.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(rawProcessTracks); i++) {
const upid = +rawProcessTracks.columns[0].longValues![i];
const name = rawProcessTracks.columns[1].stringValues![i];
const rawTrackIds = rawProcessTracks.columns[2].stringValues![i];
@@ -228,7 +229,7 @@
select distinct(upid) from heap_graph_object`);
const heapUpids: Set<number> = new Set();
- for (let i = 0; i < heapProfiles.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(heapProfiles); i++) {
const upid = heapProfiles.columns[0].longValues![i];
heapUpids.add(+upid);
}
@@ -249,7 +250,7 @@
where name = 'gpufreq' and gpu_id = ${gpu}
limit 1;
`);
- if (freqExists.numRecords > 0) {
+ if (slowlyCountRows(freqExists) > 0) {
tracksToAdd.push({
engineId,
kind: COUNTER_TRACK_KIND,
@@ -273,7 +274,7 @@
from gpu_counter_track
where name != 'gpufreq'
`);
- for (let i = 0; i < globalCounters.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(globalCounters); i++) {
const name = globalCounters.columns[0].stringValues![i];
const trackId = +globalCounters.columns[1].longValues![i];
tracksToAdd.push({
@@ -301,7 +302,7 @@
start_ts, end_ts from thread_counter_track join thread using(utid)
where thread_counter_track.name not in ('time_in_state')
`);
- for (let i = 0; i < threadCounters.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(threadCounters); i++) {
const name = threadCounters.columns[0].stringValues![i];
const utid = +threadCounters.columns[1].longValues![i];
const trackId = +threadCounters.columns[2].longValues![i];
@@ -328,7 +329,7 @@
select process_counter_track.name, upid, process_counter_track.id,
start_ts, end_ts from process_counter_track join process using(upid)
`);
- for (let i = 0; i < processCounters.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(processCounters); i++) {
const name = processCounters.columns[0].stringValues![i];
const upid = +processCounters.columns[1].longValues![i];
const trackId = +processCounters.columns[2].longValues![i];
@@ -364,7 +365,7 @@
`);
const utidToThreadTrack = new Map<number, ThreadSliceTrack[]>();
- for (let i = 0; i < maxDepthQuery.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(maxDepthQuery); i++) {
const utid = maxDepthQuery.columns[0].longValues![i];
const trackId = maxDepthQuery.columns[1].longValues![i];
const name = maxDepthQuery.columns[2].stringValues![i];
@@ -384,7 +385,7 @@
const exists =
await engine.query(`select name from sqlite_master where type='table' and
name='android_thread_time_in_state_event'`);
- if (exists.numRecords === 0) {
+ if (slowlyCountRows(exists) === 0) {
await engine.query(`create view android_thread_time_in_state_event as
select null as upid, null as value where 0`);
}
@@ -630,7 +631,7 @@
const annotationSliceRows = await engine.query(`
SELECT id, name, upid FROM annotation_slice_track`);
- for (let i = 0; i < annotationSliceRows.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(annotationSliceRows); i++) {
const id = annotationSliceRows.columns[0].longValues![i];
const name = annotationSliceRows.columns[1].stringValues![i];
const upid = annotationSliceRows.columns[2].longValues![i];
@@ -650,7 +651,7 @@
const annotationCounterRows = await engine.query(`
SELECT id, name, upid, min_value, max_value
FROM annotation_counter_track`);
- for (let i = 0; i < annotationCounterRows.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(annotationCounterRows); i++) {
const id = annotationCounterRows.columns[0].longValues![i];
const name = annotationCounterRows.columns[1].stringValues![i];
const upid = annotationCounterRows.columns[2].longValues![i];
diff --git a/ui/src/tracks/android_log/controller.ts b/ui/src/tracks/android_log/controller.ts
index fba13d7..afd235c 100644
--- a/ui/src/tracks/android_log/controller.ts
+++ b/ui/src/tracks/android_log/controller.ts
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import {slowlyCountRows} from '../../common/query_iterator';
import {fromNs, toNsCeil, toNsFloor} from '../../common/time';
import {LIMIT} from '../../common/track_data';
import {
@@ -42,7 +43,7 @@
group by ts_quant, prio
order by ts_quant, prio limit ${LIMIT};`);
- const rowCount = +rawResult.numRecords;
+ const rowCount = slowlyCountRows(rawResult);
const result = {
start,
end,
diff --git a/ui/src/tracks/async_slices/controller.ts b/ui/src/tracks/async_slices/controller.ts
index 4c0356c..96bd6e4 100644
--- a/ui/src/tracks/async_slices/controller.ts
+++ b/ui/src/tracks/async_slices/controller.ts
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import {slowlyCountRows} from '../../common/query_iterator';
import {fromNs, toNs} from '../../common/time';
import {
TrackController,
@@ -41,7 +42,7 @@
from experimental_slice_layout
where filter_track_ids = '${this.config.trackIds.join(',')}'
`);
- if (maxDurResult.numRecords === 1) {
+ if (slowlyCountRows(maxDurResult) === 1) {
this.maxDurNs = maxDurResult.columns[0].longValues![0];
}
}
@@ -65,7 +66,7 @@
order by tsq, layout_depth
`);
- const numRows = +rawResult.numRecords;
+ const numRows = slowlyCountRows(rawResult);
const slices: Data = {
start,
end,
diff --git a/ui/src/tracks/chrome_slices/controller.ts b/ui/src/tracks/chrome_slices/controller.ts
index 8172da9..b1f2101 100644
--- a/ui/src/tracks/chrome_slices/controller.ts
+++ b/ui/src/tracks/chrome_slices/controller.ts
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import {slowlyCountRows} from '../../common/query_iterator';
import {fromNs, toNs} from '../../common/time';
import {
TrackController,
@@ -41,7 +42,7 @@
const query = `SELECT max(dur) FROM ${tableName} WHERE track_id = ${
this.config.trackId}`;
const rawResult = await this.query(query);
- if (rawResult.numRecords === 1) {
+ if (slowlyCountRows(rawResult) === 1) {
this.maxDurNs = rawResult.columns[0].longValues![0];
}
}
@@ -63,12 +64,12 @@
GROUP BY depth, tsq`;
const rawResult = await this.query(query);
- const numRows = +rawResult.numRecords;
+ const numRows = slowlyCountRows(rawResult);
const slices: Data = {
start,
end,
resolution,
- length: +rawResult.numRecords,
+ length: numRows,
strings: [],
sliceIds: new Float64Array(numRows),
starts: new Float64Array(numRows),
diff --git a/ui/src/tracks/counter/controller.ts b/ui/src/tracks/counter/controller.ts
index fbad534..fa678cc 100644
--- a/ui/src/tracks/counter/controller.ts
+++ b/ui/src/tracks/counter/controller.ts
@@ -75,7 +75,7 @@
)
from ${this.tableName('counter_view')}
`);
- if (maxDurResult.numRecords === 1) {
+ if (slowlyCountRows(maxDurResult) === 1) {
this.maxDurNs = maxDurResult.columns[0].longValues![0];
}
diff --git a/ui/src/tracks/cpu_profile/controller.ts b/ui/src/tracks/cpu_profile/controller.ts
index cb850ee..fa9a6b3 100644
--- a/ui/src/tracks/cpu_profile/controller.ts
+++ b/ui/src/tracks/cpu_profile/controller.ts
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import {slowlyCountRows} from '../../common/query_iterator';
import {
TrackController,
trackControllerRegistry
@@ -33,7 +34,7 @@
const result = await this.query(query);
- const numRows = +result.numRecords;
+ const numRows = slowlyCountRows(result);
const data: Data = {
start,
end,
diff --git a/ui/src/tracks/cpu_slices/controller.ts b/ui/src/tracks/cpu_slices/controller.ts
index a3af7f9..1389cb4 100644
--- a/ui/src/tracks/cpu_slices/controller.ts
+++ b/ui/src/tracks/cpu_slices/controller.ts
@@ -13,6 +13,7 @@
// limitations under the License.
import {assertTrue} from '../../base/logging';
+import {slowlyCountRows} from '../../common/query_iterator';
import {fromNs, toNs} from '../../common/time';
import {
TrackController,
@@ -104,7 +105,7 @@
order by tsq
`);
- const numRows = +rawResult.numRecords;
+ const numRows = slowlyCountRows(rawResult);
const slices: Data = {
start,
end,
diff --git a/ui/src/tracks/debug_slices/controller.ts b/ui/src/tracks/debug_slices/controller.ts
index 9395ebb..6471de0 100644
--- a/ui/src/tracks/debug_slices/controller.ts
+++ b/ui/src/tracks/debug_slices/controller.ts
@@ -14,6 +14,7 @@
import {assertTrue} from '../../base/logging';
import {Actions} from '../../common/actions';
+import {slowlyCountRows} from '../../common/query_iterator';
import {fromNs, toNs} from '../../common/time';
import {globals} from '../../controller/globals';
import {
@@ -28,8 +29,9 @@
async onReload() {
const rawResult = await this.query(`select max(depth) from debug_slices`);
- const maxDepth =
- (rawResult.numRecords === 0) ? 1 : rawResult.columns[0].longValues![0];
+ const maxDepth = (slowlyCountRows(rawResult) === 0) ?
+ 1 :
+ rawResult.columns[0].longValues![0];
globals.dispatch(
Actions.updateTrackConfig({id: this.trackId, config: {maxDepth}}));
}
@@ -46,7 +48,7 @@
const tsValues = tsCol.longValues! || tsCol.doubleValues!;
const durValues = durCol.longValues! || durCol.doubleValues!;
- const numRows = rawResult.numRecords;
+ const numRows = slowlyCountRows(rawResult);
const slices: Data = {
start,
end,
@@ -72,7 +74,7 @@
return idx;
}
- for (let i = 0; i < rawResult.numRecords; i++) {
+ for (let i = 0; i < slowlyCountRows(rawResult); i++) {
let sliceStart: number, sliceEnd: number;
if (tsCol.isNulls![i] || durCol.isNulls![i]) {
sliceStart = sliceEnd = -1;
diff --git a/ui/src/tracks/heap_profile/controller.ts b/ui/src/tracks/heap_profile/controller.ts
index bab0b15..2422af1 100644
--- a/ui/src/tracks/heap_profile/controller.ts
+++ b/ui/src/tracks/heap_profile/controller.ts
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import {slowlyCountRows} from '../../common/query_iterator';
import {
TrackController,
trackControllerRegistry
@@ -45,7 +46,7 @@
select distinct(graph_sample_ts) as ts, 'graph' as type from
heap_graph_object
where upid = ${this.config.upid}) order by ts`);
- const numRows = +result.numRecords;
+ const numRows = slowlyCountRows(result);
const data: Data = {
start,
end,
diff --git a/ui/src/tracks/process_scheduling/controller.ts b/ui/src/tracks/process_scheduling/controller.ts
index c2bc6a8..c7676ed 100644
--- a/ui/src/tracks/process_scheduling/controller.ts
+++ b/ui/src/tracks/process_scheduling/controller.ts
@@ -14,6 +14,7 @@
import {assertTrue} from '../../base/logging';
import {RawQueryResult} from '../../common/protos';
+import {slowlyCountRows} from '../../common/query_iterator';
import {fromNs, toNs} from '../../common/time';
import {
TrackController,
@@ -89,7 +90,7 @@
const rawResult = await this.queryData(startNs, endNs, bucketNs);
- const numRows = +rawResult.numRecords;
+ const numRows = slowlyCountRows(rawResult);
const slices: Data = {
kind: 'slice',
start,
diff --git a/ui/src/tracks/process_summary/controller.ts b/ui/src/tracks/process_summary/controller.ts
index fa6c98d..75242fe 100644
--- a/ui/src/tracks/process_summary/controller.ts
+++ b/ui/src/tracks/process_summary/controller.ts
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import {slowlyCountRows} from '../../common/query_iterator';
import {fromNs, toNs} from '../../common/time';
import {LIMIT} from '../../common/track_data';
-
import {
TrackController,
trackControllerRegistry
@@ -99,7 +99,7 @@
limit ${LIMIT}`;
const rawResult = await this.query(query);
- const numRows = +rawResult.numRecords;
+ const numRows = slowlyCountRows(rawResult);
const summary: Data = {
start,
diff --git a/ui/src/tracks/thread_state/controller.ts b/ui/src/tracks/thread_state/controller.ts
index ccabed3..dc77907 100644
--- a/ui/src/tracks/thread_state/controller.ts
+++ b/ui/src/tracks/thread_state/controller.ts
@@ -13,6 +13,7 @@
// limitations under the License.
import {assertFalse} from '../../base/logging';
+import {slowlyCountRows} from '../../common/query_iterator';
import {translateState} from '../../common/thread_state';
import {fromNs, toNs} from '../../common/time';
import {
@@ -81,7 +82,7 @@
`;
const result = await this.query(query);
- const numRows = +result.numRecords;
+ const numRows = slowlyCountRows(result);
const data: Data = {
start,