Skip to content

Commit 25e6af7

Browse files
author
Brian Hulette
committed
Create predicate namespace
1 parent 016ba78 commit 25e6af7

File tree

4 files changed

+55
-21
lines changed

4 files changed

+55
-21
lines changed

js/src/Arrow.externs.js

+28-4
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,37 @@ var CountByResult = function() {};
7272
/** @type {?} */
7373
CountByResult.prototype.asJSON;
7474

75-
let Col = function() {};
75+
var col = function () {};
76+
77+
var Value = function() {};
78+
/** @type {?} */
79+
Value.prototype.gteq;
80+
/** @type {?} */
81+
Value.prototype.lteq;
82+
/** @type {?} */
83+
Value.prototype.eq;
84+
85+
var Col = function() {};
86+
87+
var Literal = function() {};
88+
89+
var GTeq = function () {};
90+
/** @type {?} */
91+
GTeq.prototype.and;
92+
/** @type {?} */
93+
GTeq.prototype.or;
94+
95+
var LTeq = function () {};
96+
/** @type {?} */
97+
LTeq.prototype.and;
7698
/** @type {?} */
77-
Col.prototype.gteq;
99+
LTeq.prototype.or;
100+
101+
var Equals = function () {};
78102
/** @type {?} */
79-
Col.prototype.lteq;
103+
Equals.prototype.and;
80104
/** @type {?} */
81-
Col.prototype.eq;
105+
Equals.prototype.or;
82106

83107
var TableToStringIterator = function() {};
84108
/** @type {?} */

js/src/Arrow.ts

+20-8
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import * as vector_ from './vector';
2121
import * as util_ from './util/int';
2222
import * as visitor_ from './visitor';
2323
import * as view_ from './vector/view';
24+
import * as predicate_ from './predicate';
2425
import { Vector } from './vector';
2526
import { RecordBatch } from './recordbatch';
2627
import { Schema, Field, Type } from './type';
27-
import { Table, CountByResult } from './table';
28-
import { lit, col, Col, Value } from './predicate';
28+
import { Table, DataFrame, NextFunc, CountByResult } from './table';
2929
import { read, readAsync } from './ipc/reader/arrow';
3030

3131
export import View = vector_.View;
@@ -36,8 +36,7 @@ export import TimeBitWidth = type_.TimeBitWidth;
3636
export import TypedArrayConstructor = type_.TypedArrayConstructor;
3737

3838
export { read, readAsync };
39-
export { Table, CountByResult };
40-
export { lit, col, Col, Value };
39+
export { Table, DataFrame, NextFunc, CountByResult };
4140
export { Field, Schema, RecordBatch, Vector, Type };
4241

4342
export namespace util {
@@ -154,6 +153,22 @@ export namespace view {
154153
export import IntervalMonthView = view_.IntervalMonthView;
155154
}
156155

156+
export namespace predicate {
157+
export import col = predicate_.col;
158+
export import Col = predicate_.Col;
159+
//export import Value = predicate_.Value;
160+
export import Literal = predicate_.Literal;
161+
162+
export import Or = predicate_.Or;
163+
export import And = predicate_.And;
164+
export import GTeq = predicate_.GTeq;
165+
export import LTeq = predicate_.LTeq;
166+
export import Equals = predicate_.Equals;
167+
export import Predicate = predicate_.Predicate;
168+
169+
export import PredicateFunc = predicate_.PredicateFunc;
170+
}
171+
157172
/* These exports are needed for the closure and uglify umd targets */
158173
try {
159174
let Arrow: any = eval('exports');
@@ -165,6 +180,7 @@ try {
165180
Arrow['view'] = view;
166181
Arrow['vector'] = vector;
167182
Arrow['visitor'] = visitor;
183+
Arrow['predicate'] = predicate;
168184

169185
Arrow['read'] = read;
170186
Arrow['readAsync'] = readAsync;
@@ -177,10 +193,6 @@ try {
177193

178194
Arrow['Table'] = Table;
179195
Arrow['CountByResult'] = CountByResult;
180-
Arrow['Value'] = Value;
181-
Arrow['lit'] = lit;
182-
Arrow['col'] = col;
183-
Arrow['Col'] = Col;
184196
}
185197
} catch (e) { /* not the UMD bundle */ }
186198
/* end umd exports */

js/src/predicate.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ export abstract class ComparisonPredicate<T= any> extends Predicate {
102102
protected abstract _bindColLit(batch: RecordBatch, col: Col, lit: Literal): PredicateFunc;
103103
}
104104

105-
abstract class CombinationPredicate extends Predicate {
105+
export abstract class CombinationPredicate extends Predicate {
106106
constructor(public readonly left: Predicate, public readonly right: Predicate) {
107107
super();
108108
}
109109
}
110110

111-
class And extends CombinationPredicate {
111+
export class And extends CombinationPredicate {
112112
bind(batch: RecordBatch) {
113113
const left = this.left.bind(batch);
114114
const right = this.right.bind(batch);
@@ -117,7 +117,7 @@ class And extends CombinationPredicate {
117117
ands(): Predicate[] { return this.left.ands().concat(this.right.ands()); }
118118
}
119119

120-
class Or extends CombinationPredicate {
120+
export class Or extends CombinationPredicate {
121121
bind(batch: RecordBatch) {
122122
const left = this.left.bind(batch);
123123
const right = this.right.bind(batch);

js/test/unit/table-tests.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
import Arrow, {
19-
} from '../Arrow';
18+
import Arrow from '../Arrow';
2019

21-
const {
22-
col,
23-
Table,
24-
} = Arrow;
20+
const { predicate, Table } = Arrow;
21+
22+
const { col } = predicate;
2523

2624
describe(`Table`, () => {
2725
test(`can create an empty table`, () => {

0 commit comments

Comments
 (0)