Re: I: About "Our CLUSTER implementation is pessimal" patch

Поиск
Список
Период
Сортировка
Искать
От
Takahiro Itagaki
Тема
Re: I: About "Our CLUSTER implementation is pessimal" patch
Дата
Msg-id
20100707173938.9809.52131E4D@oss.ntt.co.jp
Ответ на
Список
Дерево обсуждения
About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Greg Stark <stark@mit.edu>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Tom Lane <tgl@sss.pgh.pa.us>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Tom Lane <tgl@sss.pgh.pa.us>
Re: About "Our CLUSTER implementation is pessimal" patch Greg Stark <stark@mit.edu>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Tom Lane <tgl@sss.pgh.pa.us>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Robert Haas <robertmhaas@gmail.com>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Tom Lane <tgl@sss.pgh.pa.us>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Tom Lane <tgl@sss.pgh.pa.us>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>
Re: About "Our CLUSTER implementation is pessimal" patch Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>
Re: About "Our CLUSTER implementation is pessimal" patch Tom Lane <tgl@sss.pgh.pa.us>
Re: About "Our CLUSTER implementation is pessimal" patch Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>
Re: About "Our CLUSTER implementation is pessimal" patch Leonardo F <m_lists@yahoo.it>

Leonardo F  wrote:

> I saw that you also changed the writing:
(snip)
> Are we sure it's 100% equivalent?

I think writetup_rawheap() and readtup_rawheap() are a little complex,
but should work as long as there are no padding between t_len and t_self
in HeapTupleData struct.

- It might be cleaner if you write the total item length and tuple data separately.
- "(char *) tuple + sizeof(tuplen)" might be more robust than "&tuple->t_self".

Here is a sample code. writetup() and readtup() will be alike.

BTW, we could have LogicalTapeReadExact() as an alias of
LogicalTapeRead() and checking the result because we have
many duplicated codes for "unexpected end of data" errors.


static void
writetup_rawheap(Tuplesortstate *state, int tapenum, SortTuple *stup)
{HeapTuple	tuple = (HeapTuple) stup->tuple;int	    	tuplen = tuple->t_len + HEAPTUPLESIZE;
LogicalTapeWrite(state->tapeset, tapenum,				 &tuplen, sizeof(tuplen));LogicalTapeWrite(state->tapeset, tapenum,				 (char *) tuple + sizeof(tuplen),				 HEAPTUPLESIZE - sizeof(tuplen);LogicalTapeWrite(state->tapeset, tapenum, tuple->t_data, tuple->t_len);if (state->randomAccess)	/* need trailing length word? */	LogicalTapeWrite(state->tapeset, tapenum, &tuplen, sizeof(tuplen));
FREEMEM(state, GetMemoryChunkSpace(tuple));heap_freetuple(tuple);
}

static void
readtup_rawheap(Tuplesortstate *state, SortTuple *stup,			int tapenum, unsigned int tuplen)
{HeapTuple	tuple = (HeapTuple) palloc(tuplen);
USEMEM(state, GetMemoryChunkSpace(tuple));
tuple->t_len = tuplen - HEAPTUPLESIZE;if (LogicalTapeRead(state->tapeset, tapenum,					 (char *) tuple + sizeof(tuplen),		HEAPTUPLESIZE - sizeof(tuplen)) != HEAPTUPLESIZE - sizeof(tuplen))	elog(ERROR, "unexpected end of data");tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);if (LogicalTapeRead(state->tapeset, tapenum,					tuple->t_data, tuple->t_len) != tuple->t_len)	elog(ERROR, "unexpected end of data");if (state->randomAccess)	/* need trailing length word? */	if (LogicalTapeRead(state->tapeset, tapenum, &tuplen,						sizeof(tuplen)) != sizeof(tuplen))		elog(ERROR, "unexpected end of data");


Regards,
---
Takahiro Itagaki
NTT Open Source Software Center



В списке pgsql-hackers по дате отправления
От: Peter Froehlich
Дата:
Сообщение: Python Interface Hacking
От: Dimitri Fontaine
Дата:
FAQ