MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / handleKey

Method handleKey

src/function/cast_from_string_functions.cpp:433–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431};
432
433bool SplitStringMapOperation::handleKey(const char* start, const char* end,
434 const CSVOption* option) {
435 trimRightWhitespace(start, end);
436 auto fieldVector = StructVector::getFieldVector(resultVector, 0).get();
437 CastString::copyStringToVector(fieldVector, offset,
438 std::string_view{start, (uint32_t)(end - start)}, option);
439 if (fieldVector->isNull(offset)) {
440 throw common::ConversionException{"Map does not allow null as key."};
441 }
442 auto val = common::Value::createDefaultValue(fieldVector->dataType);
443 val.copyFromColLayout(fieldVector->getData() + fieldVector->getNumBytesPerValue() * offset,
444 fieldVector);
445 auto uniqueKey = uniqueKeys.insert(val).second;
446 if (!uniqueKey) {
447 throw common::ConversionException{"Map does not allow duplicate keys."};
448 }
449 return true;
450}
451
452void SplitStringMapOperation::handleValue(const char* start, const char* end,
453 const CSVOption* option) {

Callers 1

parseKeyOrValueFunction · 0.45

Calls 6

trimRightWhitespaceFunction · 0.85
copyFromColLayoutMethod · 0.80
getMethod · 0.45
isNullMethod · 0.45
getDataMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected