Content-Length: 452215 | pFad | http://github.com/postgrespro/postgres/commit/3aa51558cc26cdb77d5ed64665b1f8cbbf0bbc49

F1 Enable diffs for compressed chunks · postgrespro/postgres@3aa5155 · GitHub
Skip to content

Commit 3aa5155

Browse files
author
Nikita Glukhov
committed
Enable diffs for compressed chunks
1 parent 412eb4e commit 3aa5155

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
struct varlena *
142142
jsonx_toast_make_pointer_diff(Oid toasterid,
143143
struct varatt_external *toast_pointer,
144+
bool compressed_chunks,
144145
int32 diff_offset, int32 diff_len,
145146
const void *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
struct varlena *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-
uint32 header = ptr->has_diff ? JSONX_POINTER_DIFF :
176+
uint32 header = 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
char custom_ptr[JSONX_CUSTOM_PTR_HEADER_SIZE];
210217
char toast_ptr[TOAST_POINTER_SIZE];
211218
uint32 header = 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
#define JSONX_POINTER_DIRECT_TIDS_COMP 0x30000000
2424
#define JSONX_POINTER_COMPRESSED_CHUNKS 0x40000000
2525
#define JSONX_POINTER_DIFF 0x50000000
26+
#define JSONX_POINTER_DIFF_COMP 0x60000000
2627

2728
#define JSONX_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
extern struct varlena *
142143
jsonx_toast_make_pointer_diff(Oid toasterid, struct varatt_external *ptr,
144+
bool compressed_chunks,
143145
int32 diff_offset, int32 diff_len,
144146
const void *diff_data);
145147

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/3aa51558cc26cdb77d5ed64665b1f8cbbf0bbc49

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy