Skip to content

Commit

Permalink
remove stateless-source
Browse files Browse the repository at this point in the history
  • Loading branch information
tantaman committed Mar 28, 2024
1 parent fbf47e2 commit 2f4a7d7
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 236 deletions.
9 changes: 5 additions & 4 deletions src/zql/ast-to-ivm/pipeline-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ const e1 = z.object({
type E1 = z.infer<typeof e1>;

const context = makeTestContext();
const comparator = (l: E1, r: E1) => l.id.localeCompare(r.id);
test('A simple select', () => {
const q = new EntityQuery<{fields: E1}>(context, 'e1');
const m = new Materialite();
let s = m.newStatelessSource<E1>();
let s = m.newSetSource<E1>(comparator);
let pipeline = buildPipeline(
() => s.stream,
ast(q.select('id', 'a', 'b', 'c', 'd')),
Expand All @@ -38,7 +39,7 @@ test('A simple select', () => {
s.add(expected[1]);
expect(effectRunCount).toBe(2);

s = m.newStatelessSource();
s = m.newSetSource(comparator);
pipeline = buildPipeline(() => s.stream, ast(q.select('a', 'd')));
const expected2 = [
{a: 1, d: true},
Expand All @@ -57,7 +58,7 @@ test('A simple select', () => {
test('Count', () => {
const q = new EntityQuery<{fields: E1}>(context, 'e1');
const m = new Materialite();
const s = m.newStatelessSource<E1>();
const s = m.newSetSource<E1>(comparator);
const pipeline = buildPipeline(() => s.stream, ast(q.count()));

let effectRunCount = 0;
Expand All @@ -76,7 +77,7 @@ test('Count', () => {
test('Where', () => {
const q = new EntityQuery<{fields: E1}>(context, 'e1');
const m = new Materialite();
const s = m.newStatelessSource<E1>();
const s = m.newSetSource<E1>(comparator);
const pipeline = buildPipeline(
() => s.stream,
ast(q.select('id').where('a', '>', 1).where('b', '<', 2)),
Expand Down
5 changes: 4 additions & 1 deletion src/zql/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export function makeTestContext(): Context {
const sources = new Map<string, Source<unknown>>();
const getSource = <T extends Entity>(name: string) => {
if (!sources.has(name)) {
sources.set(name, materialite.newStatelessSource<T>());
sources.set(
name,
materialite.newSetSource<T>((l, r) => l.id.localeCompare(r.id)),
);
}
return sources.get(name)! as Source<T>;
};
Expand Down
4 changes: 2 additions & 2 deletions src/zql/ivm/graph/difference-stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ test('map, filter, linearCount', () => {

test('cleaning up the only user of a stream cleans up the entire pipeline', () => {
const materialite = new Materialite();
const set = materialite.newStatelessSource<number>();
const set = materialite.newSetSource<number>((l, r) => l - r);

let notifyCount = 0;
const final = set.stream
Expand All @@ -138,7 +138,7 @@ test('cleaning up the only user of a stream cleans up the entire pipeline', () =

test('cleaning up the only user of a stream cleans up the entire pipeline but stops at a used fork', () => {
const materialite = new Materialite();
const set = materialite.newStatelessSource<number>();
const set = materialite.newSetSource<number>((l, r) => l - r);

let notifyCount = 0;
const stream1 = set.stream.effect(_ => notifyCount++);
Expand Down
5 changes: 0 additions & 5 deletions src/zql/ivm/materialite.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {Comparator} from '@vlcn.io/ds-and-algos/types';
import {SourceInternal} from './source/source.js';
import {MutableSetSource} from './source/set-source.js';
import {StatelessSource} from './source/stateless-source.js';
import {Version} from './types.js';
import {must} from '../error/asserts.js';

Expand Down Expand Up @@ -34,10 +33,6 @@ export class Materialite {
};
}

newStatelessSource<T>() {
return new StatelessSource<T>(this.#internal);
}

newSetSource<T>(comparator: Comparator<T>) {
return new MutableSetSource<T>(this.#internal, comparator);
}
Expand Down
113 changes: 0 additions & 113 deletions src/zql/ivm/source/stateless-source.test.ts

This file was deleted.

108 changes: 0 additions & 108 deletions src/zql/ivm/source/stateless-source.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/zql/ivm/view/tree-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Entity = {
type Selected = {id: string; [orderingProp]: Primitive[]};
test('asc and descComparator on Entities', () => {
const m = new Materialite();
const s = m.newStatelessSource<Entity>();
const s = m.newSetSource<Entity>((l, r) => l.id.localeCompare(r.id));

const updatedStream = applySelect(
s.stream,
Expand Down Expand Up @@ -57,7 +57,7 @@ test('add & remove', () => {
fc.assert(
fc.property(fc.uniqueArray(fc.integer()), arr => {
const m = new Materialite();
const source = m.newStatelessSource<number>();
const source = m.newSetSource<number>((l, r) => l - r);
const view = new MutableTreeView(
m,
source.stream,
Expand All @@ -82,7 +82,7 @@ test('replace', () => {
fc.assert(
fc.property(fc.uniqueArray(fc.integer()), arr => {
const m = new Materialite();
const source = m.newStatelessSource<number>();
const source = m.newSetSource<number>((l, r) => l - r);
const view = new MutableTreeView(m, source.stream, numberComparator, [
['id'],
'asc',
Expand Down

0 comments on commit 2f4a7d7

Please sign in to comment.