Skip to content

Commit

Permalink
fix seekable handle
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Mar 13, 2024
1 parent f529745 commit 04c5501
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
8 changes: 0 additions & 8 deletions src/fdb5/database/Archiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ Archiver::Archiver(const Config& dbConfig) :

Archiver::~Archiver() {
flush(); // certify that all sessions are flushed before closing them

// for (auto it = databases_.begin(); it != databases_.end(); it++) {
// databases_.erase(it);
// }

// std::cout << databases_.size();

// databases_.clear(); //< explicitly delete the DBs before schemas are destroyed
}

void Archiver::archive(const Key &key, const void* data, size_t len) {
Expand Down
18 changes: 11 additions & 7 deletions src/fdb5/io/FieldHandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ FieldHandle::FieldHandle(ListIterator& it) :
for (size_t i=0; i< cube.size(); i++) {
ListElement element;
if (cube.find(i, element)) {
datahandles_.push_back(std::make_pair(el.location().length(), el.location().dataHandle()));
eckit::Length len = el.location().length();
eckit::Length len = element.location().length();
eckit::DataHandle* dh = element.location().dataHandle();
datahandles_.push_back(std::make_pair(len, dh));

totalSize_ += len;
bool canSeek = el.location().dataHandle()->canSeek();
bool canSeek = dh->canSeek();
if (!canSeek) {
largest = std::max(largest, len);
seekable_ = false;
Expand All @@ -84,11 +86,12 @@ FieldHandle::FieldHandle(ListIterator& it) :
}
else {
while (it.next(el)) {
datahandles_.push_back(std::make_pair(el.location().length(), el.location().dataHandle()));

eckit::Length len = el.location().length();
eckit::DataHandle* dh = el.location().dataHandle();
datahandles_.push_back(std::make_pair(len, dh));

totalSize_ += len;
bool canSeek = el.location().dataHandle()->canSeek();
bool canSeek = dh->canSeek();
if (!canSeek) {
largest = std::max(largest, len);
seekable_ = false;
Expand Down Expand Up @@ -128,7 +131,8 @@ void FieldHandle::openCurrent() {
current_->openForRead();

if (!current_->canSeek()) {
current_->read(buffer_, currentSize);
auto len = current_->read(buffer_, currentSize);
ASSERT(len == currentSize);
current_ = new eckit::MemoryHandle(buffer_, currentSize);
current_->openForRead();
currentMemoryHandle_ = true;
Expand Down
9 changes: 7 additions & 2 deletions src/fdb5/remote/RemoteStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ class FDBRemoteDataHandle : public DataHandle {

// Are we now complete?
if (msg.first == Message::Complete) {
complete_ = 0;
return 0;
if (overallPosition_ == eckit::Offset(0)) {
ASSERT(queue_.pop(msg) != -1);
} else {
complete_ = true;
return 0;
}
}

ASSERT(msg.first == Message::Blob);
Expand All @@ -116,6 +120,7 @@ class FDBRemoteDataHandle : public DataHandle {

long bufferRead(void* pos, long sz) {


ASSERT(currentBuffer_.size() != 0);
ASSERT(pos_ < currentBuffer_.size());

Expand Down

0 comments on commit 04c5501

Please sign in to comment.