Skip to content

Commit 38bf5a2

Browse files
committed
update jsonic wasm with phase 3 optimizations - query_batch support
1 parent 94046bb commit 38bf5a2

File tree

8 files changed

+64
-0
lines changed

8 files changed

+64
-0
lines changed

public/jsonic-bench/jsonic_wasm.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@ export class JsonDB {
7272
list_ids(): any;
7373
/**
7474
* Query documents using MongoDB-style queries with index optimization and caching
75+
* Phase 2 & 3: Enhanced with better index hints and optimized execution path
7576
*/
7677
query(query_json: string): any;
78+
/**
79+
* Execute multiple queries in a single batch operation (Phase 3 optimization)
80+
* This reduces lock acquisition overhead and enables result sharing
81+
*/
82+
query_batch(queries_json: string): any;
7783
/**
7884
* Query documents directly from JsValue (zero-copy, faster)
7985
* This is 2-3x faster than query() as it avoids JSON string serialization
@@ -158,6 +164,7 @@ export interface InitOutput {
158164
readonly jsondb_clear_query_cache: (a: number, b: number) => void;
159165
readonly jsondb_list_ids: (a: number, b: number) => void;
160166
readonly jsondb_query: (a: number, b: number, c: number, d: number) => void;
167+
readonly jsondb_query_batch: (a: number, b: number, c: number, d: number) => void;
161168
readonly jsondb_query_direct: (a: number, b: number, c: number) => void;
162169
readonly jsondb_query_with_options: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
163170
readonly jsondb_create_index: (a: number, b: number, c: number, d: number, e: number, f: number) => void;

public/jsonic-bench/jsonic_wasm.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ export class JsonDB {
541541
}
542542
/**
543543
* Query documents using MongoDB-style queries with index optimization and caching
544+
* Phase 2 & 3: Enhanced with better index hints and optimized execution path
544545
* @param {string} query_json
545546
* @returns {any}
546547
*/
@@ -561,6 +562,29 @@ export class JsonDB {
561562
wasm.__wbindgen_add_to_stack_pointer(16);
562563
}
563564
}
565+
/**
566+
* Execute multiple queries in a single batch operation (Phase 3 optimization)
567+
* This reduces lock acquisition overhead and enables result sharing
568+
* @param {string} queries_json
569+
* @returns {any}
570+
*/
571+
query_batch(queries_json) {
572+
try {
573+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
574+
const ptr0 = passStringToWasm0(queries_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
575+
const len0 = WASM_VECTOR_LEN;
576+
wasm.jsondb_query_batch(retptr, this.__wbg_ptr, ptr0, len0);
577+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
578+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
579+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
580+
if (r2) {
581+
throw takeObject(r1);
582+
}
583+
return takeObject(r0);
584+
} finally {
585+
wasm.__wbindgen_add_to_stack_pointer(16);
586+
}
587+
}
564588
/**
565589
* Query documents directly from JsValue (zero-copy, faster)
566590
* This is 2-3x faster than query() as it avoids JSON string serialization
-4.94 KB
Binary file not shown.

public/jsonic-bench/jsonic_wasm_bg.wasm.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const jsondb_stats: (a: number, b: number) => void;
1717
export const jsondb_clear_query_cache: (a: number, b: number) => void;
1818
export const jsondb_list_ids: (a: number, b: number) => void;
1919
export const jsondb_query: (a: number, b: number, c: number, d: number) => void;
20+
export const jsondb_query_batch: (a: number, b: number, c: number, d: number) => void;
2021
export const jsondb_query_direct: (a: number, b: number, c: number) => void;
2122
export const jsondb_query_with_options: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
2223
export const jsondb_create_index: (a: number, b: number, c: number, d: number, e: number, f: number) => void;

public/jsonic_wasm.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@ export class JsonDB {
7272
list_ids(): any;
7373
/**
7474
* Query documents using MongoDB-style queries with index optimization and caching
75+
* Phase 2 & 3: Enhanced with better index hints and optimized execution path
7576
*/
7677
query(query_json: string): any;
78+
/**
79+
* Execute multiple queries in a single batch operation (Phase 3 optimization)
80+
* This reduces lock acquisition overhead and enables result sharing
81+
*/
82+
query_batch(queries_json: string): any;
7783
/**
7884
* Query documents directly from JsValue (zero-copy, faster)
7985
* This is 2-3x faster than query() as it avoids JSON string serialization
@@ -158,6 +164,7 @@ export interface InitOutput {
158164
readonly jsondb_clear_query_cache: (a: number, b: number) => void;
159165
readonly jsondb_list_ids: (a: number, b: number) => void;
160166
readonly jsondb_query: (a: number, b: number, c: number, d: number) => void;
167+
readonly jsondb_query_batch: (a: number, b: number, c: number, d: number) => void;
161168
readonly jsondb_query_direct: (a: number, b: number, c: number) => void;
162169
readonly jsondb_query_with_options: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
163170
readonly jsondb_create_index: (a: number, b: number, c: number, d: number, e: number, f: number) => void;

public/jsonic_wasm.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ export class JsonDB {
541541
}
542542
/**
543543
* Query documents using MongoDB-style queries with index optimization and caching
544+
* Phase 2 & 3: Enhanced with better index hints and optimized execution path
544545
* @param {string} query_json
545546
* @returns {any}
546547
*/
@@ -561,6 +562,29 @@ export class JsonDB {
561562
wasm.__wbindgen_add_to_stack_pointer(16);
562563
}
563564
}
565+
/**
566+
* Execute multiple queries in a single batch operation (Phase 3 optimization)
567+
* This reduces lock acquisition overhead and enables result sharing
568+
* @param {string} queries_json
569+
* @returns {any}
570+
*/
571+
query_batch(queries_json) {
572+
try {
573+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
574+
const ptr0 = passStringToWasm0(queries_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
575+
const len0 = WASM_VECTOR_LEN;
576+
wasm.jsondb_query_batch(retptr, this.__wbg_ptr, ptr0, len0);
577+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
578+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
579+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
580+
if (r2) {
581+
throw takeObject(r1);
582+
}
583+
return takeObject(r0);
584+
} finally {
585+
wasm.__wbindgen_add_to_stack_pointer(16);
586+
}
587+
}
564588
/**
565589
* Query documents directly from JsValue (zero-copy, faster)
566590
* This is 2-3x faster than query() as it avoids JSON string serialization

public/jsonic_wasm_bg.wasm

-4.94 KB
Binary file not shown.

public/jsonic_wasm_bg.wasm.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const jsondb_stats: (a: number, b: number) => void;
1717
export const jsondb_clear_query_cache: (a: number, b: number) => void;
1818
export const jsondb_list_ids: (a: number, b: number) => void;
1919
export const jsondb_query: (a: number, b: number, c: number, d: number) => void;
20+
export const jsondb_query_batch: (a: number, b: number, c: number, d: number) => void;
2021
export const jsondb_query_direct: (a: number, b: number, c: number) => void;
2122
export const jsondb_query_with_options: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
2223
export const jsondb_create_index: (a: number, b: number, c: number, d: number, e: number, f: number) => void;

0 commit comments

Comments
 (0)