Last active
July 14, 2019 12:30
-
-
Save tebeka/851b07e85decbaf4f6faa7f6e985355b to your computer and use it in GitHub Desktop.
Getting item from column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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