Skip to content

Commit

Permalink
Add limit to autocomplete generation
Browse files Browse the repository at this point in the history
  • Loading branch information
sc1f authored and texodus committed Jan 30, 2021
1 parent 50ac870 commit 7a33089
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions cpp/perspective/src/cpp/arrow_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ namespace apachearrow {
arrow::TimestampParser::MakeStrptime("%m-%d-%Y"),
arrow::TimestampParser::MakeStrptime("%m/%d/%Y"),
arrow::TimestampParser::MakeStrptime("%d %m %Y"),
// TODO: time type column
arrow::TimestampParser::MakeStrptime("%H:%M:%S.%f")};

std::vector<std::shared_ptr<arrow::TimestampParser>> DATE_READERS{
Expand Down
20 changes: 16 additions & 4 deletions packages/perspective-viewer/src/js/viewer/dom_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,22 @@ export class DomElement extends PerspectiveElement {
columns: [],
computed_columns: computed_names.includes(name) ? computed_columns : []
});
view.to_json().then(json => {
row.choices(this._autocomplete_choices(json, type));
});
view.delete();

view.num_rows()
.then(async nrows => {
if (nrows < 100000) {
// Autocomplete
const json = await view.to_json({
end_row: 10
});
row.choices(this._autocomplete_choices(json, type));
} else {
console.warn(`perspective-viewer did not generate autocompletion results - ${nrows} is greater than limit of 100,000 rows.`);
}
})
.finally(() => {
view.delete();
});
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/perspective-viewer/test/js/simple_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ exports.default = function(method = "capture") {
const viewer = await page.$("perspective-viewer");
await page.shadow_click("perspective-viewer", "#config_button");
await page.evaluate(element => element.setAttribute("filters", '[["Order Date", ">", "01/01/2012"]]'), viewer);
await page.waitForSelector("perspective-viewer:not([updating])");
});

test[method]("highlights invalid filter.", async page => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ def test_table_row_pivot_datetime_row_path_local_time_EST(self):
def test_table_row_pivot_datetime_row_path_UTC(self):
"""Make sure that string datetimes generated in Python are in
UTC if the timezone is UTC.
Set the timezone before creating the table so that the local
datetime is in the intended timezone, as this test asserts that
paths in the same timezone are not edited to UTC."""
Expand Down
9 changes: 4 additions & 5 deletions scripts/test_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/

const {bash, execute, getarg, docker} = require("./script_utils.js");
const {bash, execute, execute_throw, getarg, docker} = require("./script_utils.js");
const fs = require("fs");

const DEBUG_FLAG = getarg("--debug") ? "" : "--silent";
Expand Down Expand Up @@ -83,7 +83,6 @@ function jest_timezone() {
return bash`
node_modules/.bin/lerna exec
--concurrency 1
--no-bail
--scope="@finos/perspective"
--
yarn test_timezone:run
Expand Down Expand Up @@ -115,18 +114,18 @@ try {
if (getarg("--quiet")) {
// Run all tests with suppressed output.
console.log("-- Running test suite in quiet mode");
execute(silent(jest_timezone()));
execute_throw(silent(jest_timezone()));
execute(silent(jest_all()));
} else if (process.env.PACKAGE) {
// Run tests for a single package.
if (PACKAGE === "perspective") {
execute(jest_timezone());
execute_throw(jest_timezone());
}
execute(jest_single());
} else {
// Run all tests with full output.
console.log("-- Running test suite in fast mode");
execute(jest_timezone());
execute_throw(jest_timezone());
execute(jest_all());
}
}
Expand Down

0 comments on commit 7a33089

Please sign in to comment.