Skip to content

Commit

Permalink
change ArrayCompression keywords to ArrayZip to be short
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jun 13, 2019
1 parent e5f2ffb commit 3eb6d56
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 43 deletions.
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ savejson.m
compress a long string, one must convert
it to uint8 or int8 array first. The compressed
array uses three extra fields
"_ArrayCompressionMethod_": the opt.Compression value.
"_ArrayCompressionSize_": a 1D interger array to
"_ArrayZipType_": the opt.Compression value.
"_ArrayZipSize_": a 1D interger array to
store the pre-compressed (but post-processed)
array dimensions, and
"_ArrayCompressedData_": the "base64" encoded
"_ArrayZipData_": the "base64" encoded
compressed binary array data.
opt.CompressArraySize [100|int]: only to compress an array if the total
element count is larger than this number.
Expand Down Expand Up @@ -432,11 +432,11 @@ saveubjson.m
compress a long string, one must convert
it to uint8 or int8 array first. The compressed
array uses three extra fields
"_ArrayCompressionMethod_": the opt.Compression value.
"_ArrayCompressionSize_": a 1D interger array to
"_ArrayZipType_": the opt.Compression value.
"_ArrayZipSize_": a 1D interger array to
store the pre-compressed (but post-processed)
array dimensions, and
"_ArrayCompressedData_": the binary stream of
"_ArrayZipData_": the binary stream of
the compressed binary array data WITHOUT
'base64' encoding
opt.CompressArraySize [100|int]: only to compress an array if the total
Expand Down
12 changes: 6 additions & 6 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ JSON. The detailed help info for the four functions can be found below:
compress a long string, one must convert
it to uint8 or int8 array first. The compressed
array uses three extra fields
"_ArrayCompressionMethod_": the opt.Compression value.
"_ArrayCompressionSize_": a 1D interger array to
"_ArrayZipType_": the opt.Compression value.
"_ArrayZipSize_": a 1D interger array to
store the pre-compressed (but post-processed)
array dimensions, and
"_ArrayCompressedData_": the "base64" encoded
"_ArrayZipData_": the "base64" encoded
compressed binary array data.
opt.CompressArraySize [100|int]: only to compress an array if the total
element count is larger than this number.
Expand Down Expand Up @@ -424,11 +424,11 @@ JSON. The detailed help info for the four functions can be found below:
compress a long string, one must convert
it to uint8 or int8 array first. The compressed
array uses three extra fields
"_ArrayCompressionMethod_": the opt.Compression value.
"_ArrayCompressionSize_": a 1D interger array to
"_ArrayZipType_": the opt.Compression value.
"_ArrayZipSize_": a 1D interger array to
store the pre-compressed (but post-processed)
array dimensions, and
"_ArrayCompressedData_": the binary stream of
"_ArrayZipData_": the binary stream of
the compressed binary array data WITHOUT
'base64' encoding
opt.CompressArraySize [100|int]: only to compress an array if the total
Expand Down
6 changes: 3 additions & 3 deletions examples/jsonlab_basictest.matlab
Original file line number Diff line number Diff line change
Expand Up @@ -1276,9 +1276,9 @@ ans =
{
"_ArrayType_": "double",
"_ArraySize_": [20,10],
"_ArrayCompressionSize_": [1,200],
"_ArrayCompressionMethod_": "zlib",
"_ArrayCompressedData_": "eJxjYACBD/YMNAGj5o6aO2ruKBgFgwtQL10DAMHODQY=
"_ArrayZipSize_": [1,200],
"_ArrayZipType_": "zlib",
"_ArrayZipData_": "eJxjYACBD/YMNAGj5o6aO2ruKBgFgwtQL10DAMHODQY=
"
}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsonlab_ubjson_basictest.matlab
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ json2data =
ans =

{U _ArrayType_SUdoubleU _ArraySize_[$U#U
U_ArrayCompressionSize_[$U#UÈU_ArrayCompressionMethod_SUzlibU_ArrayCompressedData_[$U#U xœc` ö4£æŽš;jî(ƒP/] ÁÎ}
U_ArrayZipSize_[$U#UÈU_ArrayZipType_SUzlibU_ArrayZipData_[$U#U xœc` ö4£æŽš;jî(ƒP/] ÁÎ}


json2data =
Expand Down
18 changes: 9 additions & 9 deletions jdatadecode.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
% specification. The JData keywords are
% "_ArrayType_", "_ArraySize_", "_ArrayData_"
% "_ArrayIsSparse_", "_ArrayIsComplex_",
% "_ArrayCompressionMethod_", "_ArrayCompressionSize",
% "_ArrayCompressedData_"
% "_ArrayZipType_", "_ArrayZipSize",
% "_ArrayZipData_"
% opt: (optional) a list of 'Param',value pairs for additional options
% The supported options include
% 'Recursive', if set to 1, will apply the conversion to
% every child; 0 to disable
% 'Base64'. if set to 1, _ArrayCompressedData_ is assumed to
% 'Base64'. if set to 1, _ArrayZipData_ is assumed to
% be encoded with base64 format and need to be
% decoded first. This is needed for JSON but not
% UBJSON data
Expand Down Expand Up @@ -64,20 +64,20 @@
end
end

if(~isempty(strmatch(N_('_ArrayType_'),fn)) && (~isempty(strmatch(N_('_ArrayData_'),fn)) || ~isempty(strmatch(N_('_ArrayCompressedData_'),fn))))
if(~isempty(strmatch(N_('_ArrayType_'),fn)) && (~isempty(strmatch(N_('_ArrayData_'),fn)) || ~isempty(strmatch(N_('_ArrayZipData_'),fn))))
newdata=cell(len,1);
for j=1:len
if(~isempty(strmatch(N_('_ArrayCompressionSize_'),fn)) && ~isempty(strmatch(N_('_ArrayCompressedData_'),fn)))
if(~isempty(strmatch(N_('_ArrayZipSize_'),fn)) && ~isempty(strmatch(N_('_ArrayZipData_'),fn)))
zipmethod='zip';
if(~isempty(strmatch(N_('_ArrayCompressionMethod_'),fn)))
zipmethod=data(j).(N_('_ArrayCompressionMethod_'));
if(~isempty(strmatch(N_('_ArrayZipType_'),fn)))
zipmethod=data(j).(N_('_ArrayZipType_'));
end
if(~isempty(strmatch(zipmethod,{'zlib','gzip','lzma','lzip'})))
decompfun=str2func([zipmethod 'decode']);
if(needbase64)
ndata=reshape(typecast(decompfun(base64decode(data(j).(N_('_ArrayCompressedData_')))),data(j).(N_('_ArrayType_'))),data(j).(N_('_ArrayCompressionSize_')));
ndata=reshape(typecast(decompfun(base64decode(data(j).(N_('_ArrayZipData_')))),data(j).(N_('_ArrayType_'))),data(j).(N_('_ArrayZipSize_')));
else
ndata=reshape(typecast(decompfun(data(j).(N_('_ArrayCompressedData_'))),data(j).(N_('_ArrayType_'))),data(j).(N_('_ArrayCompressionSize_')));
ndata=reshape(typecast(decompfun(data(j).(N_('_ArrayZipData_'))),data(j).(N_('_ArrayType_'))),data(j).(N_('_ArrayZipSize_')));
end
else
error('compression method is not supported');
Expand Down
18 changes: 9 additions & 9 deletions savejson.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
% compress a long string, one must convert
% it to uint8 or int8 array first. The compressed
% array uses three extra fields
% "_ArrayCompressionMethod_": the opt.Compression value.
% "_ArrayCompressionSize_": a 1D interger array to
% "_ArrayZipType_": the opt.Compression value.
% "_ArrayZipSize_": a 1D interger array to
% store the pre-compressed (but post-processed)
% array dimensions, and
% "_ArrayCompressedData_": the "base64" encoded
% "_ArrayZipData_": the "base64" encoded
% compressed binary array data.
% opt.CompressArraySize [100|int]: only to compress an array if the total
% element count is larger than this number.
Expand Down Expand Up @@ -534,10 +534,10 @@
% General case, store row and column indices.
fulldata=[ix,iy,data];
end
txt=sprintf(dataformat,txt,padding0,'"_ArrayCompressionSize_": ',regexprep(mat2str(size(fulldata)),'\s+',','), sep);
txt=sprintf(dataformat,txt,padding0,'"_ArrayCompressionMethod_": "',dozip, ['"' sep]);
txt=sprintf(dataformat,txt,padding0,'"_ArrayZipSize_": ',regexprep(mat2str(size(fulldata)),'\s+',','), sep);
txt=sprintf(dataformat,txt,padding0,'"_ArrayZipType_": "',dozip, ['"' sep]);
compfun=str2func([dozip 'encode']);
txt=sprintf(dataformat,txt,padding0,'"_ArrayCompressedData_": "',base64encode(compfun(typecast(fulldata(:),'uint8'))),['"' nl]);
txt=sprintf(dataformat,txt,padding0,'"_ArrayZipData_": "',base64encode(compfun(typecast(fulldata(:),'uint8'))),['"' nl]);
else
if(size(item,1)==1)
% Row vector, store only column indices.
Expand Down Expand Up @@ -566,10 +566,10 @@
txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','true', sep);
fulldata=[real(item(:)) imag(item(:))]';
end
txt=sprintf(dataformat,txt,padding0,'"_ArrayCompressionSize_": ',regexprep(mat2str(size(fulldata)),'\s+',','), sep);
txt=sprintf(dataformat,txt,padding0,'"_ArrayCompressionMethod_": "',dozip, ['"' sep]);
txt=sprintf(dataformat,txt,padding0,'"_ArrayZipSize_": ',regexprep(mat2str(size(fulldata)),'\s+',','), sep);
txt=sprintf(dataformat,txt,padding0,'"_ArrayZipType_": "',dozip, ['"' sep]);
compfun=str2func([dozip 'encode']);
txt=sprintf(dataformat,txt,padding0,'"_ArrayCompressedData_": "',base64encode(compfun(typecast(fulldata(:),'uint8'))),['"' nl]);
txt=sprintf(dataformat,txt,padding0,'"_ArrayZipData_": "',base64encode(compfun(typecast(fulldata(:),'uint8'))),['"' nl]);
else
if(isreal(item))
txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
Expand Down
18 changes: 9 additions & 9 deletions saveubjson.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@
% compress a long string, one must convert
% it to uint8 or int8 array first. The compressed
% array uses three extra fields
% "_ArrayCompressionMethod_": the opt.Compression value.
% "_ArrayCompressionSize_": a 1D interger array to
% "_ArrayZipType_": the opt.Compression value.
% "_ArrayZipSize_": a 1D interger array to
% store the pre-compressed (but post-processed)
% array dimensions, and
% "_ArrayCompressedData_": the binary stream of
% "_ArrayZipData_": the binary stream of
% the compressed binary array data WITHOUT
% 'base64' encoding
% opt.CompressArraySize [100|int]: only to compress an array if the total
Expand Down Expand Up @@ -513,10 +513,10 @@
fulldata=[ix,iy,data];
end
cid=I_(uint32(max(size(fulldata))),Imarker,varargin{:});
txt=[txt, N_('_ArrayCompressionSize_'),I_a(size(fulldata),cid(1),Imarker,varargin{:})];
txt=[txt, N_('_ArrayCompressionMethod_'),S_(dozip)];
txt=[txt, N_('_ArrayZipSize_'),I_a(size(fulldata),cid(1),Imarker,varargin{:})];
txt=[txt, N_('_ArrayZipType_'),S_(dozip)];
compfun=str2func([dozip 'encode']);
txt=[txt,N_('_ArrayCompressedData_'), I_a(compfun(typecast(fulldata(:),'uint8')),Imarker(1),Imarker,varargin{:})];
txt=[txt,N_('_ArrayZipData_'), I_a(compfun(typecast(fulldata(:),'uint8')),Imarker(1),Imarker,varargin{:})];
childcount=childcount+3;
else
if(size(item,1)==1)
Expand Down Expand Up @@ -550,10 +550,10 @@
fulldata=[real(item(:)) imag(item(:))];
end
cid=I_(uint32(max(size(fulldata))),Imarker,varargin{:});
txt=[txt, N_('_ArrayCompressionSize_'),I_a(size(fulldata),cid(1),Imarker,varargin{:})];
txt=[txt, N_('_ArrayCompressionMethod_'),S_(dozip)];
txt=[txt, N_('_ArrayZipSize_'),I_a(size(fulldata),cid(1),Imarker,varargin{:})];
txt=[txt, N_('_ArrayZipType_'),S_(dozip)];
compfun=str2func([dozip 'encode']);
txt=[txt,N_('_ArrayCompressedData_'), I_a(compfun(typecast(fulldata(:),'uint8')),Imarker(1),Imarker,varargin{:})];
txt=[txt,N_('_ArrayZipData_'), I_a(compfun(typecast(fulldata(:),'uint8')),Imarker(1),Imarker,varargin{:})];
childcount=childcount+3;
else
if(isreal(item))
Expand Down

0 comments on commit 3eb6d56

Please sign in to comment.