Skip to content

Commit

Permalink
Allow selecting counter under time quantization.
Browse files Browse the repository at this point in the history
 - Bug: http://b/149959272. #1.
  • Loading branch information
stellama0208 committed Feb 21, 2020
1 parent 1407613 commit 56ea342
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class CounterTrack extends Track.WithQueryEngine<CounterTrack.Data> {
"(select *, first_value(id) over (partition by quantum_ts order by dur desc) as best_id from %s) " +
"group by quantum_ts";
private static final String COUNTER_SQL = "select ts, ts + dur, value, id from %s";
private static final String VALUE_SQL = "select ts, ts + dur, value, id from %s where ts = %d";
private static final String VALUE_SQL = "select ts, ts + dur, value, id from %s where id = %d";
private static final String RANGE_SQL =
"select ts, ts + dur, value, id from %s " +
"where ts + dur >= %d and ts <= %d order by ts";
Expand Down Expand Up @@ -123,8 +123,8 @@ private String counterSQL() {
return format(COUNTER_SQL, tableName("span"));
}

public ListenableFuture<Data> getValue(long t) {
return transform(expectOneRow(qe.query(valueSql(t))), row -> {
public ListenableFuture<Data> getValue(long id) {
return transform(expectOneRow(qe.query(valueSql(id))), row -> {
Data data = new Data(null, new long[2], new double[2], new long[2]);
data.ts[0] = row.getLong(0);
data.ts[1] = row.getLong(1);
Expand Down Expand Up @@ -156,8 +156,8 @@ public ListenableFuture<Data> getValues(TimeSpan ts) {
});
}

private String valueSql(long t) {
return format(VALUE_SQL, tableName("vals"), t);
private String valueSql(long id) {
return format(VALUE_SQL, tableName("vals"), id);
}

private String rangeSql(TimeSpan ts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected Hover onTrackMouseMove(Fonts.TextMeasurer m, double x, double y, int m
return Hover.NONE;
}

long t = data.ts[idx];
long id = data.ids[idx];
double startX = state.timeToPx(data.ts[idx]);
double endX = (idx >= data.ts.length - 1) ? startX : state.timeToPx(data.ts[idx + 1]);
hovered = new HoverCard(m, track.getCounter(), data.values[idx], startX, endX, x);
Expand All @@ -202,10 +202,10 @@ public void stop() {
public boolean click() {
if ((mods & SWT.MOD1) == SWT.MOD1) {
state.addSelection(Selection.Kind.Counter,
transform(track.getValue(t), d -> new CounterTrack.Values(track.getCounter().name, d)));
transform(track.getValue(id), d -> new CounterTrack.Values(track.getCounter().name, d)));
} else {
state.setSelection(Selection.Kind.Counter,
transform(track.getValue(t), d -> new CounterTrack.Values(track.getCounter().name, d)));
transform(track.getValue(id), d -> new CounterTrack.Values(track.getCounter().name, d)));
}
return true;
}
Expand Down

0 comments on commit 56ea342

Please sign in to comment.