45 const uint32_t MINIMUM_READAHEAD_AMOUNT = 524288;
49 template <
typename IndexT>
52 m_cellstore(cellstore), m_end_key(end_key), m_scan_ctx(scan_ctx) {
59 uint16_t csversion = boost::any_cast<uint16_t>(cellstore->get_trailer()->get(
"version"));
66 iter = (start_key) ? index->lower_bound(start_key) : index->begin();
67 if (iter == index->end()) {
72 start_offset = iter.value();
74 if (!end_key || (end_iter = index->upper_bound(end_key)) == index->end())
78 if (end_iter == index->end())
90 uint32_t buf_size = cellstore->get_blocksize();
92 if (buf_size < MINIMUM_READAHEAD_AMOUNT)
93 buf_size = MINIMUM_READAHEAD_AMOUNT;
102 "readahead mode: %s", e.what());
147 template <
typename IndexT>
152 delete [] m_block.base;
154 delete m_key_decompressor;
166 template <
typename IndexT>
180 template <
typename IndexT>
189 ptr = m_cur_value.ptr + m_cur_value.length();
191 if (ptr >= m_block.end) {
192 if (!fetch_next_block_readahead(
true)) {
196 if (m_check_for_range_end && !m_key_decompressor->less_than(m_end_key)) {
202 m_cur_value.ptr = m_key_decompressor->add(ptr);
203 if (m_check_for_range_end && !m_key_decompressor->less_than(m_end_key)) {
212 m_key_decompressor->load(m_key);
214 || m_scan_ctx->family_mask[m_key.column_family_code])
236 template <
typename IndexT>
240 if (m_block.base != 0 && eob) {
241 delete [] m_block.base;
242 memset(&m_block, 0,
sizeof(m_block));
245 if (m_offset >= m_end_offset)
248 if (m_block.base == 0 && !m_eos) {
253 m_block.offset = m_offset;
260 nread =
Global::dfs->read(m_fd, input_buf.base, header.encoded_length() );
263 size_t remaining = nread;
265 header.decode((
const uint8_t **)&input_buf.ptr, &remaining);
273 input_buf.grow( input_buf.fill() + header.get_data_zlength() + extra );
274 nread =
Global::dfs->read(m_fd, input_buf.ptr, header.get_data_zlength()+extra);
276 input_buf.ptr += header.get_data_zlength() + extra;
278 if (m_offset + (int64_t)input_buf.fill() >= m_end_offset && m_end_key)
279 m_check_for_range_end =
true;
280 m_offset += input_buf.fill();
282 m_zcodec->inflate(input_buf, expand_buf, header);
284 m_disk_read += expand_buf.
fill();
288 "Error inflating cell store block - magic string mismatch");
291 HT_ERROR_OUT <<
"Error reading cell store ( fd=" << m_fd <<
" file="
292 << m_cellstore->get_filename() <<
") block: "
299 m_block.base = expand_buf.
release(&fill);
302 m_key_decompressor->reset();
303 m_block.end = m_block.base + len;
304 m_cur_value.ptr = m_key_decompressor->add(m_block.base);
#define HT_THROW2F(_code_, _ex_, _fmt_,...)
Retrieves system information (hardware, installation directory, etc)
CellStoreScannerIntervalReadahead(CellStorePtr &cellstore, IndexT *index, SerializedKey start_key, SerializedKey end_key, ScanContext *scan_ctx)
Abstract base class for a filesystem.
static const uint32_t FLAG_DELETE_ROW
Provides ability to efficiently scan over a portion of a cell store.
Scan context information.
Declarations for CellStoreScannerIntervalReadahead.
virtual bool get(Key &key, ByteString &value)
virtual void load(Key &key)=0
A dynamic, resizable and reference counted memory buffer.
#define HT_EXPECT(_e_, _code_)
A class managing one or more serializable ByteStrings.
virtual ~CellStoreScannerIntervalReadahead()
bool fetch_next_block_readahead(bool eob=false)
This method fetches the 'next' compressed block of key/value pairs from the underlying CellStore...
Compatibility Macros for C/C++.
virtual bool less_than(SerializedKey serialized_key)=0
static Hypertable::FilesystemPtr dfs
size_t length() const
Retrieves the length of the serialized string.
virtual const uint8_t * add(const uint8_t *ptr)=0
const uint8_t * ptr
The pointer to the serialized data.
std::shared_ptr< CellStore > CellStorePtr
Smart pointer to CellStore.
Provides access to internal components of opaque key.
size_t fill() const
Returns the size of the used portion.
static const char DATA_BLOCK_MAGIC[10]
This is a generic exception class for Hypertable.
#define HT_ERRORF(msg,...)
uint8_t * release(size_t *lenp=0)
Moves ownership of the buffer to the caller.
uint8_t column_family_code
BlockCompressionCodec * m_zcodec
KeyDecompressor * m_key_decompressor
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
#define HT_DIRECT_IO_ALIGNMENT
Declarations for CellStoreBlockIndexArray.
int code() const
Returns the error code.
#define HT_THROW2(_code_, _ex_, _msg_)
IndexT::iterator IndexIteratorT