Skip to content

Commit e093772

Browse files
trxcllntwesm
authored andcommitted
ARROW-1544: [JS] Export Vector types
Resolves https://issues.apache.org/jira/browse/ARROW-1544 Author: Paul Taylor <paul.e.taylor@me.com> Closes apache#1103 from trxcllnt/js-export-vector-typedefs and squashes the following commits: 91a0625 [Paul Taylor] use gulp 4 from github. thought 4-alpha was on npm already. e5a1034 [Paul Taylor] fix jest test coverage script c6b09ee [Paul Taylor] export Vector types on root Arrow export 032ad27 [Paul Taylor] add compileOnSave (now required by TS 2.5?) eb96552 [Paul Taylor] update dependencies
1 parent bfe6579 commit e093772

8 files changed

Lines changed: 181 additions & 203 deletions

File tree

js/gulpfile.js

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function runTaskCombos(name) {
8484
}
8585

8686
function cleanTask(target, format, taskName, outDir) {
87-
return () => {
87+
return function cleanTask() {
8888
const globs = [`${outDir}/**`];
8989
if (target === `es5` && format === `cjs`) {
9090
globs.push(`typings`);
@@ -102,25 +102,27 @@ function buildTask(target, format, taskName, outDir) {
102102
function bundleTask(target, format, taskName, outDir) {
103103
return [
104104
[`build:${taskName}`],
105-
(cb) => streamMerge([
106-
pump(gulp.src([`LICENSE`, `README.md`, `CHANGELOG.md`]), gulp.dest(outDir)),
107-
pump(
108-
gulp.src(`package.json`),
109-
gulpJsonTransform((orig) => [
110-
`version`, `description`,
111-
`author`, `homepage`, `bugs`, `license`,
112-
`keywords`, `repository`, `peerDependencies`
113-
].reduce((copy, key) => (
114-
(copy[key] = orig[key]) && copy || copy
115-
), {
116-
main: `Arrow.js`,
117-
typings: `Arrow.d.ts`,
118-
name: `@apache-arrow/${target}-${format}`
119-
}), 2),
120-
gulp.dest(outDir),
121-
onError
122-
)
123-
])
105+
function bundleTask() {
106+
return streamMerge([
107+
pump(gulp.src([`LICENSE`, `README.md`]), gulp.dest(outDir), onError),
108+
pump(
109+
gulp.src(`package.json`),
110+
gulpJsonTransform((orig) => [
111+
`version`, `description`,
112+
`author`, `homepage`, `bugs`, `license`,
113+
`keywords`, `repository`, `peerDependencies`
114+
].reduce((copy, key) => (
115+
(copy[key] = orig[key]) && copy || copy
116+
), {
117+
main: `Arrow.js`,
118+
typings: `Arrow.d.ts`,
119+
name: `@apache-arrow/${target}-${format}`
120+
}), 2),
121+
gulp.dest(outDir),
122+
onError
123+
)
124+
])
125+
}
124126
];
125127
}
126128

@@ -138,9 +140,11 @@ function testTask(target, format, taskName, outDir, debug) {
138140
TEST_TARGET: target, TEST_MODULE: format
139141
})
140142
};
141-
return () => !debug ?
142-
child_process.spawn(jestPath, jestOptions, spawnOptions) :
143-
child_process.exec(`node --inspect-brk ${jestPath} ${debugOpts}`, spawnOptions);
143+
return function testTask() {
144+
return !debug ?
145+
child_process.spawn(jestPath, jestOptions, spawnOptions) :
146+
child_process.exec(`node --inspect-brk ${jestPath} ${debugOpts}`, spawnOptions);
147+
}
144148
}
145149

146150
function closureTask(target, format, taskName, outDir) {
@@ -149,38 +153,36 @@ function closureTask(target, format, taskName, outDir) {
149153
const languageIn = clsTarget === `es5` ? `es2015` : clsTarget;
150154
return [
151155
[`clean:${taskName}`, `build:${clsTarget}:cls`],
152-
() => {
153-
return streamMerge([
154-
closureStream(closureSrcs(false), `Arrow`, onError, true),
155-
closureStream(closureSrcs(true), `Arrow.internal`, onError)
156-
])
157-
.on('end', () => del([`targets/${target}/cls/**`]));
156+
function closureTask() {
157+
return closureStream(
158+
closureSrcs(),
159+
closureCompiler(closureArgs())
160+
).on('end', () => del([`targets/${target}/cls/**`]));
158161
}
159162
];
160-
function closureSrcs(isInternal) {
163+
function closureSrcs() {
161164
return gulp.src([
162165
`closure-compiler-scripts/*.js`,
163166
`${googleRoot}/**/*.js`,
164167
`!${googleRoot}/format/*.js`,
165168
`!${googleRoot}/Arrow.externs.js`,
166-
`!${googleRoot}/Arrow${isInternal ? `` : `.internal`}.js`
167169
], { base: `./` });
168170
}
169-
function closureStream(sources, entry, onError, copyToDist) {
171+
function closureStream(sources, compiler) {
170172
const streams = [
171173
sources,
172174
sourcemaps.init(),
173-
closureCompiler(closureArgs(entry)),
175+
compiler,
174176
sourcemaps.write('.'),
175177
gulp.dest(outDir)
176178
];
177-
// copy the UMD bundle to dist
178-
if (target === `es5` && copyToDist) {
179+
// copy the ES5 UMD bundle to dist
180+
if (target === `es5`) {
179181
streams.push(gulp.dest(`dist`));
180182
}
181183
return pump(...streams, onError);
182184
}
183-
function closureArgs(entry) {
185+
function closureArgs() {
184186
return {
185187
third_party: true,
186188
externs: `${googleRoot}/Arrow.externs.js`,
@@ -190,10 +192,10 @@ function closureTask(target, format, taskName, outDir) {
190192
// formatting: `PRETTY_PRINT`,
191193
compilation_level: `ADVANCED`,
192194
assume_function_wrapper: true,
193-
js_output_file: `${entry}.js`,
195+
js_output_file: `Arrow.js`,
194196
language_in: gCCTargets[languageIn],
195197
language_out: gCCTargets[clsTarget],
196-
entry_point: `${googleRoot}/${entry}.js`,
198+
entry_point: `${googleRoot}/Arrow.js`,
197199
output_wrapper:
198200
`// Licensed to the Apache Software Foundation (ASF) under one
199201
// or more contributor license agreements. See the NOTICE file
@@ -223,7 +225,7 @@ function closureTask(target, format, taskName, outDir) {
223225
function typescriptTask(target, format, taskName, outDir) {
224226
return [
225227
[`clean:${taskName}`],
226-
() => {
228+
function typescriptTask() {
227229
const tsconfigPath = `tsconfig/tsconfig.${target}.${format}.json`;
228230
let { js, dts } = tsProjects.find((p) => p.target === target && p.format === format) || {};
229231
if (!js || !dts) {

js/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,28 @@
7373
"del": "~3.0.0",
7474
"esdoc": "~1.0.1",
7575
"esdoc-standard-plugin": "~1.0.0",
76-
"google-closure-compiler": "~20170806.0.0",
76+
"google-closure-compiler": "~20170910.0.0",
7777
"gulp": "github:gulpjs/gulp#4.0",
7878
"gulp-json-transform": "~0.4.2",
7979
"gulp-sourcemaps": "~2.6.1",
8080
"gulp-typescript": "~3.2.2",
81-
"jest": "~20.0.4",
81+
"jest": "~21.1.0",
8282
"jest-environment-node-debug": "~2.0.0",
8383
"json": "~9.0.6",
84-
"lerna": "2.0.0",
85-
"lint-staged": "~4.0.1",
86-
"merge2": "~1.1.0",
84+
"lerna": "~2.1.2",
85+
"lint-staged": "~4.2.1",
86+
"merge2": "~1.2.0",
8787
"mkdirp": "~0.5.1",
88-
"npm-run-all": "~4.0.2",
88+
"npm-run-all": "~4.1.1",
8989
"pump": "~1.0.2",
9090
"rimraf": "~2.6.1",
9191
"shx": "~0.2.2",
9292
"text-encoding-utf-8": "~1.0.1",
9393
"trash": "~4.0.1",
94-
"ts-jest": "~20.0.10",
94+
"ts-jest": "~21.0.1",
9595
"tslib": "~1.7.1",
96-
"tslint": "~5.6.0",
97-
"typescript": "~2.4.2",
96+
"tslint": "~5.7.0",
97+
"typescript": "~2.5.2",
9898
"validate-commit-msg": "~2.14.0"
9999
},
100100
"config": {
@@ -129,7 +129,8 @@
129129
],
130130
"coveragePathIgnorePatterns": [
131131
"format\\/(File|Message|Schema|Tensor)_generated\\.(js|ts)$",
132-
"test\\/.*\\.(ts|tsx|js)$"
132+
"test\\/.*\\.(ts|tsx|js)$",
133+
"/node_modules/"
133134
],
134135
"transform": {
135136
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js",

js/src/Arrow.externs.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Symbol.iterator;
2626
Symbol.asyncIterator;
2727
let Table = function() {};
2828
/** @type {?} */
29+
Table.prototype.length;
30+
/** @type {?} */
2931
Table.prototype.rows;
3032
/** @type {?} */
3133
Table.prototype.cols;
@@ -65,3 +67,9 @@ TypedVector.prototype.arrayType;
6567
let ValidityVector = function() {};
6668
/** @type {?} */
6769
(<any> ValidityVector).pack;
70+
71+
let DictionaryVector = function() {};
72+
/** @type {?} */
73+
DictionaryVector.prototype.index;
74+
/** @type {?} */
75+
DictionaryVector.prototype.value;

js/src/Arrow.internal.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

js/src/Arrow.ts

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,43 @@
1717

1818
import { Table } from './table';
1919
import { readBuffers } from './reader/arrow';
20-
export { Table, readBuffers };
20+
import { Vector } from './vector/vector';
21+
import { StructVector } from './vector/struct';
22+
import { DictionaryVector } from './vector/dictionary';
23+
import { ListVector, Utf8Vector, FixedSizeListVector } from './vector/list';
24+
import {
25+
TypedVector, BitVector,
26+
DateVector, IndexVector,
27+
Int8Vector, Int16Vector,
28+
Int32Vector, Int64Vector,
29+
Uint8Vector, Uint16Vector,
30+
Uint32Vector, Uint64Vector,
31+
Float32Vector, Float64Vector,
32+
} from './vector/typed';
33+
34+
export {
35+
Table, readBuffers,
36+
Vector,
37+
BitVector,
38+
ListVector,
39+
Utf8Vector,
40+
DateVector,
41+
IndexVector,
42+
TypedVector,
43+
Int8Vector,
44+
Int16Vector,
45+
Int32Vector,
46+
Int64Vector,
47+
Uint8Vector,
48+
Uint16Vector,
49+
Uint32Vector,
50+
Uint64Vector,
51+
Float32Vector,
52+
Float64Vector,
53+
StructVector,
54+
DictionaryVector,
55+
FixedSizeListVector,
56+
};
2157

2258
/* These exports are needed for the closure umd targets */
2359
try {
@@ -26,6 +62,26 @@ try {
2662
// string indexers tell closure compiler not to rename these properties
2763
Arrow['Table'] = Table;
2864
Arrow['readBuffers'] = readBuffers;
65+
Arrow['Vector'] = Vector;
66+
Arrow['BitVector'] = BitVector;
67+
Arrow['ListVector'] = ListVector;
68+
Arrow['Utf8Vector'] = Utf8Vector;
69+
Arrow['DateVector'] = DateVector;
70+
Arrow['IndexVector'] = IndexVector;
71+
Arrow['TypedVector'] = TypedVector;
72+
Arrow['Int8Vector'] = Int8Vector;
73+
Arrow['Int16Vector'] = Int16Vector;
74+
Arrow['Int32Vector'] = Int32Vector;
75+
Arrow['Int64Vector'] = Int64Vector;
76+
Arrow['Uint8Vector'] = Uint8Vector;
77+
Arrow['Uint16Vector'] = Uint16Vector;
78+
Arrow['Uint32Vector'] = Uint32Vector;
79+
Arrow['Uint64Vector'] = Uint64Vector;
80+
Arrow['Float32Vector'] = Float32Vector;
81+
Arrow['Float64Vector'] = Float64Vector;
82+
Arrow['StructVector'] = StructVector;
83+
Arrow['DictionaryVector'] = DictionaryVector;
84+
Arrow['FixedSizeListVector'] = FixedSizeListVector;
2985
}
3086
} catch (e) { /* not the UMD bundle */ }
31-
/** end closure exports */
87+
/* end closure exports */

0 commit comments

Comments
 (0)