erthink / libmdbx

One of the fastest embeddable key-value ACID database without WAL. libmdbx surpasses the legendary LMDB in terms of reliability, features and performance.
https://erthink.github.io/libmdbx/
Other
1.16k stars 110 forks source link

is MDBX_INTEGERKEY support int32_t or int64_t ? #247

Closed gcxfd closed 2 years ago

gcxfd commented 2 years ago

I see the document wrtie

MDBX_INTEGERKEY | Numeric keys in native byte order either uint32_t or uint64_t. The keys must all be of the same size and must be aligned while passing as arguments.

I want kown is MDBX_INTEGERKEY support int32_t or int64_t or uint16_t or int16_t , uint128_t , int128_t?

erthink commented 2 years ago

Please RTFM.

gcxfd commented 2 years ago

I readed the code , seems only support u32 and u64


  /* Compare two items pointing at aligned unsigned int's. */
  static int __hot cmp_int_align4(const MDBX_val *a, const MDBX_val *b) {
    mdbx_assert(NULL, a->iov_len == b->iov_len);
    switch (a->iov_len) {
    case 4:
      return CMP2INT(unaligned_peek_u32(4, a->iov_base),
                     unaligned_peek_u32(4, b->iov_base));
    case 8:
      return CMP2INT(unaligned_peek_u64(4, a->iov_base),
                     unaligned_peek_u64(4, b->iov_base));
    default:
      mdbx_assert_fail(NULL, "invalid size for INTEGERKEY/INTEGERDUP", __func__,
                       __LINE__);
      return 0;
    }
  }
erthink commented 2 years ago

Please RTFM, the quote: "MDBX_INTEGERKEY | Numeric keys in native byte order either uint32_t or uint64_t. The keys must all be of the same size and must be aligned while passing as arguments."

So please ask clarifying questions related to the documentation if something is unclear, or do PR to improve the documentation. But (please) don't ask me to retell the source code.