Skip to content

Commit

Permalink
refactor(rstream-query): update addQueryFromSpec, nextID
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 18, 2019
1 parent c6a40df commit 4a140e8
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions packages/rstream-query/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,24 +367,17 @@ export class TripleStore implements Iterable<Triple>, IToDot {
for (let q of spec.q) {
if (isWhereQuery(q)) {
curr = this.addMultiJoin(this.addParamQueries(q.where));
query && (curr = this.addJoin(query, curr));
} else if (isPathQuery(q)) {
curr = this.addPathQuery(q.path);
query && (curr = this.addJoin(query, curr));
}
query && curr && (curr = this.addJoin(query, curr));
query = curr;
}
assert(!!query, "illegal query spec");
let xforms: Transducer<any, any>[] = [];
if (spec.limit) {
xforms.push(limitSolutions(spec.limit));
}
if (spec.bind) {
xforms.push(bindVars(spec.bind));
}
if (spec.select) {
xforms.push(filterSolutions(spec.select));
}
spec.limit && xforms.push(limitSolutions(spec.limit));
spec.bind && xforms.push(bindVars(spec.bind));
spec.select && xforms.push(filterSolutions(spec.select));
if (xforms.length) {
query = <ISubscribable<any>>(
query!.subscribe(comp.apply(null, <any>xforms))
Expand All @@ -404,10 +397,7 @@ export class TripleStore implements Iterable<Triple>, IToDot {
}

protected nextID() {
if (this.freeIDs.length) {
return this.freeIDs.pop()!;
}
return this.NEXT_ID++;
return this.freeIDs.length ? this.freeIDs.pop()! : this.NEXT_ID++;
}

private broadcastTriple(
Expand Down

0 comments on commit 4a140e8

Please sign in to comment.