Skip to content

Commit

Permalink
Fixed Select operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Griezn committed Nov 17, 2024
1 parent c6ac73e commit aca79ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")

if (CMAKE_BUILD_TYPE MATCHES "Debug")
add_compile_options(-fsanitize=address,undefined)
add_link_options(-fsanitize=address,undefined)
endif()

add_subdirectory(tests)

# Option to build benchmarks
Expand Down
7 changes: 4 additions & 3 deletions src/file_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <unistd.h>

#include "generator.h"
#include "utils.h"


data_t *get_next_file(const source_t *source)
Expand All @@ -23,8 +24,8 @@ data_t *get_next_file(const source_t *source)
data_t *data = malloc(sizeof(data_t));
assert(data);
data->data = fs->source.buffer.data + (fs->index * fs->source.buffer.width);
data->size = fs->inc;
data->width = data->width;
data->size = min(fs->inc, fs->source.buffer.size - fs->index);
data->width = source->buffer.width;

fs->index += fs->inc;

Expand Down Expand Up @@ -56,7 +57,7 @@ source_t *create_file_source(const char *filename, uint8_t width, uint32_t inc)
return NULL;
}
fs->source.buffer.data = triples;
fs->source.buffer.size = sb.st_size / sizeof(triple_t);
fs->source.buffer.size = sb.st_size / (sizeof(triple_t) * width);
fs->source.buffer.width = width;
fs->source.get_next = get_next_file;
fs->index = 0;
Expand Down
10 changes: 7 additions & 3 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ void select_query(const data_t *in, data_t *out, const parameter_t param)
out->width = param.select.size;
uint32_t out_idx = 0;

for (uint32_t i = 0; i < in->size * in->width; ++i) {
if (select_check(in, i, param.select))
out->data[out_idx++] = in->data[i];
for (uint32_t i = 0; i < in->size; ++i) {
for (uint32_t j = 0; j < in->width; ++j) {
if (select_check(in, i * in->width + j, param.select)) {
out->data[out_idx++] = in->data[i * in->width + j];
break;
}
}
}
}

Expand Down

0 comments on commit aca79ab

Please sign in to comment.