-
Notifications
You must be signed in to change notification settings - Fork 19
/
build48_test.go
432 lines (389 loc) · 37.7 KB
/
build48_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
package compactindexsized
// This is a fork of the original project at https://github.com/firedancer-io/radiance/tree/main/pkg/compactindex
// The following changes have been made:
// - The package has been renamed to `compactindexsized` to avoid conflicts with the original package
// - The values it indexes are N-byte values instead of 8-byte values. This allows to index CIDs (in particular sha256+CBOR CIDs), and other values, directly.
import (
"context"
"encoding/binary"
"errors"
"io"
"io/fs"
"math/rand"
"os"
"testing"
"time"
"github.com/rpcpool/yellowstone-faithful/indexmeta"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vbauerster/mpb/v8/decor"
)
var testValues48 = [][]byte{
{0xcc, 0x0a, 0xd4, 0x66, 0x32, 0x50, 0xc3, 0x96, 0x8b, 0x5c, 0x77, 0x7e, 0xb8, 0xfd, 0x9c, 0x78, 0xea, 0xfb, 0xd3, 0x4f, 0x1a, 0x59, 0x4e, 0xda, 0x1d, 0x90, 0x2a, 0xcd, 0x79, 0xb6, 0x0b, 0x2d, 0xea, 0x76, 0x36, 0x54, 0x65, 0xe6, 0x53, 0x1b, 0x70, 0x38, 0x84, 0xb2, 0xbf, 0x5d, 0xf9, 0x30},
{0x7c, 0x18, 0x51, 0xd7, 0x63, 0x83, 0xf9, 0xc5, 0xaa, 0x48, 0x3c, 0x8e, 0xff, 0xf0, 0xf1, 0xab, 0xee, 0xda, 0xb0, 0x2f, 0x92, 0xcc, 0xb8, 0x78, 0x11, 0x5b, 0xa0, 0xb9, 0xfa, 0xf5, 0x2e, 0xb4, 0xd7, 0x10, 0x2d, 0x7b, 0xe5, 0xb6, 0x9f, 0xd0, 0xb1, 0xff, 0xd0, 0xf2, 0xef, 0xcd, 0x72, 0x1a},
{0x0b, 0x2f, 0xc2, 0x4d, 0xc5, 0x98, 0x8b, 0x13, 0xd9, 0x17, 0xf8, 0xc1, 0xb8, 0x59, 0xd4, 0x24, 0xad, 0xef, 0xe5, 0xb6, 0xb8, 0xb9, 0xba, 0x01, 0x9c, 0xe0, 0x7f, 0x96, 0x25, 0x83, 0xd6, 0xbf, 0xa3, 0xb2, 0xf2, 0x29, 0xb9, 0xa1, 0xa1, 0x92, 0xd0, 0xc0, 0xe5, 0x06, 0x94, 0xea, 0x6c, 0xb3},
{0xbb, 0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0xb5, 0x6b, 0x20, 0x74, 0xa2, 0xc0, 0xab, 0x4b, 0x56, 0xce, 0xba, 0xf6, 0x61, 0x13, 0x86, 0x08},
{0xf7, 0x50, 0xec, 0x3f, 0x40, 0x61, 0x26, 0x2b, 0xe8, 0xf7, 0x67, 0x69, 0x94, 0xcb, 0x0b, 0xaa, 0xe8, 0x7b, 0x37, 0xf8, 0x9f, 0x3e, 0x5b, 0x35, 0x6d, 0xd0, 0x3f, 0xe7, 0x42, 0x04, 0x09, 0x62, 0x44, 0xc8, 0x40, 0xf9, 0xf8, 0x08, 0x9e, 0x4c, 0x07, 0x44, 0x92, 0x85, 0xb9, 0x8e, 0xe3, 0x77},
}
func TestBuilder48(t *testing.T) {
const numBuckets = 3
const valueSize = 48
// Create a table with 3 buckets.
builder, err := NewBuilderSized("", numBuckets*targetEntriesPerBucket, valueSize)
require.NoError(t, err)
require.NotNil(t, builder)
assert.Len(t, builder.buckets, 3)
defer builder.Close()
kindSomething48 := []byte("something48")
require.NoError(t, builder.SetKind(kindSomething48))
// Insert a few entries.
keys := []string{"hello", "world", "blub", "foo"}
for i, key := range keys {
require.NoError(t, builder.Insert([]byte(key), []byte(testValues48[i])))
}
// {
// // print test values
// for _, tc := range testValues48 {
// spew.Dump(FormatByteSlice(tc))
// }
// }
// Create index file.
targetFile, err := os.CreateTemp("", "compactindex-final-")
require.NoError(t, err)
defer os.Remove(targetFile.Name())
defer targetFile.Close()
// Seal index.
require.NoError(t, builder.Seal(context.TODO(), targetFile))
// Assert binary content.
buf, err := os.ReadFile(targetFile.Name())
require.NoError(t, err)
expected := concatBytes(
// --- File header
// magic
[]byte{'c', 'o', 'm', 'p', 'i', 's', 'z', 'd'},
// header size
i32tob(31),
// value size (36 bytes in this case)
[]byte{48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
[]byte{0x03, 0x00, 0x00, 0x00}, // num buckets
[]byte{1}, // version
[]byte{1}, // how many kv pairs
[]byte{4}, // key size
[]byte("kind"), // key
[]byte{11}, // value size
[]byte("something48"), // value
// --- Bucket header 0
// hash domain
[]byte{0x00, 0x00, 0x00, 0x00},
// num entries
[]byte{0x01, 0x00, 0x00, 0x00},
// hash len
[]byte{0x03},
// padding
[]byte{0x00},
// file offset
[]byte{91, 0x00, 0x00, 0x00, 0x00, 0x00},
// --- Bucket header 1
// hash domain
[]byte{0x00, 0x00, 0x00, 0x00},
// num entries
[]byte{0x01, 0x00, 0x00, 0x00},
// hash len
[]byte{0x03},
// padding
[]byte{0x00},
// file offset
[]byte{142, 0x00, 0x00, 0x00, 0x00, 0x00},
// --- Bucket header 2
// hash domain
[]byte{0x00, 0x00, 0x00, 0x00},
// num entries
[]byte{0x02, 0x00, 0x00, 0x00},
// hash len
[]byte{0x03},
// padding
[]byte{0x00},
// file offset
[]byte{193, 0x00, 0x00, 0x00, 0x00, 0x00},
// --- Bucket 0
// hash
[]byte{0xe2, 0xdb, 0x55},
// value
[]byte{0xcc, 0x0a, 0xd4, 0x66, 0x32, 0x50, 0xc3, 0x96, 0x8b, 0x5c, 0x77, 0x7e, 0xb8, 0xfd, 0x9c, 0x78, 0xea, 0xfb, 0xd3, 0x4f, 0x1a, 0x59, 0x4e, 0xda, 0x1d, 0x90, 0x2a, 0xcd, 0x79, 0xb6, 0x0b, 0x2d, 0xea, 0x76, 0x36, 0x54, 0x65, 0xe6, 0x53, 0x1b, 0x70, 0x38, 0x84, 0xb2, 0xbf, 0x5d, 0xf9, 0x30},
// --- Bucket 2
// hash
[]byte{0x92, 0xcd, 0xbb},
// value
[]byte{0x7c, 0x18, 0x51, 0xd7, 0x63, 0x83, 0xf9, 0xc5, 0xaa, 0x48, 0x3c, 0x8e, 0xff, 0xf0, 0xf1, 0xab, 0xee, 0xda, 0xb0, 0x2f, 0x92, 0xcc, 0xb8, 0x78, 0x11, 0x5b, 0xa0, 0xb9, 0xfa, 0xf5, 0x2e, 0xb4, 0xd7, 0x10, 0x2d, 0x7b, 0xe5, 0xb6, 0x9f, 0xd0, 0xb1, 0xff, 0xd0, 0xf2, 0xef, 0xcd, 0x72, 0x1a},
// hash
[]byte{0x98, 0x3d, 0xbd},
// value
[]byte{0xbb, 0x12, 0x08, 0x5f, 0x73, 0xee, 0x39, 0x69, 0x9f, 0x6e, 0x5a, 0xd8, 0x21, 0x2d, 0x43, 0xbe, 0x01, 0xc1, 0x3f, 0xc5, 0xfa, 0x86, 0x09, 0x7e, 0x97, 0x61, 0x59, 0xb8, 0xc9, 0x16, 0x47, 0xe3, 0x18, 0xfe, 0x52, 0x1e, 0xa2, 0x98, 0x59, 0x83, 0x16, 0x88, 0x5b, 0x46, 0x83, 0x2b, 0xa3, 0x2a},
// hash
[]byte{0xe3, 0x09, 0x6b},
// value
[]byte{0x0b, 0x2f, 0xc2, 0x4d, 0xc5, 0x98, 0x8b, 0x13, 0xd9, 0x17, 0xf8, 0xc1, 0xb8, 0x59, 0xd4, 0x24, 0xad, 0xef, 0xe5, 0xb6, 0xb8, 0xb9, 0xba, 0x01, 0x9c, 0xe0, 0x7f, 0x96, 0x25, 0x83, 0xd6, 0xbf, 0xa3, 0xb2, 0xf2, 0x29, 0xb9, 0xa1, 0xa1, 0x92, 0xd0, 0xc0, 0xe5, 0x06, 0x94, 0xea, 0x6c, 0xb3}, // 26
)
assert.Equal(t, expected, buf)
{
splitSizes := []int{
// --- File header
8, 4, 8, 4, 1, 1, 1, 4, 1, 11,
// --- Bucket header 0
4, 4, 1, 1, 6,
// --- Bucket header 1
4, 4, 1, 1, 6,
// --- Bucket header 2
4, 4, 1, 1, 6,
// --- Bucket 0
3, valueSize,
// --- Bucket 2
3, valueSize, 3, valueSize, 3, valueSize,
}
splitExpected := splitBufferWithProvidedSizes(expected, splitSizes)
splitGot := splitBufferWithProvidedSizes(buf, splitSizes)
comparations := compareBufferArrays(splitExpected, splitGot)
for i, equal := range comparations {
if !equal {
t.Errorf("%d: \nexpected: %v, \n got: %v", i, FormatByteSlice(splitExpected[i]), FormatByteSlice(splitGot[i]))
}
}
}
// Reset file offset.
_, seekErr := targetFile.Seek(0, io.SeekStart)
require.NoError(t, seekErr)
// Open index.
db, err := Open(targetFile)
require.NoError(t, err, "Failed to open generated index")
require.NotNil(t, db)
// File header assertions.
assert.Equal(t, &Header{
ValueSize: valueSize,
NumBuckets: numBuckets,
Metadata: &indexmeta.Meta{
KeyVals: []indexmeta.KV{
{
Key: indexmeta.MetadataKey_Kind,
Value: kindSomething48,
},
},
},
}, db.Header)
// Get bucket handles.
buckets := make([]*Bucket, numBuckets)
for i := range buckets {
buckets[i], err = db.GetBucket(uint(i))
require.NoError(t, err)
}
// Ensure out-of-bounds bucket accesses fail.
_, wantErr := db.GetBucket(numBuckets)
assert.EqualError(t, wantErr, "out of bounds bucket index: 3 >= 3")
// Bucket header assertions.
assert.Equal(t, BucketDescriptor{
BucketHeader: BucketHeader{
HashDomain: 0x00,
NumEntries: 1,
HashLen: 3,
FileOffset: 91,
headerSize: 43,
},
Stride: 3 + valueSize, // 3 + 36
OffsetWidth: valueSize,
}, buckets[0].BucketDescriptor)
assert.Equal(t, BucketHeader{
HashDomain: 0x00,
NumEntries: 1,
HashLen: 3,
FileOffset: 142,
headerSize: 43,
}, buckets[1].BucketHeader)
assert.Equal(t, BucketHeader{
HashDomain: 0x00,
NumEntries: 2,
HashLen: 3,
FileOffset: 193,
headerSize: 43,
}, buckets[2].BucketHeader)
assert.Equal(t, uint8(3+valueSize), buckets[2].Stride)
// Test lookups.
entries, err := buckets[2].Load( /*batchSize*/ 3)
require.NoError(t, err)
assert.Equal(t, []Entry{
{
Hash: 12402072,
Value: []byte(testValues48[3]),
},
{
Hash: 7014883,
Value: []byte(testValues48[2]),
},
}, entries)
{
for i, keyString := range keys {
key := []byte(keyString)
bucket, err := db.LookupBucket(key)
require.NoError(t, err)
value, err := bucket.Lookup(key)
require.NoError(t, err)
assert.Equal(t, []byte(testValues48[i]), value)
}
}
}
func TestBuilder48_Random(t *testing.T) {
if testing.Short() {
t.Skip("Skipping long test")
}
numKeys := uint(len(testValues48))
const keySize = uint(16)
const valueSize = 48
const queries = int(10000)
// Create new builder session.
builder, err := NewBuilderSized("", numKeys, valueSize)
require.NoError(t, err)
require.NotNil(t, builder)
require.NotEmpty(t, builder.buckets)
// Ensure we cleaned up after ourselves.
defer func() {
_, statErr := os.Stat(builder.tmpDir)
assert.Truef(t, errors.Is(statErr, fs.ErrNotExist), "Delete failed: %v", statErr)
}()
defer builder.Close()
// Insert items to temp buckets.
preInsert := time.Now()
key := make([]byte, keySize)
for i := uint(0); i < numKeys; i++ {
binary.LittleEndian.PutUint64(key, uint64(i))
err := builder.Insert(key, []byte(testValues48[i]))
require.NoError(t, err)
}
t.Logf("Inserted %d keys in %s", numKeys, time.Since(preInsert))
// Create file for final index.
targetFile, err := os.CreateTemp("", "compactindex-final-")
require.NoError(t, err)
defer os.Remove(targetFile.Name())
defer targetFile.Close()
// Seal to final index.
preSeal := time.Now()
sealErr := builder.Seal(context.TODO(), targetFile)
require.NoError(t, sealErr, "Seal failed")
t.Logf("Sealed in %s", time.Since(preSeal))
// Print some stats.
targetStat, err := targetFile.Stat()
require.NoError(t, err)
t.Logf("Index size: %d (% .2f)", targetStat.Size(), decor.SizeB1000(targetStat.Size()))
t.Logf("Bytes per entry: %f", float64(targetStat.Size())/float64(numKeys))
t.Logf("Indexing speed: %f/s", float64(numKeys)/time.Since(preInsert).Seconds())
// Open index.
_, seekErr := targetFile.Seek(0, io.SeekStart)
require.NoError(t, seekErr)
db, err := Open(targetFile)
require.NoError(t, err, "Failed to open generated index")
// Run query benchmark.
preQuery := time.Now()
for i := queries; i != 0; i-- {
keyN := uint64(rand.Int63n(int64(numKeys)))
binary.LittleEndian.PutUint64(key, keyN)
bucket, err := db.LookupBucket(key)
require.NoError(t, err)
value, err := bucket.Lookup(key)
require.NoError(t, err)
require.Equal(t, []byte(testValues48[keyN]), value)
}
t.Logf("Queried %d items", queries)
t.Logf("Query speed: %f/s", float64(queries)/time.Since(preQuery).Seconds())
}