Skip to content

Commit afb40a9

Browse files
authored
apacheGH-39259: [JS] Remove getByteLength (apache#39260)
* Closes: apache#39259
1 parent 9b931af commit afb40a9

File tree

5 files changed

+3
-203
lines changed

5 files changed

+3
-203
lines changed

js/src/recordbatch.ts

-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { instance as getVisitor } from './visitor/get.js';
2525
import { instance as setVisitor } from './visitor/set.js';
2626
import { instance as indexOfVisitor } from './visitor/indexof.js';
2727
import { instance as iteratorVisitor } from './visitor/iterator.js';
28-
import { instance as byteLengthVisitor } from './visitor/bytelength.js';
2928

3029
/** @ignore */
3130
export interface RecordBatch<T extends TypeMap = any> {
@@ -150,14 +149,6 @@ export class RecordBatch<T extends TypeMap = any> {
150149
return indexOfVisitor.visit(this.data, element, offset);
151150
}
152151

153-
/**
154-
* Get the size (in bytes) of a row by index.
155-
* @param index The row index for which to compute the byteLength.
156-
*/
157-
public getByteLength(index: number): number {
158-
return byteLengthVisitor.visit(this.data, index);
159-
}
160-
161152
/**
162153
* Iterator for rows in this RecordBatch.
163154
*/

js/src/table.ts

-9
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import { instance as getVisitor } from './visitor/get.js';
3838
import { instance as setVisitor } from './visitor/set.js';
3939
import { instance as indexOfVisitor } from './visitor/indexof.js';
4040
import { instance as iteratorVisitor } from './visitor/iterator.js';
41-
import { instance as byteLengthVisitor } from './visitor/bytelength.js';
4241

4342
import { DataProps } from './data.js';
4443
import { clampRange } from './util/vector.js';
@@ -215,13 +214,6 @@ export class Table<T extends TypeMap = any> {
215214
// @ts-ignore
216215
public indexOf(element: Struct<T>['TValue'], offset?: number): number { return -1; }
217216

218-
/**
219-
* Get the size in bytes of an element by index.
220-
* @param index The index at which to get the byteLength.
221-
*/
222-
// @ts-ignore
223-
public getByteLength(index: number): number { return 0; }
224-
225217
/**
226218
* Iterator for rows in this Table.
227219
*/
@@ -390,7 +382,6 @@ export class Table<T extends TypeMap = any> {
390382
(proto as any)['get'] = wrapChunkedCall1(getVisitor.getVisitFn(Type.Struct));
391383
(proto as any)['set'] = wrapChunkedCall2(setVisitor.getVisitFn(Type.Struct));
392384
(proto as any)['indexOf'] = wrapChunkedIndexOf(indexOfVisitor.getVisitFn(Type.Struct));
393-
(proto as any)['getByteLength'] = wrapChunkedCall1(byteLengthVisitor.getVisitFn(Type.Struct));
394385
return 'Table';
395386
})(Table.prototype);
396387
}

js/src/vector.ts

+3-14
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import { instance as getVisitor } from './visitor/get.js';
3636
import { instance as setVisitor } from './visitor/set.js';
3737
import { instance as indexOfVisitor } from './visitor/indexof.js';
3838
import { instance as iteratorVisitor } from './visitor/iterator.js';
39-
import { instance as byteLengthVisitor } from './visitor/bytelength.js';
4039

4140
// @ts-ignore
4241
import type { vectorFromArray } from './factories.js';
@@ -56,7 +55,7 @@ export interface Vector<T extends DataType = any> {
5655
[Symbol.isConcatSpreadable]: true;
5756
}
5857

59-
const visitorsByTypeId = {} as { [typeId: number]: { get: any; set: any; indexOf: any; byteLength: any } };
58+
const visitorsByTypeId = {} as { [typeId: number]: { get: any; set: any; indexOf: any } };
6059
const vectorPrototypesByTypeId = {} as { [typeId: number]: any };
6160

6261
/**
@@ -76,14 +75,13 @@ export class Vector<T extends DataType = any> {
7675
case 0: this._offsets = [0]; break;
7776
case 1: {
7877
// special case for unchunked vectors
79-
const { get, set, indexOf, byteLength } = visitorsByTypeId[type.typeId];
78+
const { get, set, indexOf } = visitorsByTypeId[type.typeId];
8079
const unchunkedData = data[0];
8180

8281
this.isValid = (index: number) => isChunkedValid(unchunkedData, index);
8382
this.get = (index: number) => get(unchunkedData, index);
8483
this.set = (index: number, value: T) => set(unchunkedData, index, value);
8584
this.indexOf = (index: number) => indexOf(unchunkedData, index);
86-
this.getByteLength = (index: number) => byteLength(unchunkedData, index);
8785
this._offsets = [0, unchunkedData.length];
8886
break;
8987
}
@@ -200,13 +198,6 @@ export class Vector<T extends DataType = any> {
200198
return this.indexOf(element, offset) > -1;
201199
}
202200

203-
/**
204-
* Get the size in bytes of an element by index.
205-
* @param index The index at which to get the byteLength.
206-
*/
207-
// @ts-ignore
208-
public getByteLength(index: number): number { return 0; }
209-
210201
/**
211202
* Iterator for the Vector's elements.
212203
*/
@@ -366,15 +357,13 @@ export class Vector<T extends DataType = any> {
366357
const get = getVisitor.getVisitFnByTypeId(typeId);
367358
const set = setVisitor.getVisitFnByTypeId(typeId);
368359
const indexOf = indexOfVisitor.getVisitFnByTypeId(typeId);
369-
const byteLength = byteLengthVisitor.getVisitFnByTypeId(typeId);
370360

371-
visitorsByTypeId[typeId] = { get, set, indexOf, byteLength };
361+
visitorsByTypeId[typeId] = { get, set, indexOf };
372362
vectorPrototypesByTypeId[typeId] = Object.create(proto, {
373363
['isValid']: { value: wrapChunkedCall1(isChunkedValid) },
374364
['get']: { value: wrapChunkedCall1(getVisitor.getVisitFnByTypeId(typeId)) },
375365
['set']: { value: wrapChunkedCall2(setVisitor.getVisitFnByTypeId(typeId)) },
376366
['indexOf']: { value: wrapChunkedIndexOf(indexOfVisitor.getVisitFnByTypeId(typeId)) },
377-
['getByteLength']: { value: wrapChunkedCall1(byteLengthVisitor.getVisitFnByTypeId(typeId)) },
378367
});
379368
}
380369

js/src/visitor/bytelength.ts

-164
This file was deleted.

js/test/unit/table-tests.ts

-7
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,6 @@ describe(`Table`, () => {
369369
}
370370
}
371371
});
372-
373-
test(`table.getByteLength() returns the byteLength of each row`, () => {
374-
const table = datum.table();
375-
for (let i = -1, n = table.numRows; ++i < n;) {
376-
expect(table.getByteLength(i)).toBeGreaterThan(0);
377-
}
378-
});
379372
});
380373
}
381374
});

0 commit comments

Comments
 (0)