We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c4f5095 commit 77e08e5Copy full SHA for 77e08e5
4 files changed
core/symbols.c
@@ -147,7 +147,7 @@ i64_t symbols_intern(lit_p str, i64_t len) {
147
raw_p node = __atomic_load_n(&symbols->strings_node, __ATOMIC_ACQUIRE);
148
i64_t rounds2 = 0;
149
150
- while (slot_end > node) {
+ while ((i64_t)node == NULL_I64 || slot_end > node) {
151
if ((i64_t)node == NULL_I64) {
152
backoff_spin(&rounds2);
153
node = __atomic_load_n(&symbols->strings_node, __ATOMIC_ACQUIRE);
tests/lang.c
@@ -5280,3 +5280,23 @@ test_result_t test_lang_safety() {
5280
5281
PASS();
5282
}
5283
+
5284
+// ==================== READ-CSV LARGE SYMBOLS ====================
5285
+test_result_t test_lang_read_csv() {
5286
+ i64_t i;
5287
+ FILE *f;
5288
5289
+ f = fopen("/tmp/rf_test_syms.csv", "w");
5290
+ TEST_ASSERT(f != NULL, "failed to create temp CSV");
5291
+ fprintf(f, "id,sym\n");
5292
+ for (i = 0; i < 20000; i++)
5293
+ fprintf(f, "%lld,s%lld\n", (long long)i, (long long)i);
5294
+ fclose(f);
5295
5296
+ TEST_ASSERT_EQ(
5297
+ "(count (read-csv [I64 SYMBOL] \"/tmp/rf_test_syms.csv\"))",
5298
+ "20000");
5299
5300
+ remove("/tmp/rf_test_syms.csv");
5301
+ PASS();
5302
+}
tests/main.c
@@ -261,6 +261,7 @@ test_entry_t tests[] = {
261
{"test_lang_do_let", test_lang_do_let},
262
{"test_lang_error", test_lang_error},
263
{"test_lang_safety", test_lang_safety},
264
+ {"test_lang_read_csv", test_lang_read_csv},
265
// Parted table tests
266
{"test_parted_load", test_parted_load},
267
{"test_parted_select_where_date", test_parted_select_where_date},
@@ -455,6 +456,7 @@ test_entry_t tests[] = {
455
456
{"test_string_list_ops", test_string_list_ops},
457
{"test_string_where_in", test_string_where_in},
458
{"test_string_combined", test_string_combined},
459
+ {"test_symbols_intern_large", test_symbols_intern_large},
460
// Vector operation tests
461
{"test_vec_til", test_vec_til},
462
{"test_vec_take", test_vec_take},
tests/string_ops.c
@@ -432,3 +432,28 @@ test_result_t test_string_combined() {
432
433
434
435
436
+// ==================== SYMBOL INTERN LARGE ====================
437
+test_result_t test_symbols_intern_large() {
438
+ symbols_p symbols = runtime_get()->symbols;
439
+ i64_t i, id;
440
+ char buf[32];
441
442
+ for (i = 0; i < 20000; i++) {
443
+ i64_t len = snprintf(buf, sizeof(buf), "sym_%lld", (long long)i);
444
+ id = symbols_intern(buf, len);
445
+ TEST_ASSERT(id != NULL_I64, "symbols_intern returned NULL_I64");
446
+ }
447
448
+ TEST_ASSERT(symbols_count(symbols) >= 20000, "expected >= 20000 symbols");
449
450
451
452
453
+ str_p s = str_from_symbol(id);
454
+ TEST_ASSERT(s != NULL, "str_from_symbol returned NULL");
+ TEST_ASSERT(str_cmp(s, len, buf, len) == 0, "symbol string mismatch");
0 commit comments