Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3aa5155

Browse files
author
Nikita Glukhov
committed
Enable diffs for compressed chunks
1 parent412eb4e commit3aa5155

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

‎contrib/jsonb_toaster/jsonb_toast_internals.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ jsonx_toast_make_pointer_compressed_chunks(Oid toasterid,
141141
structvarlena*
142142
jsonx_toast_make_pointer_diff(Oidtoasterid,
143143
structvaratt_external*toast_pointer,
144+
boolcompressed_chunks,
144145
int32diff_offset,int32diff_len,
145146
constvoid*diff_data)
146147
{
@@ -150,7 +151,10 @@ jsonx_toast_make_pointer_diff(Oid toasterid,
150151
TOAST_POINTER_SIZE+ offsetof(JsonxPointerDiff,data)+diff_len;
151152

152153
structvarlena*result=
153-
jsonx_toast_make_custom_pointer(toasterid,JSONX_POINTER_DIFF,
154+
jsonx_toast_make_custom_pointer(toasterid,
155+
compressed_chunks ?
156+
JSONX_POINTER_DIFF_COMP :
157+
JSONX_POINTER_DIFF,
154158
datalen,toast_pointer->va_rawsize,&data);
155159

156160
SET_VARTAG_EXTERNAL(data,VARTAG_ONDISK);
@@ -169,7 +173,10 @@ jsonxMakeToastPointer(JsonbToastedContainerPointerData *ptr)
169173
if (ptr->ntids||ptr->has_diff)
170174
{
171175
char*data;
172-
uint32header=ptr->has_diff ?JSONX_POINTER_DIFF :
176+
uint32header=ptr->has_diff ?
177+
(ptr->compressed_chunks ?
178+
JSONX_POINTER_DIFF_COMP :
179+
JSONX_POINTER_DIFF) :
173180
ptr->ntids | (ptr->compressed_tids ?
174181
JSONX_POINTER_DIRECT_TIDS_COMP :
175182
JSONX_POINTER_DIRECT_TIDS);
@@ -209,7 +216,9 @@ jsonxWriteToastPointer(StringInfo buffer, JsonbToastedContainerPointerData *ptr)
209216
charcustom_ptr[JSONX_CUSTOM_PTR_HEADER_SIZE];
210217
chartoast_ptr[TOAST_POINTER_SIZE];
211218
uint32header=ptr->has_diff ?
212-
JSONX_POINTER_DIFF :
219+
(ptr->compressed_chunks ?
220+
JSONX_POINTER_DIFF_COMP :
221+
JSONX_POINTER_DIFF) :
213222
ptr->ntids | (ptr->compressed_tids ?
214223
JSONX_POINTER_DIRECT_TIDS_COMP :
215224
JSONX_POINTER_DIRECT_TIDS);
@@ -989,12 +998,16 @@ jsonx_create_fetch_datum_iterator(struct varlena *attr, Oid toasterid,
989998
iter->toasterid=toasterid;
990999
iter->chunk_tids_inline_size=inline_size;
9911000

992-
if (inline_size <=0||type==JSONX_POINTER_DIFF)
1001+
if (inline_size <=0||
1002+
type==JSONX_POINTER_DIFF||
1003+
type==JSONX_POINTER_DIFF_COMP)
9931004
{
9941005
iter->nchunk_tids=0;
9951006
iter->chunk_tids=NULL;
9961007
iter->compressed_chunk_tids=NULL;
997-
iter->compressed_chunks=type==JSONX_POINTER_COMPRESSED_CHUNKS;
1008+
iter->compressed_chunks=
1009+
type==JSONX_POINTER_COMPRESSED_CHUNKS||
1010+
type==JSONX_POINTER_DIFF_COMP;
9981011
}
9991012
else
10001013
{
@@ -1628,7 +1641,8 @@ jsonx_create_detoast_iterator(struct varlena *attr)
16281641
/* prepare buffer to received decompressed data */
16291642
iter->buf=create_toast_buffer(toast_pointer.va_rawsize, false);
16301643

1631-
if (type==JSONX_POINTER_DIFF)
1644+
if (type==JSONX_POINTER_DIFF||
1645+
type==JSONX_POINTER_DIFF_COMP)
16321646
iter->orig_buf=create_toast_buffer(toast_pointer.va_rawsize, false);
16331647
else
16341648
iter->orig_buf=iter->buf;
@@ -1642,7 +1656,8 @@ jsonx_create_detoast_iterator(struct varlena *attr)
16421656
iter->buf=iter->orig_buf=iter->fetch_datum_iterator->buf;
16431657
}
16441658

1645-
if (type==JSONX_POINTER_DIFF)
1659+
if (type==JSONX_POINTER_DIFF||
1660+
type==JSONX_POINTER_DIFF_COMP)
16461661
{
16471662
JsonxPointerDiff*diff= (JsonxPointerDiff*)inline_data;
16481663

‎contrib/jsonb_toaster/jsonb_toaster.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,7 @@ jsonxSetPathInplace(JsonContainer *jc, int idx,
22722272
toast_diff=PointerGetDatum(
22732273
jsonx_toast_make_pointer_diff(jbcptr.toasterid,
22742274
&jbcptr.ptr,
2275+
jbcptr.compressed_chunks,
22752276
diff.offset,
22762277
len,val));
22772278

‎contrib/jsonb_toaster/jsonb_toaster.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#defineJSONX_POINTER_DIRECT_TIDS_COMP0x30000000
2424
#defineJSONX_POINTER_COMPRESSED_CHUNKS0x40000000
2525
#defineJSONX_POINTER_DIFF0x50000000
26+
#defineJSONX_POINTER_DIFF_COMP0x60000000
2627

2728
#defineJSONX_CUSTOM_PTR_HEADER_SIZE(INTALIGN(VARATT_CUSTOM_SIZE(0)) + sizeof(uint32))
2829

@@ -140,6 +141,7 @@ jsonx_toast_make_plain_pointer(Oid toasterid, JsonbContainerHeader *jbc, int len
140141

141142
externstructvarlena*
142143
jsonx_toast_make_pointer_diff(Oidtoasterid,structvaratt_external*ptr,
144+
boolcompressed_chunks,
143145
int32diff_offset,int32diff_len,
144146
constvoid*diff_data);
145147

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp