MCPcopy Create free account
hub / github.com/apache/orc / loadStringDictionary

Function loadStringDictionary

c++/src/DictionaryLoader.cc:45–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 } // namespace
44
45 std::shared_ptr<StringDictionary> loadStringDictionary(uint64_t columnId, StripeStreams& stripe,
46 MemoryPool& pool) {
47 // Get encoding information
48 proto::ColumnEncoding encoding = stripe.getEncoding(columnId);
49 RleVersion rleVersion = convertRleVersion(encoding.kind());
50 uint32_t dictSize = encoding.dictionary_size();
51
52 // Create the dictionary object
53 auto dictionary = std::make_shared<StringDictionary>(pool);
54
55 // Read LENGTH stream to get dictionary entry lengths
56 std::unique_ptr<SeekableInputStream> stream =
57 stripe.getStream(columnId, proto::Stream_Kind_LENGTH, false);
58 if (dictSize > 0 && stream == nullptr) {
59 std::stringstream ss;
60 ss << "LENGTH stream not found in StringDictionaryColumn for column " << columnId;
61 throw ParseError(ss.str());
62 }
63 std::unique_ptr<RleDecoder> lengthDecoder =
64 createRleDecoder(std::move(stream), false, rleVersion, pool, stripe.getReaderMetrics());
65
66 // Decode dictionary entry lengths
67 dictionary->dictionaryOffset.resize(dictSize + 1);
68 int64_t* lengthArray = dictionary->dictionaryOffset.data();
69 lengthDecoder->next(lengthArray + 1, dictSize, nullptr);
70 lengthArray[0] = 0;
71
72 // Convert lengths to cumulative offsets
73 for (uint32_t i = 1; i < dictSize + 1; ++i) {
74 if (lengthArray[i] < 0) {
75 std::stringstream ss;
76 ss << "Negative dictionary entry length for column " << columnId;
77 throw ParseError(ss.str());
78 }
79 lengthArray[i] += lengthArray[i - 1];
80 }
81
82 int64_t blobSize = lengthArray[dictSize];
83
84 // Read DICTIONARY_DATA stream to get dictionary content
85 dictionary->dictionaryBlob.resize(static_cast<uint64_t>(blobSize));
86 std::unique_ptr<SeekableInputStream> blobStream =
87 stripe.getStream(columnId, proto::Stream_Kind_DICTIONARY_DATA, false);
88 if (blobSize > 0 && blobStream == nullptr) {
89 std::stringstream ss;
90 ss << "DICTIONARY_DATA stream not found in StringDictionaryColumn for column " << columnId;
91 throw ParseError(ss.str());
92 }
93
94 // Read the dictionary blob
95 readFully(dictionary->dictionaryBlob.data(), blobSize, blobStream.get());
96
97 return dictionary;
98 }
99
100} // namespace orc

Callers 2

loadStripeDictionariesFunction · 0.85

Calls 11

convertRleVersionFunction · 0.85
ParseErrorClass · 0.85
createRleDecoderFunction · 0.85
readFullyFunction · 0.70
nextMethod · 0.65
getEncodingMethod · 0.45
getStreamMethod · 0.45
getReaderMetricsMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected