Skip to content

Instantly share code, notes, and snippets.

@tebeka
Last active July 14, 2019 12:30
Show Gist options
  • Save tebeka/851b07e85decbaf4f6faa7f6e985355b to your computer and use it in GitHub Desktop.
Save tebeka/851b07e85decbaf4f6faa7f6e985355b to your computer and use it in GitHub Desktop.
Getting item from column
int column_bool_at(void *vp, long long i) {
auto column = (Column *)vp;
// TODO: errors
if (column == nullptr) {
return -1;
}
if (column->ptr->type()->id() != BOOL_DTYPE) {
return -1;
}
if ((i < 0) || (i >= column->ptr->length())) {
return -1;
}
auto chunks = column->ptr->data();
int index = i;
for (int c = 0; c < chunks->num_chunks(); c++) {
auto chunk = chunks->chunk(c);
if (index < chunk->length()) {
return chunk->data[index];
}
index -= chunk->length();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment