0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CellStoreV0.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #include "Common/Compat.h"
23 #include <cassert>
24 
25 #include <boost/algorithm/string.hpp>
26 #include <boost/scoped_array.hpp>
27 
28 #include "Common/Error.h"
29 #include "Common/Logger.h"
30 #include "Common/System.h"
31 
32 #include "AsyncComm/Protocol.h"
33 
36 #include "Hypertable/Lib/Key.h"
37 #include "Hypertable/Lib/Schema.h"
38 
39 #include "CellStoreV0.h"
40 #include "CellStoreTrailerV0.h"
41 #include "CellStoreScanner.h"
42 
43 #include "FileBlockCache.h"
44 #include "Global.h"
45 #include "Config.h"
46 
47 using namespace std;
48 using namespace Hypertable;
49 
50 namespace {
51  const uint32_t MAX_APPENDS_OUTSTANDING = 3;
52  const uint16_t BLOCK_HEADER_FORMAT = 0;
53 }
54 
55 
56 CellStoreV0::CellStoreV0(Filesystem *filesys)
57  : m_filesys(filesys), m_fd(-1), m_filename(), m_compressor(0), m_buffer(0),
58  m_fix_index_buffer(0), m_var_index_buffer(0), m_memory_consumed(0),
59  m_outstanding_appends(0), m_offset(0), m_last_key(0), m_file_length(0),
60  m_disk_usage(0), m_file_id(0), m_uncompressed_blocksize(0),
61  m_bloom_filter_mode(BLOOM_FILTER_DISABLED), m_bloom_filter(0),
62  m_bloom_filter_items(0) {
63 
65  assert(sizeof(float) == 4);
66 }
67 
68 
70  try {
71  delete m_compressor;
72 
73  if (m_bloom_filter != 0) {
74  delete m_bloom_filter;
75  }
76  if (m_bloom_filter_items != 0) {
77  delete m_bloom_filter_items;
78  }
79  if (m_fd != -1)
81  }
82  catch (Exception &e) {
83  HT_ERROR_OUT << e << HT_END;
84  }
87 }
88 
89 
93 }
94 
95 
97  return make_shared<CellStoreScanner<CellStoreBlockIndexArray<uint32_t>>>(shared_from_this(), scan_ctx, &m_index_map32);
98 }
99 
100 
101 void
102 CellStoreV0::create(const char *fname, size_t max_entries,
103  PropertiesPtr &props, const TableIdentifier *table_id) {
104  int32_t blocksize = props->get("blocksize", 0);
105  String compressor = props->get("compressor", String());
106 
107  assert(Config::properties); // requires Config::init* first
108 
109  if (blocksize == 0)
110  blocksize = Config::get_i32("Hypertable.RangeServer.CellStore"
111  ".DefaultBlockSize");
112  if (compressor.empty())
113  compressor = Config::get_str("Hypertable.RangeServer.CellStore"
114  ".DefaultCompressor");
115  if (!props->has("bloom-filter-mode")) {
116  // probably not called from AccessGroup
117  AccessGroupOptions::parse_bloom_filter(Config::get_str("Hypertable.RangeServer"
118  ".CellStore.DefaultBloomFilter"), props);
119  }
120 
121  m_buffer.reserve(blocksize*4);
122 
123  m_max_entries = max_entries;
124 
125  m_fd = -1;
126  m_offset = 0;
127  m_last_key = 0;
128  m_fix_index_buffer.reserve(blocksize);
129  m_var_index_buffer.reserve(blocksize);
130 
131  m_uncompressed_data = 0.0;
132  m_compressed_data = 0.0;
133 
134  m_trailer.clear();
135  m_trailer.blocksize = blocksize;
136  m_uncompressed_blocksize = blocksize;
137 
138  m_filename = fname;
139 
140  m_start_row = "";
142 
144  compressor, m_compressor_args);
145 
149 
151 
152  m_bloom_filter_mode = props->get<BloomFilterMode>("bloom-filter-mode");
153  m_max_approx_items = props->get_i32("max-approx-items");
154  m_trailer.filter_false_positive_prob = props->get_f64("false-positive");
155 
157  m_bloom_filter_items = new BloomFilterItems(); // aproximator items
158  }
159  HT_DEBUG_OUT <<"bloom-filter-mode="<< m_bloom_filter_mode
160  <<" max-approx-items="<< m_max_approx_items <<" false-positive="
162 }
163 
164 
165 void CellStoreV0::create_bloom_filter(bool is_approx) {
167 
168  HT_DEBUG_OUT << "Creating new BloomFilter for CellStore '"
169  << m_filename <<"' for "<< (is_approx ? "estimated " : "")
170  << m_trailer.num_filter_items << " items"<< HT_END;
171  try {
174  }
175  catch (Exception &e) {
176  HT_FATAL_OUT << "Error creating new BloomFilter for CellStore '"
177  << m_filename <<"' for "<< (is_approx ? "estimated " : "")
178  << m_trailer.num_filter_items << " items - "<< e << HT_END;
179  }
180 
181  for (const auto &blob : *m_bloom_filter_items)
182  m_bloom_filter->insert(blob.start, blob.size);
183 
184  delete m_bloom_filter_items;
185  m_bloom_filter_items = 0;
186 
187  HT_DEBUG_OUT << "Created new BloomFilter for CellStore '"
188  << m_filename <<"'"<< HT_END;
189 }
190 
191 
192 void CellStoreV0::add(const Key &key, const ByteString value) {
193  EventPtr event_ptr;
194  DynamicBuffer zbuf;
195 
196  if (key.revision > m_trailer.revision)
198 
200  BlockHeaderCellStore header(BLOCK_HEADER_FORMAT, DATA_BLOCK_MAGIC);
201 
203 
204  m_uncompressed_data += (float)m_buffer.fill();
205  m_compressor->deflate(m_buffer, zbuf, header);
206  m_compressed_data += (float)zbuf.fill();
207  m_buffer.clear();
208 
209  uint64_t llval = ((uint64_t)m_trailer.blocksize
210  * (uint64_t)m_uncompressed_data) / (uint64_t)m_compressed_data;
211  m_uncompressed_blocksize = (uint32_t)llval;
212 
213  if (m_outstanding_appends >= MAX_APPENDS_OUTSTANDING) {
214  if (!m_sync_handler.wait_for_reply(event_ptr)) {
215  if (event_ptr->type == Event::MESSAGE)
217  "Problem writing to FS file '%s' : %s", m_filename.c_str(),
219  HT_THROWF(event_ptr->error,
220  "Problem writing to FS file '%s'", m_filename.c_str());
221  }
223  }
224 
225  size_t zlen = zbuf.fill();
226  StaticBuffer send_buf(zbuf);
227 
229  catch (Exception &e) {
230  HT_THROW2F(e.code(), e, "Problem writing to FS file '%s'",
231  m_filename.c_str());
232  }
234  m_offset += zlen;
235  }
236 
237  size_t value_len = value.length();
238 
239  m_buffer.ensure(key.length + value_len);
240 
242  m_buffer.add_unchecked(value.ptr, value_len);
243 
246  m_bloom_filter_items->insert(key.row, key.row_len);
247 
249  m_bloom_filter_items->insert(key.row, key.row_len + 2);
250 
252  m_trailer.num_filter_items = (size_t)(((double)m_max_entries
253  / (double)m_max_approx_items) * m_bloom_filter_items->size());
254  create_bloom_filter(true);
255  }
256  }
257  else {
258  assert(!m_bloom_filter_items && m_bloom_filter);
259 
260  m_bloom_filter->insert(key.row);
261 
263  m_bloom_filter->insert(key.row, key.row_len + 2);
264  }
265  }
266 
268 }
269 
270 
271 void CellStoreV0::finalize(TableIdentifier *table_identifier) {
272  EventPtr event_ptr;
273  size_t zlen;
274  DynamicBuffer zbuf(0);
275  size_t len;
276  uint8_t *base;
277  SerializedKey key;
278  StaticBuffer send_buf;
279 
280  if (m_buffer.fill() > 0) {
281  BlockHeaderCellStore header(BLOCK_HEADER_FORMAT, DATA_BLOCK_MAGIC);
282 
284 
285  m_uncompressed_data += (float)m_buffer.fill();
286  m_compressor->deflate(m_buffer, zbuf, header);
287  m_compressed_data += (float)zbuf.fill();
288 
289  zlen = zbuf.fill();
290  send_buf = zbuf;
291 
292  if (m_outstanding_appends >= MAX_APPENDS_OUTSTANDING) {
293  if (!m_sync_handler.wait_for_reply(event_ptr))
295  "Problem finalizing CellStore file '%s' : %s",
296  m_filename.c_str(),
297  Protocol::string_format_message(event_ptr).c_str());
299  }
300 
302 
304  m_offset += zlen;
305  }
306 
307  m_buffer.free();
308 
310  if (m_uncompressed_data == 0)
312  else
314  m_trailer.version = 0;
315 
319  base = m_fix_index_buffer.release(&len);
322  delete [] base;
323  base = m_var_index_buffer.release(&len);
326  delete [] base;
327 
331  {
332  BlockHeaderCellStore header(BLOCK_HEADER_FORMAT, INDEX_FIXED_BLOCK_MAGIC);
333  m_compressor->deflate(m_fix_index_buffer, zbuf, header);
334  }
335 
336  zlen = zbuf.fill();
337  send_buf = zbuf;
338 
340 
342  m_offset += zlen;
343 
347  {
348  BlockHeaderCellStore header(BLOCK_HEADER_FORMAT, INDEX_VARIABLE_BLOCK_MAGIC);
350  m_compressor->deflate(m_var_index_buffer, zbuf, header);
351  }
352 
353  zlen = zbuf.fill();
354  send_buf = zbuf;
355 
357 
359  m_offset += zlen;
360 
361  // write filter_offset
363 
364  // if bloom_items haven't been spilled to create a bloom filter yet, do it
366  if (m_bloom_filter_items) {
367  m_trailer.num_filter_items = m_bloom_filter_items->size();
369  }
370  assert(!m_bloom_filter_items && m_bloom_filter);
371 
372  m_bloom_filter->serialize(send_buf);
374 
377  }
378 
382 
383  // deallocate fix index data
384  delete [] m_fix_index_buffer.release();
385 
386  // Add table information
387  m_trailer.table_id = table_identifier->index();
388  m_trailer.table_generation = table_identifier->generation;
389 
390  // write trailer
391  zbuf.clear();
392  zbuf.reserve(m_trailer.size());
393  m_trailer.serialize(zbuf.ptr);
394  zbuf.ptr += m_trailer.size();
395 
396  zlen = zbuf.fill();
397  send_buf = zbuf;
398 
399  m_filesys->append(m_fd, send_buf);
400 
402  m_offset += zlen;
403 
405  m_filesys->close(m_fd);
406 
409 
411  m_fd = m_filesys->open(m_filename, 0);
412 
413  m_disk_usage = (uint32_t)m_file_length;
414  if (m_disk_usage < 0)
415  HT_WARN_OUT << "[Issue 339] Disk usage for " << m_filename << "=" << m_disk_usage
416  << HT_END;
417 
419  if (m_bloom_filter)
422 
423  delete m_compressor;
424  m_compressor = 0;
425 
426 }
427 
428 
429 void CellStoreV0::add_index_entry(const SerializedKey key, uint32_t offset) {
430 
431  size_t key_len = key.length();
432  m_var_index_buffer.ensure(key_len);
433  memcpy(m_var_index_buffer.ptr, key.ptr, key_len);
434  m_var_index_buffer.ptr += key_len;
435 
436  // Serialize offset into fix index buffer
437  m_fix_index_buffer.ensure(sizeof(offset));
438  memcpy(m_fix_index_buffer.ptr, &offset, sizeof(offset));
439  m_fix_index_buffer.ptr += sizeof(offset);
440 
442 }
443 
444 
445 void
446 CellStoreV0::open(const String &fname, const String &start_row,
447  const String &end_row, int32_t fd, int64_t file_length,
448  CellStoreTrailer *trailer) {
449  m_filename = fname;
450  m_start_row = start_row;
451  m_end_row = end_row;
452  m_fd = fd;
453  m_file_length = file_length;
454 
455  CellStoreTrailerV0 *trailer_v0 = static_cast<CellStoreTrailerV0 *>(trailer);
456 
457  m_trailer = *trailer_v0;
458 
461 
465  "Bad index offsets in CellStore trailer fix=%u, var=%u, "
466  "length=%llu, file='%s'", m_trailer.fix_index_offset,
467  m_trailer.var_index_offset, (Llu)m_file_length, fname.c_str());
468 
469  load_index();
470 }
471 
472 
474  uint32_t amount, index_amount;
475  uint32_t len = 0;
476  BlockHeaderCellStore header(BLOCK_HEADER_FORMAT);
477  SerializedKey key;
478  bool inflating_fixed=true;
479  bool second_try = false;
480 
482 
483  amount = index_amount = m_trailer.filter_offset
485 
486  try_again:
487 
488  try {
489  DynamicBuffer buf(amount);
490 
492  len = m_filesys->pread(m_fd, buf.ptr, amount, m_trailer.fix_index_offset, second_try);
493 
494  if (len != amount)
495  HT_THROWF(Error::FSBROKER_IO_ERROR, "Error loading index for "
496  "CellStore '%s' : tried to read %d but only got %d",
497  m_filename.c_str(), amount, len);
500  m_compressor->inflate(buf, m_fix_index_buffer, header);
501 
502  inflating_fixed = false;
503 
506 
508  DynamicBuffer vbuf(0, false);
510  vbuf.base = buf.ptr;
511  vbuf.ptr = buf.ptr + amount;
512 
513  m_compressor->inflate(vbuf, m_var_index_buffer, header);
514 
517  }
518  catch (Exception &e) {
519  String msg;
520  if (inflating_fixed) {
521  msg = String("Error inflating FIXED index for cellstore '")
522  + m_filename + "'";
523  HT_ERROR_OUT << msg << ": "<< e << HT_END;
524  }
525  else {
526  msg = "Error inflating VARIABLE index for cellstore '" + m_filename + "'";
527  HT_ERROR_OUT << msg << ": " << e << HT_END;
528  }
529  HT_ERROR_OUT << "pread(fd=" << m_fd << ", len=" << len << ", amount="
530  << index_amount << ")\n" << HT_END;
532  if (second_try)
533  HT_THROW2(e.code(), e, msg);
534  second_try = true;
535  goto try_again;
536  }
537 
541 
542  // instantiate a bloom filter and read in the bloom filter bits.
543  // If num_filter_items in trailer is 0, means bloom_filter is disabled..
544  if (m_trailer.num_filter_items != 0) {
545  HT_DEBUG_OUT << "Creating new BloomFilter for CellStore '"
546  << m_filename <<"' with "<< m_trailer.num_filter_items
547  << " items"<< HT_END;
548  try {
551  }
552  catch (Exception &e) {
553  HT_FATAL_OUT << "Error loading BloomFilter for CellStore '"
554  << m_filename <<"' with "<< m_trailer.num_filter_items
555  << " items -"<< e << HT_END;
556  }
558 
559  while (true) {
560  try {
561  len = m_filesys->pread(m_fd, m_bloom_filter->ptr(), amount,
562  m_trailer.filter_offset, second_try);
563  }
564  catch (Exception &e) {
565  if (!second_try) {
566  second_try=true;
567  continue;
568  }
569  HT_THROW2(e.code(), e, format("Error loading BloomFilter for CellStore '%s'",
570  m_filename.c_str()));
571  }
572  break;
573  }
574 
575  if (len != amount) {
576  HT_THROWF(Error::FSBROKER_IO_ERROR, "Problem loading bloomfilter for"
577  "CellStore '%s' : tried to read %d but only got %d",
578  m_filename.c_str(), amount, len);
579 
580  }
581  } else {
583  }
584 
586  if (m_disk_usage < 0)
587  HT_WARN_OUT << "[Issue 339] Disk usage for " << m_filename << "=" << m_disk_usage
588  << HT_END;
589 
591  if (m_bloom_filter)
594 
595  delete m_compressor;
596  m_compressor = 0;
597  delete [] m_fix_index_buffer.release();
598 }
599 
600 
602  switch (m_bloom_filter_mode) {
603  case BLOOM_FILTER_ROWS:
604  return may_contain(scan_ctx->start_row);
606  if (may_contain(scan_ctx->start_row)) {
607  SchemaPtr &schema = scan_ctx->schema;
608  size_t rowlen = scan_ctx->start_row.length();
609  boost::scoped_array<char> rowcol(new char[rowlen + 2]);
610  memcpy(rowcol.get(), scan_ctx->start_row.c_str(), rowlen + 1);
611 
612  for (auto col : scan_ctx->spec->columns) {
613  uint8_t column_family_id = schema->get_column_family(col)->get_id();
614  rowcol[rowlen + 1] = column_family_id;
615 
616  if (may_contain(rowcol.get(), rowlen + 2))
617  return true;
618  }
619  }
620  return false;
622  return true;
623  default:
624  HT_ASSERT(!"unpossible bloom filter mode!");
625  }
626  return false; // silence stupid compilers
627 }
628 
629 
630 bool CellStoreV0::may_contain(const void *ptr, size_t len) {
631  assert(m_bloom_filter != 0);
632  bool may_contain = m_bloom_filter->may_contain(ptr, len);
633  return may_contain;
634 }
635 
636 
638  SerializedKey last_key;
639  uint32_t last_offset = 0;
640  uint32_t block_size;
641  size_t i=0;
643  iter != m_index_map32.end(); ++iter) {
644  if (last_key) {
645  block_size = iter.value() - last_offset;
646  cout << i << ": offset=" << last_offset << " size=" << block_size
647  << " row=" << last_key.row() << endl;
648  i++;
649  }
650  last_offset = iter.value();
651  last_key = iter.key();
652  }
653  if (last_key) {
654  block_size = m_trailer.filter_offset - last_offset;
655  cout << i << ": offset=" << last_offset << " size=" << block_size
656  << " row=" << last_key.row() << endl;
657  }
658 }
659 
660 
662  return BLOCK_HEADER_FORMAT;
663 }
void free()
Frees resources.
static const char INDEX_FIXED_BLOCK_MAGIC[10]
Definition: CellStore.h:326
#define HT_THROW2F(_code_, _ex_, _fmt_,...)
Definition: Error.h:494
A memory buffer of static size.
Definition: StaticBuffer.h:45
Retrieves system information (hardware, installation directory, etc)
virtual void append(int fd, StaticBuffer &buffer, Flags flags, DispatchHandler *handler)=0
Appends data to a file asynchronously.
Abstract base class for cell store trailer.
virtual void close(int fd, DispatchHandler *handler)=0
Closes a file asynchronously.
const char * row
Definition: Key.h:129
virtual void pread(int fd, size_t amount, uint64_t offset, bool verify_checksum, DispatchHandler *handler)=0
Reads data from a file at the specified position asynchronously.
static const char INDEX_VARIABLE_BLOCK_MAGIC[10]
Definition: CellStore.h:327
static int32_t response_code(const Event *event)
Returns the response code from an event event generated in response to a request message.
Definition: Protocol.cc:39
virtual void serialize(uint8_t *buf)
Serializes this trailer to the given buffer;.
uint32_t m_outstanding_appends
Definition: CellStoreV0.h:133
PropertiesPtr properties
This singleton map stores all options.
Definition: Config.cc:47
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
uint32_t length
Definition: Key.h:124
bool check_magic(const char *magic)
Compares a given character sequence with the magic field.
Definition: BlockHeader.h:86
const char * row() const
Definition: SerializedKey.h:53
static String string_format_message(const Event *event)
Returns error message decoded standard error MESSAGE generated in response to a request message...
Definition: Protocol.cc:51
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Definition: String.cc:37
std::string m_start_row
Definition: CellList.h:99
long long unsigned int Llu
Shortcut for printf formats.
Definition: String.h:50
BlockCompressionCodec * create_block_compression_codec() override
Creates a block compression codec suitable for decompressing the cell store's blocks.
Definition: CellStoreV0.cc:90
CellStoreV0(Filesystem *filesys)
Definition: CellStoreV0.cc:56
Declarations for CellStoreScanner.
static void parse_bloom_filter(const std::string &spec, PropertiesPtr &props)
Parsers a bloom filter specification and sets properties.
void add_index_entry(const SerializedKey key, uint32_t offset)
Definition: CellStoreV0.cc:429
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
uint32_t m_uncompressed_blocksize
Definition: CellStoreV0.h:141
STL namespace.
CellStoreBlockIndexArray< uint32_t > m_index_map32
Definition: CellStoreV0.h:125
Scan context information.
Definition: ScanContext.h:52
uint8_t * ptr()
Getter for the bloom filter data.
Definition: BloomFilter.h:226
DispatchHandlerSynchronizer m_sync_handler
Definition: CellStoreV0.h:132
std::string m_end_row
Definition: CellList.h:100
Type
Enumeration for compression type.
uint8_t * ptr
Pointer to the end of the used part of the buffer.
void add(const Key &key, uint8_t flag, const void *value, uint32_t value_len, TableMutatorAsync *value_index_mutator, TableMutatorAsync *qualifier_index_mutator)
Definition: IndexTables.cc:34
bool wait_for_reply(EventPtr &event)
This method is used by a client to synchronize.
void create(const char *fname, size_t max_entries, PropertiesPtr &props, const TableIdentifier *table_id=0) override
Creates a new cell store.
Definition: CellStoreV0.cc:102
A dynamic, resizable and reference counted memory buffer.
Definition: DynamicBuffer.h:42
Declarations for Schema.
A class managing one or more serializable ByteStrings.
Definition: ByteString.h:47
#define HT_ASSERT(_e_)
Definition: Logger.h:396
bool may_contain(const void *ptr, size_t len)
Definition: CellStoreV0.cc:630
uint32_t row_len
Definition: Key.h:131
static BlockCompressionCodec::Type parse_block_codec_spec(const std::string &spec, BlockCompressionCodec::Args &args)
Given a block codec config string return its type and put config.
static Hypertable::MemoryTracker * memory_tracker
Definition: Global.h:94
BloomFilterItems * m_bloom_filter_items
Definition: CellStoreV0.h:147
virtual size_t size()
Returns the serialized size of the trailer.
CellStoreTrailerV0 m_trailer
Definition: CellStoreV0.h:126
const ScanSpec * spec
Definition: ScanContext.h:55
size_t size()
Getter for the bloom filter size.
Definition: BloomFilter.h:232
Filesystem * m_filesys
Definition: CellStoreV0.h:121
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
Logging routines and macros.
BloomFilterMode
Enumeration for bloom filter modes.
virtual void clear()
Clears the contents of this trailer;.
Compatibility Macros for C/C++.
BasicBloomFilter BloomFilter
Definition: BloomFilter.h:284
void display_block_info() override
Displays block information to stdout.
Definition: CellStoreV0.cc:637
#define HT_END
Definition: Logger.h:220
size_t length() const
Retrieves the length of the serialized string.
Definition: ByteString.h:62
BlockCompressionCodec::Args m_compressor_args
Definition: CellStoreV0.h:142
static BlockCompressionCodec * create_block_codec(BlockCompressionCodec::Type, const BlockCompressionCodec::Args &args=BlockCompressionCodec::Args())
#define HT_ERROR_OUT
Definition: Logger.h:301
bool may_contain(const void *key, size_t len) const
Checks if the data set "may" contain the key.
Definition: BloomFilter.h:188
#define HT_WARN_OUT
Definition: Logger.h:291
const uint8_t * ptr
The pointer to the serialized data.
Definition: ByteString.h:121
Hypertable definitions
SerializedKey serial
Definition: Key.h:123
void load(DynamicBuffer &fixed, DynamicBuffer &variable, int64_t end_of_data, const String &start_row="", const String &end_row="")
void clear()
Clears the buffer.
Declarations for BlockHeaderCellStore.
BloomFilterMode m_bloom_filter_mode
Definition: CellStoreV0.h:145
void finalize(TableIdentifier *table_identifier) override
Finalizes the creation of a cell store, by writing block index and metadata trailer.
Definition: CellStoreV0.cc:271
BlockCompressionCodec * m_compressor
Definition: CellStoreV0.h:127
uint16_t block_header_format() override
Definition: CellStoreV0.cc:661
Declarations for Protocol.
#define HT_THROWF(_code_, _fmt_,...)
Definition: Error.h:490
Provides access to internal components of opaque key.
Definition: Key.h:40
void open(const String &fname, const String &start_row, const String &end_row, int32_t fd, int64_t file_length, CellStoreTrailer *trailer) override
Opens a cell store with possibly a restricted view.
Definition: CellStoreV0.cc:446
uint8_t * base
Pointer to the allocated memory buffer.
size_t fill() const
Returns the size of the used portion.
Definition: DynamicBuffer.h:70
virtual void deflate(const DynamicBuffer &input, DynamicBuffer &output, BlockHeader &header, size_t reserve=0)=0
Compresses a buffer.
static const char DATA_BLOCK_MAGIC[10]
Definition: CellStore.h:325
Request/response message event.
Definition: Event.h:63
void subtract(int64_t amount)
Subtract to memory used.
Definition: MemoryTracker.h:60
CellListScannerPtr create_scanner(ScanContext *scan_ctx) override
Creates a scanner on this cell list.
Definition: CellStoreV0.cc:96
void serialize(StaticBuffer &buf)
Serializes the BloomFilter into a static memory buffer.
Definition: BloomFilter.h:218
This is a generic exception class for Hypertable.
Definition: Error.h:314
void create_bloom_filter(bool is_approx=false)
Definition: CellStoreV0.cc:165
int64_t revision
Definition: Key.h:135
BloomFilter * m_bloom_filter
Definition: CellStoreV0.h:146
DynamicBuffer m_fix_index_buffer
Definition: CellStoreV0.h:129
uint8_t * release(size_t *lenp=0)
Moves ownership of the buffer to the caller.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
std::shared_ptr< CellListScanner > CellListScannerPtr
Definition: CellList.h:35
void insert(const void *key, size_t len)
Inserts a new blob into the hash.
Definition: BloomFilter.h:159
DynamicBuffer m_var_index_buffer
Definition: CellStoreV0.h:130
virtual void open(const String &name, uint32_t flags, DispatchHandler *handler)=0
Opens a file asynchronously.
DynamicBuffer m_buffer
Definition: CellStoreV0.h:128
A space-efficent probabilistic set for membership test, false postives are possible, but false negatives are not.
Definition: BloomFilter.h:50
virtual void inflate(const DynamicBuffer &input, DynamicBuffer &output, BlockHeader &header)=0
Decompresses a buffer.
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
Definition: Error.h:478
static const char * END_ROW_MARKER
Definition: Key.h:49
#define HT_FATAL_OUT
Definition: Logger.h:347
void add(int64_t amount)
Add to memory used.
Definition: MemoryTracker.h:53
void ensure(size_t len)
Ensure space for additional data Will grow the space to 1.5 of the needed space with existing data un...
Definition: DynamicBuffer.h:82
uint8_t * add_unchecked(const void *data, size_t len)
Adds additional data without boundary checks.
virtual void create(const String &name, uint32_t flags, int32_t bufsz, int32_t replication, int64_t blksz, DispatchHandler *handler)=0
Creates a file asynchronously.
BlobHashSet BloomFilterItems
Definition: CellStoreV0.h:119
#define HT_DEBUG_OUT
Definition: Logger.h:261
Abstract base class for block compression codecs.
Abstract base class for a filesystem.
Definition: Filesystem.h:72
int code() const
Returns the error code.
Definition: Error.h:391
void reserve(size_t len, bool nocopy=false)
Reserve space for additional data Will grow the space to exactly what's needed.
Definition: DynamicBuffer.h:95
#define HT_THROW2(_code_, _ex_, _msg_)
Definition: Error.h:484