0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Cell.h
Go to the documentation of this file.
1 /* -*- c++ -*-
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 #ifndef HYPERTABLE_CELL_H
23 #define HYPERTABLE_CELL_H
24 
25 #include <iosfwd>
26 #include "Common/Error.h"
27 #include "Key.h"
28 
29 namespace Hypertable {
30 
32  class Cell {
33  public:
36  flag(FLAG_INSERT) { }
37 
38  Cell(const char *rk, const char *cf, const char *cq, uint64_t ts,
39  uint64_t rev, uint8_t *val, uint32_t vlen, uint8_t flag)
40  : row_key(rk), column_family(cf), column_qualifier(cq), timestamp(ts),
41  revision(rev), value(val), value_len(vlen), flag(flag) { }
42 
43  void sanity_check() const {
44  if (!row_key || !*row_key)
45  HT_THROW(Error::BAD_KEY, "Invalid row key - cannot be zero length");
46 
47  if (row_key[0] == (char)0xff && row_key[1] == (char)0xff)
48  HT_THROW(Error::BAD_KEY, "Invalid row key - cannot start with "
49  "character sequence 0xff 0xff");
50 
51  if (flag > FLAG_DELETE_ROW && flag < FLAG_INSERT) {
52  if (column_family == 0)
53  HT_THROWF(Error::BAD_KEY, "Flag is set to %d but column family is null", flag);
56  HT_THROWF(Error::BAD_KEY, "Flag is set to %d but timestamp is AUTO_ASSIGN", flag);
57  }
58  }
59 
62  "Invalid timestamp %lld (reserved for Hypertable use)",
64  }
65 
66  const char *row_key;
67  const char *column_family;
68  const char *column_qualifier;
69  int64_t timestamp;
70  uint64_t revision;
71  const uint8_t *value;
72  uint32_t value_len;
73  uint8_t flag;
74  };
75 
76  std::ostream &operator<<(std::ostream &, const Cell &);
77 
78 } // namespace Hypertable
79 
80 #endif // HYPERTABLE_CELL_H
static const uint32_t FLAG_DELETE_ROW
Definition: KeySpec.h:40
static const uint32_t FLAG_INSERT
Definition: KeySpec.h:47
const char * column_qualifier
Definition: Cell.h:68
static const uint32_t FLAG_DELETE_COLUMN_FAMILY
Definition: KeySpec.h:41
Cell(const char *rk, const char *cf, const char *cq, uint64_t ts, uint64_t rev, uint8_t *val, uint32_t vlen, uint8_t flag)
Definition: Cell.h:38
uint64_t revision
Definition: Cell.h:70
std::ostream & operator<<(std::ostream &os, const crontab_entry &entry)
Helper function to write crontab_entry to an ostream.
Definition: Crontab.cc:301
const char * row_key
Definition: Cell.h:66
static const int64_t TIMESTAMP_NULL
Definition: KeySpec.h:36
Hypertable definitions
void sanity_check() const
Definition: Cell.h:43
long long int Lld
Shortcut for printf formats.
Definition: String.h:53
const char * column_family
Definition: Cell.h:67
#define HT_THROWF(_code_, _fmt_,...)
Definition: Error.h:490
uint32_t value_len
Definition: Cell.h:72
static const int64_t AUTO_ASSIGN
Definition: KeySpec.h:38
uint8_t flag
Definition: Cell.h:73
Encapsulates decomposed key and value.
Definition: Cell.h:32
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
Definition: Error.h:478
static const uint32_t FLAG_DELETE_CELL_VERSION
Definition: KeySpec.h:43
const uint8_t * value
Definition: Cell.h:71
int64_t timestamp
Definition: Cell.h:69