Beispiel #1
0
int view_key_cmp(const sized_buf *key1, const sized_buf *key2,
                 const void *user_ctx)
{
    uint16_t json_key1_len = decode_raw16(*((raw_16 *) key1->buf));
    uint16_t json_key2_len = decode_raw16(*((raw_16 *) key2->buf));
    sized_buf json_key1;
    sized_buf json_key2;
    sized_buf doc_id1;
    sized_buf doc_id2;
    int res;

    (void)user_ctx;

    json_key1.buf = key1->buf + sizeof(uint16_t);
    json_key1.size = json_key1_len;
    json_key2.buf = key2->buf + sizeof(uint16_t);
    json_key2.size = json_key2_len;

    res = CollateJSON(&json_key1, &json_key2, kCollateJSON_Unicode);

    if (res == 0) {
        doc_id1.buf = key1->buf + sizeof(uint16_t) + json_key1.size;
        doc_id1.size = key1->size - sizeof(uint16_t) - json_key1.size;
        doc_id2.buf = key2->buf + sizeof(uint16_t) + json_key2.size;
        doc_id2.size = key2->size - sizeof(uint16_t) - json_key2.size;

        res = ebin_cmp(&doc_id1, &doc_id2);
    }

    return res;
}
Beispiel #2
0
int view_id_cmp(const sized_buf *key1, const sized_buf *key2,
                const void *user_ctx)
{
    (void)user_ctx;
    return ebin_cmp(key1, key2);
}
Beispiel #3
0
static int ebin_ptr_compare(const void *a, const void *b)
{
    const sized_buf* const* buf1 = a;
    const sized_buf* const* buf2 = b;
    return ebin_cmp(*buf1, *buf2);
}
Beispiel #4
0
static int id_ptr_cmp(const void *a, const void *b)
{
    sized_buf **buf1 = (sized_buf**) a;
    sized_buf **buf2 = (sized_buf**) b;
    return ebin_cmp(*buf1, *buf2);
}