Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a previous contiguous array fix in Dysco #1337

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tables/Dysco/bytepacker.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef DYSCO_BYTE_PACKER_H
#define DYSCO_BYTE_PACKER_H

#include <stdexcept>
#include <cstdint>
#include <stdexcept>

namespace dyscostman {

Expand Down
12 changes: 6 additions & 6 deletions tables/Dysco/threadeddyscocolumn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,20 @@ void ThreadedDyscoColumn<DataType>::loadBlock(size_t blockIndex) {
template <typename DataType>
void ThreadedDyscoColumn<DataType>::getValues(
casacore::rownr_t rowNr, casacore::Array<DataType> *dataArr) {
// Make sure array storage is contiguous.
casacore::Bool deleteIt;
DataType* dataPtr = dataArr->getStorage (deleteIt);
if (!areOffsetsInitialized()) {
// Trying to read before first block was written -- return zero
// TODO if a few rows were written of the first block, those are
// incorrectly returned. This is a rare case but can be fixed.
*dataPtr = DataType();
*dataArr = DataType();
} else {
size_t blockIndex = getBlockIndex(rowNr);
if (blockIndex >= nBlocksInFile()) {
// Trying to read a row that was not stored yet -- return zero
*dataPtr = DataType();
*dataArr = DataType();
} else {
// Make sure array storage is contiguous.
casacore::Bool deleteIt;
DataType* dataPtr = dataArr->getStorage (deleteIt);
std::unique_lock<std::mutex> lock(_mutex);
// Wait until the block to be read is not in the write cache
typename cache_t::const_iterator cacheItemPtr = _cache.find(blockIndex);
Expand All @@ -137,9 +137,9 @@ void ThreadedDyscoColumn<DataType>::getValues(
// The time block encoder is now initialized and contains the unpacked
// block.
_timeBlockBuffer->GetData(getRowWithinBlock(rowNr), dataPtr);
dataArr->putStorage (dataPtr, deleteIt);
}
}
dataArr->putStorage (dataPtr, deleteIt);
}

template <typename DataType>
Expand Down
Loading