Skip to content

Commit 845bbe6

Browse files
committed
Also run orderByWithFractionalIndex tests for both the array and B+ tree variant
1 parent 4e22638 commit 845bbe6

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

packages/d2mini/tests/operators/orderByWithFractionalIndex.test.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
import { describe, test, expect } from 'vitest'
1+
import { describe, test, expect, beforeAll } from 'vitest'
22
import { D2 } from '../../src/d2.js'
33
import { MultiSet } from '../../src/multiset.js'
44
import {
55
orderByWithFractionalIndex,
6+
orderByWithFractionalIndexBTree,
67
output,
78
} from '../../src/operators/index.js'
89
import { KeyValue } from '../../src/types.js'
10+
import { loadBTree } from '../../src/operators/topKWithFractionalIndexBTree.js'
911

1012
const stripFractionalIndex = ([[key, [value, _index]], multiplicity]) => [
1113
key,
1214
value,
1315
multiplicity,
1416
]
1517

18+
beforeAll(async () => {
19+
await loadBTree()
20+
})
21+
1622
describe('Operators', () => {
17-
describe('OrderByWithFractionalIndex operation', () => {
23+
describe.each([
24+
['with array', { orderBy: orderByWithFractionalIndex }],
25+
['with B+ tree', { orderBy: orderByWithFractionalIndexBTree }],
26+
])('OrderByWithFractionalIndex operator %s', (_, { orderBy }) => {
1827
test('initial results with default comparator', () => {
1928
const graph = new D2()
2029
const input = graph.newInput<
@@ -29,7 +38,7 @@ describe('Operators', () => {
2938
let latestMessage: any = null
3039

3140
input.pipe(
32-
orderByWithFractionalIndex((item) => item.value),
41+
orderBy((item) => item.value),
3342
output((message) => {
3443
latestMessage = message
3544
}),
@@ -77,7 +86,7 @@ describe('Operators', () => {
7786
let latestMessage: any = null
7887

7988
input.pipe(
80-
orderByWithFractionalIndex((item) => item.value, {
89+
orderBy((item) => item.value, {
8190
comparator: (a, b) => b.localeCompare(a), // reverse order
8291
}),
8392
output((message) => {
@@ -127,7 +136,7 @@ describe('Operators', () => {
127136
let latestMessage: any = null
128137

129138
input.pipe(
130-
orderByWithFractionalIndex((item) => item.value, { limit: 3 }),
139+
orderBy((item) => item.value, { limit: 3 }),
131140
output((message) => {
132141
latestMessage = message
133142
}),
@@ -173,7 +182,7 @@ describe('Operators', () => {
173182
let latestMessage: any = null
174183

175184
input.pipe(
176-
orderByWithFractionalIndex((item) => item.value, {
185+
orderBy((item) => item.value, {
177186
limit: 2,
178187
offset: 2,
179188
}),
@@ -221,7 +230,7 @@ describe('Operators', () => {
221230
let latestMessage: any = null
222231

223232
input.pipe(
224-
orderByWithFractionalIndex((item) => item.id),
233+
orderBy((item) => item.id),
225234
output((message) => {
226235
latestMessage = message
227236
}),
@@ -269,7 +278,7 @@ describe('Operators', () => {
269278
let latestMessage: any = null
270279

271280
input.pipe(
272-
orderByWithFractionalIndex((item) => item.value, { limit: 3 }),
281+
orderBy((item) => item.value, { limit: 3 }),
273282
output((message) => {
274283
latestMessage = message
275284
}),
@@ -333,7 +342,7 @@ describe('Operators', () => {
333342
let latestMessage: any = null
334343

335344
input.pipe(
336-
orderByWithFractionalIndex((item) => item.value, { limit: 3 }),
345+
orderBy((item) => item.value, { limit: 3 }),
337346
output((message) => {
338347
latestMessage = message
339348
}),
@@ -399,7 +408,7 @@ describe('Operators', () => {
399408
let latestMessage: any = null
400409

401410
input.pipe(
402-
orderByWithFractionalIndex((item) => item.value, { limit: 3 }),
411+
orderBy((item) => item.value, { limit: 3 }),
403412
output((message) => {
404413
latestMessage = message
405414
}),

0 commit comments

Comments
 (0)