Skip to content

Commit 87334a5

Browse files
committed
Merge branch 'table-scan-perf' of github.com:ccri/arrow into js-cpp-refactor
2 parents b7f5bfb + 0620cfd commit 87334a5

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

js/src/table.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class Table implements DataFrame {
130130
}
131131
}
132132
}
133-
public count(): number { return this.batchesUnion.length; }
133+
public count(): number { return this.length; }
134134
public countBy(name: Col | string): CountByResult {
135135
const batches = this.batches, numBatches = batches.length;
136136
const count_by = typeof name === 'string' ? new Col(name) : name;
@@ -264,7 +264,7 @@ export class CountByResult extends Table implements DataFrame {
264264
counts.length, [values, counts]
265265
));
266266
}
267-
public asJSON(): Object {
267+
public toJSON(): Object {
268268
const [values, counts] = this.columns;
269269
const result = {} as { [k: string]: number | null };
270270
for (let i = -1; ++i < this.length;) {

js/test/unit/table-tests.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ describe(`Table`, () => {
118118
// Wrap floating point values in a Float32Array and take them back out to
119119
// make sure that equality checks will pass
120120
const values = [
121-
[new Float32Array([-0.3])[0], -1, 'a'],
122-
[new Float32Array([-0.2])[0], 1, 'b'],
123-
[new Float32Array([-0.1])[0], -1, 'c'],
124-
[new Float32Array([ 0 ])[0], 1, 'a'],
125-
[new Float32Array([ 0.1])[0], -1, 'b'],
126-
[new Float32Array([ 0.2])[0], 1, 'c'],
127-
[new Float32Array([ 0.3])[0], -1, 'a']
121+
[Math.fround(-0.3), -1, 'a'],
122+
[Math.fround(-0.2), 1, 'b'],
123+
[Math.fround(-0.1), -1, 'c'],
124+
[Math.fround( 0 ), 1, 'a'],
125+
[Math.fround( 0.1), -1, 'b'],
126+
[Math.fround( 0.2), 1, 'c'],
127+
[Math.fround( 0.3), -1, 'a']
128128
];
129129
test(`has the correct length`, () => {
130130
expect(table.length).toEqual(values.length);
@@ -161,19 +161,19 @@ describe(`Table`, () => {
161161
test(`countBy on dictionary returns the correct counts`, () => {
162162
// Make sure countBy works both with and without the Col wrapper
163163
// class
164-
expect(table.countBy(col('dictionary')).asJSON()).toEqual({
164+
expect(table.countBy(col('dictionary')).toJSON()).toEqual({
165165
'a': 3,
166166
'b': 2,
167167
'c': 2,
168168
});
169-
expect(table.countBy('dictionary').asJSON()).toEqual({
169+
expect(table.countBy('dictionary').toJSON()).toEqual({
170170
'a': 3,
171171
'b': 2,
172172
'c': 2,
173173
});
174174
});
175175
test(`countBy on dictionary with filter returns the correct counts`, () => {
176-
expect(table.filter(col('i32').eq(1)).countBy('dictionary').asJSON()).toEqual({
176+
expect(table.filter(col('i32').eq(1)).countBy('dictionary').toJSON()).toEqual({
177177
'a': 1,
178178
'b': 1,
179179
'c': 1,
@@ -321,15 +321,15 @@ describe(`Table`, () => {
321321
// Wrap floating point values in a Float32Array and take them back out to
322322
// make sure that equality checks will pass
323323
const values = [
324-
[new Float32Array([-0.3])[0], -1, 'a'],
325-
[new Float32Array([-0.2])[0], 1, 'b'],
326-
[new Float32Array([-0.1])[0], -1, 'c'],
327-
[new Float32Array([ 0 ])[0], 1, 'a'],
328-
[new Float32Array([ 0.1])[0], -1, 'b'],
329-
[new Float32Array([ 0.2])[0], 1, 'c'],
330-
[new Float32Array([ 0.3])[0], -1, 'a'],
331-
[new Float32Array([ 0.2])[0], 1, 'b'],
332-
[new Float32Array([ 0.1])[0], -1, 'c'],
324+
[Math.fround(-0.3), -1, 'a'],
325+
[Math.fround(-0.2), 1, 'b'],
326+
[Math.fround(-0.1), -1, 'c'],
327+
[Math.fround( 0 ), 1, 'a'],
328+
[Math.fround( 0.1), -1, 'b'],
329+
[Math.fround( 0.2), 1, 'c'],
330+
[Math.fround( 0.3), -1, 'a'],
331+
[Math.fround( 0.2), 1, 'b'],
332+
[Math.fround( 0.1), -1, 'c'],
333333
];
334334
test(`has the correct length`, () => {
335335
expect(table.length).toEqual(values.length);
@@ -366,19 +366,19 @@ describe(`Table`, () => {
366366
test(`countBy on dictionary returns the correct counts`, () => {
367367
// Make sure countBy works both with and without the Col wrapper
368368
// class
369-
expect(table.countBy(col('dictionary')).asJSON()).toEqual({
369+
expect(table.countBy(col('dictionary')).toJSON()).toEqual({
370370
'a': 3,
371371
'b': 3,
372372
'c': 3,
373373
});
374-
expect(table.countBy('dictionary').asJSON()).toEqual({
374+
expect(table.countBy('dictionary').toJSON()).toEqual({
375375
'a': 3,
376376
'b': 3,
377377
'c': 3,
378378
});
379379
});
380380
test(`countBy on dictionary with filter returns the correct counts`, () => {
381-
expect(table.filter(col('i32').eq(1)).countBy(col('dictionary')).asJSON()).toEqual({
381+
expect(table.filter(col('i32').eq(1)).countBy(col('dictionary')).toJSON()).toEqual({
382382
'a': 1,
383383
'b': 2,
384384
'c': 1,

0 commit comments

Comments
 (0)