1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#ifndef __ROARING64_BUFFER_READER_H__
#define __ROARING64_BUFFER_READER_H__
#include "roaring_buffer_reader.h"
typedef struct roaring64_buffer_s {
const char *buf;
size_t buf_len;
int32_t size; /* number of 64-bit buckets (each holds a 32-bit roaring bitmap) */
const uint32_t *keys; /* upper 32 bits per bucket */
const roaring_buffer_t **rb_readers; /* buffer reader for 32-bit roaring bitmaps */
} roaring64_buffer_t;
/**
* Creates a new 64-bit roaring buffer reader (from a portable serialized 64-bit roaringbitmap buffer).
* The caller is responsible for freeing the result.
* Returns NULL if error occurred.
*/
roaring64_buffer_t *roaring64_buffer_create(const char *buf, size_t buf_len);
/**
* free 64-bit roaring buffer reader
*/
void roaring64_buffer_free(const roaring64_buffer_t *rb);
/**
* Get the cardinality of the bitmap (number of elements).
*/
uint64_t roaring64_buffer_get_cardinality(const roaring64_buffer_t *rb);
/**
* Check if value x is present
* Return false if error occurred.
*/
bool roaring64_buffer_contains(const roaring64_buffer_t *r,
uint64_t val,
bool *result);
/**
* Check if all the elements of ra1 are also in ra2.
* Return false if error occurred.
*/
bool roaring64_buffer_is_subset(const roaring64_buffer_t *ra1,
const roaring64_buffer_t *ra2,
bool *result);
/**
* Computes the intersection between two bitmaps.
* Return false if error occurred.
*/
bool roaring64_buffer_and_cardinality(const roaring64_buffer_t *x1,
const roaring64_buffer_t *x2,
uint64_t *result);
/**
* Computes the size of the union between two bitmaps.
* Return false if error occurred.
*/
bool roaring64_buffer_or_cardinality(const roaring64_buffer_t *x1,
const roaring64_buffer_t *x2,
uint64_t *result);
/**
* Computes the size of the difference (andnot) between two bitmaps.
* Return false if error occurred.
*/
bool roaring64_buffer_andnot_cardinality(const roaring64_buffer_t *x1,
const roaring64_buffer_t *x2,
uint64_t *result);
/**
* Computes the size of the symmetric difference between two bitmaps.
* Return false if error occurred.
*/
bool roaring64_buffer_xor_cardinality(const roaring64_buffer_t *x1,
const roaring64_buffer_t *x2,
uint64_t *result);
/**
* Computes the Jaccard index between two bitmaps.
* Return false if error occurred.
*/
bool roaring64_buffer_jaccard_index(const roaring64_buffer_t *x1,
const roaring64_buffer_t *x2,
double *result);
/**
* Check whether two bitmaps intersect.
* Return false if error occurred.
*/
bool roaring64_buffer_intersect(const roaring64_buffer_t *x1,
const roaring64_buffer_t *x2,
bool *result);
/**
* Returns true if the bitmap is empty (cardinality is zero).
*/
bool roaring64_buffer_is_empty(const roaring64_buffer_t *rb);
/**
* Check if the two bitmaps contain the same elements.
* Return false if error occurred.
*/
bool roaring64_buffer_equals(const roaring64_buffer_t *rb1,
const roaring64_buffer_t *rb2,
bool *result);
/**
* Count the number of integers that are smaller or equal to x.
* Return false if error occurred.
*/
bool roaring64_buffer_rank(const roaring64_buffer_t *rb,
uint64_t x,
uint64_t *result);
/**
* Get the smallest value in the set, or UINT64_MAX if the set is empty.
* Return false if error occurred.
*/
bool roaring64_buffer_minimum(const roaring64_buffer_t *rb,
uint64_t *result);
/**
* Get the greatest value in the set, or 0 if the set is empty.
* Return false if error occurred.
*/
bool roaring64_buffer_maximum(const roaring64_buffer_t *rb,
uint64_t *result);
#endif
|