Skip to content
Snippets Groups Projects

Fixed bug in dada_db_split.cpp

Merged Niclas Esser requested to merge nesser/psrdada_cpp:devel into devel
1 file
+ 15
6
Compare changes
  • Side-by-side
  • Inline
@@ -31,9 +31,11 @@ DbSplitDb::DbSplitDb(std::vector<key_t> out_keys, MultiLog& log, std::size_t chu
@@ -31,9 +31,11 @@ DbSplitDb::DbSplitDb(std::vector<key_t> out_keys, MultiLog& log, std::size_t chu
exit(1);
exit(1);
}
}
}
}
if(_dsize % _chunk_size || _chunk_size > _dsize){
if(_chunk_size){
BOOST_LOG_TRIVIAL(error) << "Chunk size must be smaller than buffer size and buffer size must be multiple of chunk size";
if(_dsize % _chunk_size || _chunk_size > _dsize){
exit(1);
BOOST_LOG_TRIVIAL(error) << "Chunk size must be smaller than buffer size and buffer size must be multiple of chunk size";
 
exit(1);
 
}
}
}
(_chunk_size == 0)?_writes_per_slot=1:_writes_per_slot = _dsize / _chunk_size;
(_chunk_size == 0)?_writes_per_slot=1:_writes_per_slot = _dsize / _chunk_size;
}
}
@@ -65,11 +67,18 @@ bool DbSplitDb::operator()(RawBytes &dada_block)
@@ -65,11 +67,18 @@ bool DbSplitDb::operator()(RawBytes &dada_block)
return true;
return true;
}
}
// Acquire all out buffers and fill them
// Acquire all out buffers and fill them
 
for(uint i = 0; i < _writer.size(); i++){
for(uint i = 0; i < _writer.size(); i++){
auto &slot = _writer[i]->data_stream().next();
auto &slot = _writer[i]->data_stream().next();
for(uint j = 0; j < _writes_per_slot; j++){
if(_chunk_size){
memcpy(slot.ptr(j*_chunk_size), dada_block.ptr(j * _dsize + i * _chunk_size), dada_block.used_bytes());
for(uint j = 0; j < _writes_per_slot; j++){
slot.used_bytes(dada_block.used_bytes());
memcpy(slot.ptr(j*_chunk_size), dada_block.ptr(j * _dsize + i * _chunk_size), _dsize);
 
slot.used_bytes(j*_chunk_size);
 
}
 
}
 
else{
 
memcpy(slot.ptr(), dada_block.ptr(i * _dsize), _dsize);
 
slot.used_bytes(_dsize);
}
}
}
}
// As soon as all out buffers are full release them
// As soon as all out buffers are full release them
Loading