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

Method readBlock

src/processor/operator/persistent/reader/npy/npy_reader.cpp:218–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void NpyReader::readBlock(block_idx_t blockIdx, ValueVector* vectorToRead) const {
219 uint64_t rowNumber = DEFAULT_VECTOR_CAPACITY * blockIdx;
220 auto numRows = getNumRows();
221 if (rowNumber >= numRows) {
222 vectorToRead->state->getSelVectorUnsafe().setSelSize(0);
223 } else {
224 auto rowPointer = getPointerToRow(rowNumber);
225 auto numRowsToRead = std::min(DEFAULT_VECTOR_CAPACITY, getNumRows() - rowNumber);
226 const auto& rowType = vectorToRead->dataType;
227 if (rowType.getLogicalTypeID() == LogicalTypeID::ARRAY) {
228 auto numValuesPerRow = ArrayType::getNumElements(rowType);
229 for (auto i = 0u; i < numRowsToRead; i++) {
230 auto listEntry = ListVector::addList(vectorToRead, numValuesPerRow);
231 vectorToRead->setValue(i, listEntry);
232 }
233 auto dataVector = ListVector::getDataVector(vectorToRead);
234 memcpy(dataVector->getData(), rowPointer,
235 numRowsToRead * numValuesPerRow * dataVector->getNumBytesPerValue());
236 vectorToRead->state->getSelVectorUnsafe().setSelSize(numRowsToRead);
237 } else {
238 memcpy(vectorToRead->getData(), rowPointer,
239 numRowsToRead * vectorToRead->getNumBytesPerValue());
240 vectorToRead->state->getSelVectorUnsafe().setSelSize(numRowsToRead);
241 }
242 }
243}
244
245NpyMultiFileReader::NpyMultiFileReader(const std::vector<std::string>& filePaths) {
246 for (auto& file : filePaths) {

Callers 1

tableFuncFunction · 0.80

Calls 9

getNumElementsFunction · 0.85
addListFunction · 0.85
setSelSizeMethod · 0.80
getLogicalTypeIDMethod · 0.80
getNumRowsFunction · 0.50
getDataVectorFunction · 0.50
setValueMethod · 0.45
getDataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected