int
compareItemPointers(ItemPointer a, ItemPointer b)
{
	if (GinItemPointerGetBlockNumber(a) == GinItemPointerGetBlockNumber(b))
	{
		if (GinItemPointerGetOffsetNumber(a) == GinItemPointerGetOffsetNumber(b))
			return 0;
		return (GinItemPointerGetOffsetNumber(a) > GinItemPointerGetOffsetNumber(b)) ? 1 : -1;
	}

	return (GinItemPointerGetBlockNumber(a) > GinItemPointerGetBlockNumber(b)) ? 1 : -1;
}
示例#2
0
static inline uint64
itemptr_to_uint64(const ItemPointer iptr)
{
	uint64		val;

	Assert(ItemPointerIsValid(iptr));
	Assert(GinItemPointerGetOffsetNumber(iptr) < (1 << MaxHeapTuplesPerPageBits));

	val = GinItemPointerGetBlockNumber(iptr);
	val <<= MaxHeapTuplesPerPageBits;
	val |= GinItemPointerGetOffsetNumber(iptr);

	return val;
}
int
ginCompareItemPointers(ItemPointer a, ItemPointer b)
{
    BlockNumber ba = GinItemPointerGetBlockNumber(a);
    BlockNumber bb = GinItemPointerGetBlockNumber(b);

    if (ba == bb)
    {
        OffsetNumber oa = GinItemPointerGetOffsetNumber(a);
        OffsetNumber ob = GinItemPointerGetOffsetNumber(b);

        if (oa == ob)
            return 0;
        return (oa > ob) ? 1 : -1;
    }

    return (ba > bb) ? 1 : -1;
}