Skip to content

Commit

Permalink
Fix a previous contiguous array fix in Dysco
Browse files Browse the repository at this point in the history
  • Loading branch information
aroffringa committed Feb 15, 2024
1 parent d7d5a12 commit 2faa79a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit 2faa79a

Please sign in to comment.