Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite parquet_find_span function with start key, end key as paramters && polish queue FOR_EACH macro. #816

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/nng/supplemental/nanolib/parquet.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int parquet_write_batch_async(parquet_object *elem);
int parquet_write_launcher(conf_parquet *conf);

const char *parquet_find(uint64_t key);
const char **parquet_find_span(uint64_t key, uint32_t offset, uint32_t *size);
const char **parquet_find_span(uint64_t start_key, uint64_t end_key, uint32_t *size);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions src/mqtt/protocol/exchange/exchange_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,8 @@ ex_query_recv_cb(void *arg)
#ifdef SUPP_PARQUET
const char **fnames = NULL;
uint32_t sz = 0;
/* parquet not support fuzz search now, offset means endKey-startKey */
fnames = parquet_find_span(startKey, endKey - startKey, &sz);
/* parquet not support fuzz search now */
fnames = parquet_find_span(startKey, endKey, &sz);
if (fnames && sz > 0) {
ret = get_parquet_files(sz, (char **)fnames, obj);
if (ret != 0) {
Expand Down
10 changes: 5 additions & 5 deletions src/supplemental/nanolib/parquet/parquet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,18 +441,18 @@ parquet_find(uint64_t key)
}

const char **
parquet_find_span(uint64_t key, uint32_t offset, uint32_t *size)
parquet_find_span(uint64_t start_key, uint64_t end_key, uint32_t *size)
{
if (offset <= 0 || offset > key) {
log_error("offset can't be negative or greater than key.");
if (start_key > end_key) {
log_error("Start key can't be greater than end_key.");
*size = 0;
return NULL;
}

WAIT_FOR_AVAILABLE

uint64_t low = key - offset;
uint64_t high = key + offset;
uint64_t low = start_key;
uint64_t high = end_key;
uint32_t local_size = 0;
const char *value = NULL;
const char **array = NULL;
Expand Down
8 changes: 7 additions & 1 deletion src/supplemental/nanolib/parquet/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ typedef struct {


#define FOREACH_QUEUE(queue, elem) \
for (int i = (queue).front < 0 ? 0 : (queue).front; elem = (queue).array[i], (queue).size != 0 && i != NEXT_INDEX((queue).rear, (queue).capacity); i = NEXT_INDEX(i, (queue).capacity))
for (int i = (queue).front, _count = 0; \
(queue).size != 0 && _count < (queue).size; \
i = NEXT_INDEX(i, (queue).capacity), _count++) \
\
for (elem = (queue).array[i]; \
elem != NULL; \
elem = NULL)

#define DESTROY_QUEUE(queue) free((queue).array)

Expand Down
Loading