Skip to content

Commit

Permalink
Hide ART and roaring64-internal types
Browse files Browse the repository at this point in the history
These don't actually need to be exposed to the user, so we can declare them in
the header and keep them private. ART types don't need to be declared at all.
  • Loading branch information
SLieve committed Jan 2, 2024
1 parent 24b22a9 commit 7c952c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
25 changes: 3 additions & 22 deletions include/roaring/roaring64.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,14 @@
#include <stddef.h>
#include <stdint.h>

// TODO: This is messy and can likely be improved.
#if defined(__cplusplus)
#define ROARING_ART_T ::roaring::internal::art_t
#define ROARING_ART_VAL_T ::roaring::internal::art_val_t
#else
#define ROARING_ART_T art_t
#define ROARING_ART_VAL_T art_val_t
#define ROARING_CONTAINER_T void
#endif

#ifdef __cplusplus
extern "C" {
namespace roaring {
namespace api {
#endif

typedef struct roaring64_bitmap_s {
ROARING_ART_T art;
uint8_t flags;
} roaring64_bitmap_t;

// TODO: Ideally we don't put this in the header.
typedef struct leaf_s {
ROARING_ART_VAL_T _pad;
uint8_t typecode;
ROARING_CONTAINER_T *container;
} leaf_t;
typedef struct roaring64_bitmap_s roaring64_bitmap_t;
typedef struct roaring64_leaf_s roaring64_leaf_t;

/**
* A bit of context usable with `roaring64_bitmap_*_bulk()` functions.
Expand All @@ -50,7 +31,7 @@ typedef struct leaf_s {
typedef struct roaring64_bulk_context_s {
uint8_t high_bytes[ART_KEY_BYTES];
uint16_t low_bytes;
leaf_t *leaf;
roaring64_leaf_t *leaf;
} roaring64_bulk_context_t;

/**
Expand Down
20 changes: 18 additions & 2 deletions src/roaring64.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <assert.h>
#include <roaring/art/art.h>
#include <roaring/containers/containers.h>
#include <roaring/roaring64.h>
#include <stdarg.h>
Expand Down Expand Up @@ -41,10 +42,9 @@ using namespace ::roaring::internal;

extern "C" {
namespace roaring {
namespace api64 {
namespace api {
#endif

// TODO: Figure out how to keep art_t from being exposed in roaring64.h
// TODO: Iteration.
// * Need to create a container iterator which can be used across 32 and 64 bit
// bitmaps.
Expand All @@ -53,6 +53,22 @@ namespace api64 {
// TODO: Serialization.
// TODO: Error on failed allocation.

typedef struct roaring64_bitmap_s {
art_t art;
uint8_t flags;
} roaring64_bitmap_t;

// Leaf type of the ART used to keep the high 48 bits of each entry.
typedef struct roaring64_leaf_s {
art_val_t _pad;
uint8_t typecode;
container_t *container;
} roaring64_leaf_t;

// Alias to make it easier to work with, since it's an internal-only type
// anyway.
typedef struct roaring64_leaf_s leaf_t;

// Splits the given uint64 key into high 48 bit and low 16 bit components.
// Expects high48_out to be of length ART_KEY_BYTES.
static inline uint16_t split_key(uint64_t key, uint8_t high48_out[]) {
Expand Down

0 comments on commit 7c952c1

Please sign in to comment.