Skip to content

Commit be68b94

Browse files
fangqclaude
andcommitted
[refactor] the compiled backend is the jdai MEX file (jdi is renamed jdai)
The jdi library is now jdai (JData Interface); loadjson, loadbj, savejson and savebj look for and call jdai (jdai.mexa64 / jdai.mex). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 28a131b commit be68b94

8 files changed

Lines changed: 34 additions & 34 deletions

File tree

‎jdatadecode.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@
687687
if (iscpx)
688688
ndata = complex(ndata(1, :), ndata(2, :));
689689
end
690-
% a one-element _ArraySize_ (a 1-D array, as jdi and numpy write it) is a row, as a
690+
% a one-element _ArraySize_ (a 1-D array, as jdai and numpy write it) is a row, as a
691691
% 1-D typed array read by loadbj is: [N] taken as [1 N] before the row-major flip,
692692
% which would otherwise make it a column
693693
if (iscell(data(j).(N_ArraySize)))

‎jdataencode.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
% order; 'auto' picks N-D tiles of about 256 KiB (arrays up
7272
% to 64 MiB) or 1 MiB (larger ones) for dense arrays of 2 MiB
7373
% or more, one payload for the rest (the same tile shapes as
74-
% jdi's chunks="auto" and pyjdata's chunks="auto")
74+
% jdai's chunks="auto" and pyjdata's chunks="auto")
7575
%
7676
% example:
7777
% jd=jdataencode(struct('a',rand(5)+1i*rand(5),'b',[],'c',sparse(5,5)))

‎loadbj.m‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@
7272
% returned mmap will be filtered by removing
7373
% entries containing any one of the string patterns
7474
% provided in a cell
75-
% Backend ['auto'|'mex'|'m']: 'auto' uses the compiled jdi MEX
76-
% backend (from the jdi library) when it is on the
75+
% Backend ['auto'|'mex'|'m']: 'auto' uses the compiled jdai MEX
76+
% backend (from the jdai library) when it is on the
7777
% path and handles the options, else this file's
78-
% code; 'mex' requires jdi; 'm' never uses it
78+
% code; 'mex' requires jdai; 'm' never uses it
7979
%
8080
% output:
8181
% dat: a cell array, where {...} blocks are converted into cell arrays,
@@ -106,16 +106,16 @@
106106

107107
opt = varargin2struct(varargin{:});
108108

109-
% the compiled backend (the jdi MEX file, from the jdi library) when it is on the path: the same result,
109+
% the compiled backend (the jdai MEX file, from the jdai library) when it is on the path: the same result,
110110
% much faster; options it does not handle, and any error, fall back to the code below
111111
backend = lower(jsonopt('Backend', 'auto', opt));
112-
if (~strcmp(backend, 'm') && exist('jdi', 'file') == 3 && ...
112+
if (~strcmp(backend, 'm') && exist('jdai', 'file') == 3 && ...
113113
~(ischar(fname) && all(fname < 128) && ~isempty(regexpi(fname, '^\s*(http|https|ftp|file)://', 'once'))))
114114
try
115115
if (nargout > 1)
116-
[data, needdecode, mmap] = jdi('loadbj', fname, opt); % with the JSON-Mmap table
116+
[data, needdecode, mmap] = jdai('loadbj', fname, opt); % with the JSON-Mmap table
117117
else
118-
[data, needdecode] = jdi('loadbj', fname, opt);
118+
[data, needdecode] = jdai('loadbj', fname, opt);
119119
end
120120
if (needdecode && jsonopt('JDataDecode', 1, opt) == 1)
121121
try

‎loadjson.m‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@
8484
% provided in a cell
8585
% WebOptions {'Username', ..}: additional parameters for urlread
8686
%
87-
% Backend ['auto'|'mex'|'m']: 'auto' uses the compiled jdi MEX
88-
% backend (from the jdi library) when it is on the
87+
% Backend ['auto'|'mex'|'m']: 'auto' uses the compiled jdai MEX
88+
% backend (from the jdai library) when it is on the
8989
% path and handles the options, else this file's
90-
% code; 'mex' requires jdi; 'm' never uses it
90+
% code; 'mex' requires jdai; 'm' never uses it
9191
%
9292
% output:
9393
% dat: a cell array, where {...} blocks are converted into cell arrays,
@@ -166,16 +166,16 @@
166166
opt = varargin2struct(varargin{:});
167167
webopt = jsonopt('WebOptions', {}, opt);
168168

169-
% the compiled backend (the jdi MEX file, from the jdi library) when it is on the path: the same result,
169+
% the compiled backend (the jdai MEX file, from the jdai library) when it is on the path: the same result,
170170
% much faster; options it does not handle, and any error, fall back to the code below
171171
backend = lower(jsonopt('Backend', 'auto', opt));
172-
if (~strcmp(backend, 'm') && exist('jdi', 'file') == 3 && ...
172+
if (~strcmp(backend, 'm') && exist('jdai', 'file') == 3 && ...
173173
isempty(regexpi(fname, '^\s*(http|https|ftp|file)://', 'once')))
174174
try
175175
if (nargout > 1)
176-
[data, needdecode, mmap] = jdi('loadjson', fname, opt); % with the JSON-Mmap table
176+
[data, needdecode, mmap] = jdai('loadjson', fname, opt); % with the JSON-Mmap table
177177
else
178-
[data, needdecode] = jdi('loadjson', fname, opt);
178+
[data, needdecode] = jdai('loadjson', fname, opt);
179179
end
180180
if (needdecode && jsonopt('JDataDecode', 1, opt) == 1)
181181
try

‎savebj.m‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@
118118
% of unique strings to total records is below this
119119
% threshold, use dictionary encoding; otherwise use
120120
% fixed-length or offset-table encoding.
121-
% Backend ['auto'|'mex'|'m']: 'auto' uses the compiled jdi MEX
122-
% backend (from the jdi library) when it is on the
121+
% Backend ['auto'|'mex'|'m']: 'auto' uses the compiled jdai MEX
122+
% backend (from the jdai library) when it is on the
123123
% path and handles the options, else this file's
124-
% code; 'mex' requires jdi; 'm' never uses it
124+
% code; 'mex' requires jdai; 'm' never uses it
125125
% KeepType [0|1]: if set to 1, use the original data type to store
126126
% integers instead of converting to the integer type
127127
% of the minimum length without losing accuracy (default)
@@ -183,19 +183,19 @@
183183
opt = varargin2struct(varargin{:});
184184
end
185185

186-
% the compiled backend (the jdi MEX file, from the jdi library) when it is on the path: the same bytes,
186+
% the compiled backend (the jdai MEX file, from the jdai library) when it is on the path: the same bytes,
187187
% much faster; options and values it does not handle, and any error, fall back to the code below
188188
backend = lower(jsonopt('Backend', 'auto', opt));
189-
if (~strcmp(backend, 'm') && exist('jdi', 'file') == 3)
189+
if (~strcmp(backend, 'm') && exist('jdai', 'file') == 3)
190190
try
191191
mexroot = rootname;
192192
if (isempty(mexroot) && jsonopt('ForceRootName', 0, opt) && ~isstruct(obj) && ~iscell(obj))
193193
mexroot = varname;
194194
end
195195
if (nargout > 0 || isempty(jsonopt('FileName', '', opt)))
196-
output = jdi('savebj', mexroot, obj, opt);
196+
output = jdai('savebj', mexroot, obj, opt);
197197
else
198-
jdi('savebj', mexroot, obj, opt);
198+
jdai('savebj', mexroot, obj, opt);
199199
end
200200
return
201201
catch err

‎savejson.m‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
% UnpackHex [1|0]: convert the 0x[hex code] output by loadjson
7474
% back to the string form
7575
% SaveBinary [1|0]: 1 - save the JSON file in binary mode; 0 - text mode.
76-
% Backend ['auto'|'mex'|'m']: 'auto' uses the compiled jdi MEX
77-
% backend (from the jdi library) when it is on the
76+
% Backend ['auto'|'mex'|'m']: 'auto' uses the compiled jdai MEX
77+
% backend (from the jdai library) when it is on the
7878
% path and handles the options, else this file's
79-
% code; 'mex' requires jdi; 'm' never uses it
79+
% code; 'mex' requires jdai; 'm' never uses it
8080
% Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
8181
% Compression 'zlib', 'gzip', 'lzma', 'lzip', 'lz4' or 'lz4hc': specify array
8282
% compression method; currently only supports 6 methods. The
@@ -157,19 +157,19 @@
157157
opt = varargin2struct(varargin{:});
158158
end
159159

160-
% the compiled backend (the jdi MEX file, from the jdi library) when it is on the path: the same text,
160+
% the compiled backend (the jdai MEX file, from the jdai library) when it is on the path: the same text,
161161
% much faster; options and values it does not handle, and any error, fall back to the code below
162162
backend = lower(jsonopt('Backend', 'auto', opt));
163-
if (~strcmp(backend, 'm') && exist('jdi', 'file') == 3 && ischar(jsonopt('FileName', '', opt)))
163+
if (~strcmp(backend, 'm') && exist('jdai', 'file') == 3 && ischar(jsonopt('FileName', '', opt)))
164164
try
165165
mexroot = rootname;
166166
if (isempty(mexroot) && jsonopt('ForceRootName', 0, opt) && ~isstruct(obj) && ~iscell(obj))
167167
mexroot = varname;
168168
end
169169
if (nargout > 0 || isempty(jsonopt('FileName', '', opt)))
170-
output = jdi('savejson', mexroot, obj, opt);
170+
output = jdai('savejson', mexroot, obj, opt);
171171
else
172-
jdi('savejson', mexroot, obj, opt);
172+
jdai('savejson', mexroot, obj, opt);
173173
end
174174
return
175175
catch err

‎test/run_jsonlab_test.m‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4870,7 +4870,7 @@ function run_jsonlab_test(tests)
48704870
test_jsonlab('asymmetric nd chunks roundtrip', @savejson, isequaln(dec_asym, big3d), '[true]', 'compact', 1);
48714871
clear enc_asym dec_asym;
48724872

4873-
%% --- _ArrayShuffle_: bytes regrouped by position before compressing (as jdi writes) ---
4873+
%% --- _ArrayShuffle_: bytes regrouped by position before compressing (as jdai writes) ---
48744874
shuf4 = @(b) reshape(reshape(b, 4, []).', 1, []);
48754875
rowbytes = typecast(reshape(permute(big3d, [3 2 1]), 1, []), 'uint8');
48764876
enc_sh = struct('x_ArrayType_', 'single', 'x_ArraySize_', [5 12 10], 'x_ArrayZipType_', 'zlib', ...
@@ -4901,7 +4901,7 @@ function run_jsonlab_test(tests)
49014901
isequal(jdatadecode(enc_shc, 'base64', 0, 'prefix', 'x'), big3d), '[true]', 'compact', 1);
49024902
clear shuf4 rowbytes enc_sh enc_shc tiles_sh ti tj tk tile bitshuffle_err;
49034903

4904-
%% --- a one-element _ArraySize_ (1-D arrays from jdi/numpy) decodes as a row ---
4904+
%% --- a one-element _ArraySize_ (1-D arrays from jdai/numpy) decodes as a row ---
49054905
v1d = single(1:400);
49064906
enc_1d = struct('x_ArrayType_', 'single', 'x_ArraySize_', 400, 'x_ArrayZipType_', 'zlib', ...
49074907
'x_ArrayZipSize_', [1 400], 'x_ArrayZipData_', zlibencode(typecast(v1d, 'uint8')));
@@ -4918,7 +4918,7 @@ function run_jsonlab_test(tests)
49184918
'[true]', 'compact', 1);
49194919
clear v1d enc_1d;
49204920

4921-
%% --- ArrayChunks 'auto': N-D tiles for dense arrays of 2 MiB or more (as jdi/pyjdata) ---
4921+
%% --- ArrayChunks 'auto': N-D tiles for dense arrays of 2 MiB or more (as jdai/pyjdata) ---
49224922
big_auto = single(reshape(mod(0:719999, 977), 100, 90, 80)); % 2.75 MiB
49234923
enc_auto = jdataencode(big_auto, 'formatversion', 4, 'compression', 'zlib', ...
49244924
'arraychunks', 'auto', 'base64', 0, 'prefix', 'x');

‎test/test_jsonlab_zip.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function test_jsonlab_zip(testname, fhandle, input, expected, varargin)
33
% test_jsonlab_zip(testname, fhandle, input, expected, ...)
44
%
55
% Like test_jsonlab, for output holding a compressed _ArrayZipData_ payload. Encoders may
6-
% compress the same data to different (equally valid) bytes - zmat's zlib, or the jdi MEX
6+
% compress the same data to different (equally valid) bytes - zmat's zlib, or the jdai MEX
77
% backend's own deflate - so the text outside the payload must match exactly, and the payload
88
% must decompress to the same bytes as the expected one.
99
%

0 commit comments

Comments
 (0)