(t *testing.T)
| 2467 | } |
| 2468 | |
| 2469 | func TestDB_HintFileWithDifferentDataStructures(t *testing.T) { |
| 2470 | opts := DefaultOptions |
| 2471 | opts.SegmentSize = KB |
| 2472 | opts.Dir = filepath.Join(t.TempDir(), "test-hintfile-ds-recovery") |
| 2473 | opts.EnableHintFile = true |
| 2474 | |
| 2475 | // Clean the test directory at the start |
| 2476 | removeDir(opts.Dir) |
| 2477 | |
| 2478 | db, err := Open(opts) |
| 2479 | require.NoError(t, err) |
| 2480 | |
| 2481 | // Test BTree |
| 2482 | bucketBTree := "bucket_btree" |
| 2483 | txCreateBucket(t, db, DataStructureBTree, bucketBTree, nil) |
| 2484 | for i := 0; i < 50; i++ { |
| 2485 | txPut(t, db, bucketBTree, testutils.GetTestBytes(i), testutils.GetTestBytes(i), Persistent, nil, nil) |
| 2486 | } |
| 2487 | |
| 2488 | // Test Set |
| 2489 | bucketSet := "bucket_set" |
| 2490 | txCreateBucket(t, db, DataStructureSet, bucketSet, nil) |
| 2491 | key := testutils.GetTestBytes(0) |
| 2492 | for i := 0; i < 30; i++ { |
| 2493 | txSAdd(t, db, bucketSet, key, testutils.GetTestBytes(i), nil, nil) |
| 2494 | } |
| 2495 | |
| 2496 | // Test List |
| 2497 | bucketList := "bucket_list" |
| 2498 | txCreateBucket(t, db, DataStructureList, bucketList, nil) |
| 2499 | listKey := testutils.GetTestBytes(0) |
| 2500 | for i := 0; i < 20; i++ { |
| 2501 | txPush(t, db, bucketList, listKey, testutils.GetTestBytes(i), true, nil, nil) |
| 2502 | } |
| 2503 | |
| 2504 | // Test SortedSet |
| 2505 | bucketZSet := "bucket_zset" |
| 2506 | txCreateBucket(t, db, DataStructureSortedSet, bucketZSet, nil) |
| 2507 | zsetKey := testutils.GetTestBytes(0) |
| 2508 | for i := 0; i < 15; i++ { |
| 2509 | txZAdd(t, db, bucketZSet, zsetKey, testutils.GetTestBytes(i), float64(i), nil, nil) |
| 2510 | } |
| 2511 | |
| 2512 | // Perform merge to create hint files |
| 2513 | require.NoError(t, db.Merge()) |
| 2514 | |
| 2515 | // Close the database |
| 2516 | require.NoError(t, db.Close()) |
| 2517 | |
| 2518 | // Reopen the database - it should use hint files for fast recovery |
| 2519 | db, err = Open(opts) |
| 2520 | require.NoError(t, err) |
| 2521 | |
| 2522 | // Verify BTree data |
| 2523 | for i := 0; i < 50; i++ { |
| 2524 | txGet(t, db, bucketBTree, testutils.GetTestBytes(i), testutils.GetTestBytes(i), nil) |
| 2525 | } |
| 2526 |
nothing calls this directly
no test coverage detected