From fb1f0c646956ecb9571c6aa9407a3c4455948900 Mon Sep 17 00:00:00 2001 From: Bruce Martin Date: Fri, 21 Feb 2020 14:14:41 -0700 Subject: [PATCH] fix latent crossfilter bug (#1162) --- .../util/typedCrossfilter/bitArray.test.js | 21 +++++++++++++++++++ client/src/util/typedCrossfilter/bitArray.js | 1 + 2 files changed, 22 insertions(+) diff --git a/client/__tests__/util/typedCrossfilter/bitArray.test.js b/client/__tests__/util/typedCrossfilter/bitArray.test.js index e4b3e305..3a712328 100644 --- a/client/__tests__/util/typedCrossfilter/bitArray.test.js +++ b/client/__tests__/util/typedCrossfilter/bitArray.test.js @@ -183,3 +183,24 @@ describe("fillBySelection", () => { expect(arr).toEqual(truth); }); }); + +describe("wide bitarray", () => { + test.each([9, 30, 31, 32, 33, 54, 63, 64, 65, 127, 128, 129])( + "more than %d dimensions", + ndim => { + /* ensure we move across the uint boundary correctly */ + + const ba = new BitArray(defaultTestLength); + expect(ba).toBeDefined(); + + for (let i = 0; i < ndim; i += 1) { + expect(ba.allocDimension()).toEqual(i); + } + ba.freeDimension(0); + expect(ba.allocDimension()).toEqual(0); + + ba.freeDimension(ndim - 1); + expect(ba.allocDimension()).toEqual(ndim - 1); + } + ); +}); diff --git a/client/src/util/typedCrossfilter/bitArray.js b/client/src/util/typedCrossfilter/bitArray.js index 3db06c1c..89470e22 100644 --- a/client/src/util/typedCrossfilter/bitArray.js +++ b/client/src/util/typedCrossfilter/bitArray.js @@ -98,6 +98,7 @@ class BitArray { if (lowestZeroBit) { this.bitmask[col] |= lowestZeroBit; dim = 32 * col + BitArray.ctz(lowestZeroBit); + break; } } return dim;