Hi,
> I'm wondering if we should replace `state->memtuples` with `data` in the
> `sort_byvalue_datum()` function here.
+1. Now data == state->memtuples, how about remove the parameter "data" and "n"
and just
get them from "Tuplesortstate"?
Some comments for v7:
1)
```
/*
* Retrieve byte from datum, indexed by 'level': 0 for LSB, 7 for MSB
*/
static inline uint8
current_byte(Datum key, int level)
{
int shift = (SIZEOF_DATUM - 1 - level) *
BITS_PER_BYTE;
return (key >> shift) & 0xFF;
}
```
Maybe "0 for MSB, 7 for LSB"? If level == 0, this function will return the Most
Significant Byte.
2) radix_sort_tuple()
```
size_t end_offset = partitions[*rp].next_offset;
SortTuple *partition_end = begin + end_offset;
ptrdiff_t num_elements = end_offset - start_offset;
```
Why the type of "num_elements" is "ptrdiff_t"? Maybe just "size_t"?
3) tuplesort_sort_memtuples()
```
/*
* Do we have the leading column's value or abbreviation in
datum1?
*/
if (state->base.haveDatum1 && state->base.sortKeys)
{
SortSupportData ssup = state->base.sortKeys[0];
```
I think we should avoid the copy of SortSupportData. We can just use a pointer.
4)
Many places just consider "Datum" as integer, do we need to add a
DatumGetUInt**() for them?
--
Regards,
ChangAo Chen