MCPcopy Create free account
hub / github.com/alibaba/zvec / extract_binary_array

Function extract_binary_array

src/binding/c/c_api.cc:3172–3192  ·  view source on GitHub ↗

Helper function to extract binary array from raw data

Source from the content-addressed store, hash-verified

3170
3171// Helper function to extract binary array from raw data
3172std::vector<std::string> extract_binary_array(const void *value,
3173 size_t value_size) {
3174 std::vector<std::string> binary_array;
3175 const char *data = static_cast<const char *>(value);
3176 size_t pos = 0;
3177
3178 while (pos < value_size) {
3179 if (pos + sizeof(uint32_t) > value_size) {
3180 break;
3181 }
3182 uint32_t bin_len = *reinterpret_cast<const uint32_t *>(data + pos);
3183 pos += sizeof(uint32_t);
3184
3185 if (pos + bin_len > value_size) {
3186 break;
3187 }
3188 binary_array.emplace_back(data + pos, bin_len);
3189 pos += bin_len;
3190 }
3191 return binary_array;
3192}
3193
3194static zvec::Result<std::vector<zvec::Doc>> convert_zvec_docs_to_internal(
3195 const zvec_doc_t **zvec_docs, size_t doc_count) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected