Skip to content

Commit f173b80

Browse files
author
Artur Zakirov
committed
Add length of RumKey into Logical Tape
1 parent 8e868f1 commit f173b80

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

rumsort.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4089,11 +4089,13 @@ copytup_rumkey(Tuplesortstate *state, SortTuple *stup, void *tup)
40894089
static void
40904090
writetup_rumkey(Tuplesortstate *state, int tapenum, SortTuple *stup)
40914091
{
4092-
RumKey *item = (RumKey *) stup->tuple;
4093-
unsigned int writtenlen = sizeof(*item);
4092+
RumKey *item = (RumKey *) stup->tuple;
4093+
unsigned int writtenlen = sizeof(*item) + sizeof(unsigned int);
40944094

40954095
LogicalTapeWrite(state->tapeset, tapenum,
4096-
(void *) item, writtenlen);
4096+
(void *) &writtenlen, sizeof(writtenlen));
4097+
LogicalTapeWrite(state->tapeset, tapenum,
4098+
(void *) item, sizeof(*item));
40974099
if (state->randomAccess) /* need trailing length word? */
40984100
LogicalTapeWrite(state->tapeset, tapenum,
40994101
(void *) &writtenlen, sizeof(writtenlen));
@@ -4106,18 +4108,19 @@ static void
41064108
readtup_rumkey(Tuplesortstate *state, SortTuple *stup,
41074109
int tapenum, unsigned int len)
41084110
{
4109-
RumKey *item = (RumKey *) palloc(sizeof(RumKey));
4111+
unsigned int tuplen = len - sizeof(unsigned int);
4112+
RumKey *item = (RumKey *) palloc(sizeof(RumKey));
41104113

4111-
Assert(len == sizeof(RumKey));
4114+
Assert(tuplen == sizeof(RumKey));
41124115

41134116
USEMEM(state, GetMemoryChunkSpace(item));
41144117
LogicalTapeReadExact(state->tapeset, tapenum,
4115-
(void *) item, len);
4118+
(void *) item, tuplen);
41164119
stup->isnull1 = true;
41174120
stup->tuple = item;
41184121

41194122
if (state->randomAccess) /* need trailing length word? */
41204123
LogicalTapeReadExact(state->tapeset, tapenum,
4121-
&len, sizeof(len));
4124+
&tuplen, sizeof(tuplen));
41224125
}
41234126

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy