MCPcopy Create free account
hub / github.com/apache/arrow / Cache

Method Cache

cpp/src/arrow/io/caching.cc:176–197  ·  view source on GitHub ↗

Add the given ranges to the cache, coalescing them where possible

Source from the content-addressed store, hash-verified

174
175 // Add the given ranges to the cache, coalescing them where possible
176 virtual Status Cache(std::vector<ReadRange> ranges) {
177 ARROW_ASSIGN_OR_RAISE(
178 ranges, internal::CoalesceReadRanges(std::move(ranges), options.hole_size_limit,
179 options.range_size_limit));
180 std::vector<RangeCacheEntry> new_entries = MakeCacheEntries(ranges);
181 // Add new entries, themselves ordered by offset
182 if (entries.size() > 0) {
183 std::vector<RangeCacheEntry> merged(entries.size() + new_entries.size());
184 std::merge(entries.begin(), entries.end(), new_entries.begin(), new_entries.end(),
185 merged.begin());
186 entries = std::move(merged);
187 } else {
188 entries = std::move(new_entries);
189 }
190 // Prefetch immediately, regardless of executor availability, if possible
191 auto st = file->WillNeed(ranges);
192 // As this is optimisation only, I/O failures should not be treated as fatal
193 if (st.IsIOError()) {
194 return Status::OK();
195 }
196 return st;
197 }
198
199 // Read the given range from the cache, blocking if needed. Cannot read a range
200 // that spans cache entries.

Callers

nothing calls this directly

Calls 7

CoalesceReadRangesFunction · 0.85
ARROW_ASSIGN_OR_RAISEFunction · 0.50
OKFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
WillNeedMethod · 0.45

Tested by

no test coverage detected