Skip to content

Commit

Permalink
[debug] _cast_dictionary_values
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenv committed Feb 13, 2025
1 parent 073bf71 commit 7520a48
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libtiledbsoma/src/soma/managed_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ void ManagedQuery::_promote_indexes_to_values(
template <typename T>
void ManagedQuery::_cast_dictionary_values(
ArrowSchema* schema, ArrowArray* array) {
std::cout << "ManagedQuery::_cast_dictionary_values<T> 1" << std::endl;
// This is a column with a dictionary. However, the associated TileDB
// attribute on disk is not enumerated. Here, we map the dictionary indexes
// to the associated dictionary values and set the buffers to use the
Expand All @@ -805,6 +806,7 @@ void ManagedQuery::_cast_dictionary_values(
index_to_value.push_back(values[i]);
}

std::cout << "ManagedQuery::_cast_dictionary_values<T> 2" << std::endl;
setup_write_column(
schema->name,
array->length,
Expand All @@ -816,6 +818,7 @@ void ManagedQuery::_cast_dictionary_values(
template <>
void ManagedQuery::_cast_dictionary_values<std::string>(
ArrowSchema* schema, ArrowArray* array) {
std::cout << "ManagedQuery::_cast_dictionary_values<std::string> 1" << std::endl;
// String types require special handling due to large vs regular
// string/binary

Expand All @@ -838,6 +841,8 @@ void ManagedQuery::_cast_dictionary_values<std::string>(
}
}

std::cout << "ManagedQuery::_cast_dictionary_values<std::string> 2" << std::endl;

char* data = (char*)value_array->buffers[2];
std::string data_v(data, data + offsets_v[offsets_v.size() - 1]);

Expand All @@ -849,9 +854,13 @@ void ManagedQuery::_cast_dictionary_values<std::string>(
values.push_back(data_v.substr(beg, sz));
}

std::cout << "ManagedQuery::_cast_dictionary_values<std::string> 3" << std::endl;

std::vector<int64_t> indexes = ManagedQuery::_get_index_vector(
schema, array);

std::cout << "ManagedQuery::_cast_dictionary_values<std::string> 4" << std::endl;

uint64_t offset_sum = 0;
std::vector<uint64_t> value_offsets = {0};
std::string index_to_value;
Expand All @@ -862,12 +871,16 @@ void ManagedQuery::_cast_dictionary_values<std::string>(
index_to_value.insert(index_to_value.end(), value.begin(), value.end());
}

std::cout << "ManagedQuery::_cast_dictionary_values<std::string> 5" << std::endl;

setup_write_column(
schema->name,
value_offsets.size() - 1,
(const void*)index_to_value.data(),
(uint64_t*)value_offsets.data(),
std::nullopt); // validities are set by index column

std::cout << "ManagedQuery::_cast_dictionary_values<std::string> 6" << std::endl;
}

template <>
Expand Down

0 comments on commit 7520a48

Please sign in to comment.