0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BlobHashTraits.h
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; either version 3
9  * of the 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 Hypertable. If not, see <http://www.gnu.org/licenses/>
18  */
19 
24 #ifndef HYPERTABLE_BLOB_HASH_TRAITS_H
25 #define HYPERTABLE_BLOB_HASH_TRAITS_H
26 
27 #include "PageArena.h"
28 #include "Common/MurmurHash.h"
29 
30 namespace Hypertable {
31 
39 struct Blob {
40  Blob(const void *buf, size_t len) : start(buf), size(len) { }
41 
42  const void *start;
43  size_t size;
44 };
45 
51 template <typename HashFunT = MurmurHash2>
54 
55  struct hasher {
56  HashFunT hash_fun;
57 
58  size_t operator()(const Blob &b) const {
59  return hash_fun(b.start, b.size);
60  }
61  };
62 
63  struct key_equal {
64  bool operator()(const Blob &x, const Blob &y) const {
65  if (x.size != y.size)
66  return false;
67 
68  return memcmp(x.start, y.start, x.size) == 0;
69  }
70  };
71 };
72 
75 } // namespace Hypertable
76 
77 #endif // !HYPERTABLE_BLOB_HASH_TRAITS_H
bool operator()(const Blob &x, const Blob &y) const
MurmurHash2 digest routine.
PageArena memory allocator.
Blob(const void *buf, size_t len)
A Blob structure holds a data pointer and a size.
size_t operator()(const Blob &b) const
const void * start
The PageArena allocator is simple and fast, avoiding individual mallocs/frees.
Definition: PageArena.h:69
Hypertable definitions
Traits for BlobHashSet Hash function default to MurmurHash2 for speed and mix.