@@ -196,6 +196,7 @@ static JsonbValue *fillCompressedJsonbValue(CompressedJsonx *cjb,
196
196
JsonFieldPtr * ptr );
197
197
static JsonbContainerHeader * jsonxzDecompress (JsonContainer * jc );
198
198
static void jsonxzDecompressTo (CompressedJsonx * cjb , Size offset );
199
+ static void jsonxzDecompressSlice (CompressedJsonx * cjb , Size offset , Size length );
199
200
static bool JsonContainerIsToasted (JsonContainer * jc ,
200
201
JsonbToastedContainerPointerData * jbcptr );
201
202
static bool JsonContainerIsCompressed (JsonContainer * jc ,
@@ -796,7 +797,7 @@ JsonxIteratorInit(JsonContainer *cont, const JsonbContainerHeader *container,
796
797
797
798
/* decompress container header */
798
799
if (cjb )
799
- jsonxzDecompressTo (cjb , cjb -> offset + offsetof(JsonbContainerHeader , children ));
800
+ jsonxzDecompressSlice (cjb , cjb -> offset , offsetof(JsonbContainerHeader , children ));
800
801
801
802
type = container -> header & JBC_TMASK ;
802
803
@@ -843,7 +844,7 @@ JsonxIteratorInit(JsonContainer *cont, const JsonbContainerHeader *container,
843
844
}
844
845
845
846
if (it -> dataProper && cjb )
846
- jsonxzDecompressTo (cjb , cjb -> offset + ( it -> dataProper - (char * ) container ) );
847
+ jsonxzDecompressSlice (cjb , cjb -> offset , it -> dataProper - (char * ) container );
847
848
848
849
return (JsonIterator * ) it ;
849
850
}
@@ -1785,7 +1786,7 @@ jsonxzDecompress(JsonContainer *jc)
1785
1786
JsonbDatum * jb = (JsonbDatum * ) cjb -> iter -> buf -> buf ;
1786
1787
JsonbContainerHeader * container = (JsonbContainerHeader * )((char * ) jb + cjb -> offset );
1787
1788
1788
- jsonxzDecompressTo (cjb , cjb -> offset + jc -> len );
1789
+ jsonxzDecompressSlice (cjb , cjb -> offset , jc -> len );
1789
1790
1790
1791
return container ;
1791
1792
}
@@ -1826,7 +1827,7 @@ fillCompressedJsonbValue(CompressedJsonx *cjb,
1826
1827
1827
1828
cjb2 .offset = base_offset + offset ;
1828
1829
1829
- jsonxzDecompressTo (cjb , cjb2 .offset + offsetof(JsonbContainerHeader , children ));
1830
+ jsonxzDecompressSlice (cjb , cjb2 .offset , offsetof(JsonbContainerHeader , children ));
1830
1831
jsonxzInitContainer (cont , & cjb2 , NULL , length );
1831
1832
JsonValueInitBinary (result , cont );
1832
1833
@@ -1877,7 +1878,7 @@ findValueInCompressedJsonbObject(CompressedJsonx *cjb, Oid toasterid,
1877
1878
key .val .string .val = keystr ;
1878
1879
key .val .string .len = keylen ;
1879
1880
1880
- jsonxzDecompressTo (cjb , base_offset );
1881
+ jsonxzDecompressSlice (cjb , cjb -> offset , base_offset - cjb -> offset );
1881
1882
1882
1883
/* Binary search on object/pair keys *only* */
1883
1884
while (stopLow < stopHigh )
@@ -1944,7 +1945,7 @@ jsonxzFindKeyInObject(JsonContainer *jc, const char *key, int len,
1944
1945
1945
1946
CompressedDatumDecompress (cjb -> datum , cjb -> offset + offsetof(JsonbContainerHeader , header ));
1946
1947
#else
1947
- jsonxzDecompressTo (cjb , cjb -> offset + offsetof(JsonbContainerHeader , children ));
1948
+ jsonxzDecompressSlice (cjb , cjb -> offset , offsetof(JsonbContainerHeader , children ));
1948
1949
#endif
1949
1950
1950
1951
return findValueInCompressedJsonbObject (cjb , jc -> toasterid , key , len , res , ptr );
@@ -1968,11 +1969,11 @@ JsonbzArrayIteratorInit(JsonbzArrayIterator *it, CompressedJsonx *cjb,
1968
1969
JsonbDatum * jb = (JsonbDatum * ) cjb -> iter -> buf -> buf ;
1969
1970
const JsonbContainerHeader * jbc = (const JsonbContainerHeader * )((char * ) jb + cjb -> offset );
1970
1971
1971
- //jsonxzDecompressTo (cjb, cjb->offset + ((char *) &jbc->children - (char *) jbc));
1972
+ //jsonxzDecompressSlice (cjb, cjb->offset, ((char *) &jbc->children - (char *) jbc));
1972
1973
1973
1974
it -> count = (cjb -> header & JBC_CMASK );
1974
1975
1975
- //jsonxzDecompressTo (cjb, cjb->offset + ((char *) &jbc->children[it->count] - (char *) jbc));
1976
+ //jsonxzDecompressSlice (cjb, cjb->offset, ((char *) &jbc->children[it->count] - (char *) jbc));
1976
1977
1977
1978
it -> cjb = cjb ;
1978
1979
it -> container = jbc ;
@@ -1991,7 +1992,7 @@ JsonbzArrayIteratorNext(JsonbzArrayIterator *it, JsonValue *result)
1991
1992
if (it -> index >= it -> count )
1992
1993
return false;
1993
1994
1994
- jsonxzDecompressTo (it -> cjb , (char * ) & jbc -> children [it -> count ] - (char * ) jb );
1995
+ jsonxzDecompressSlice (it -> cjb , it -> cjb -> offset , (char * ) & jbc -> children [it -> count ] - (char * ) jb - it -> cjb -> offset );
1995
1996
fillCompressedJsonbValue (it -> cjb , it -> container , it -> toasterid , it -> index , it -> base_addr ,
1996
1997
it -> offset , result , NULL );
1997
1998
0 commit comments