1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*
* Copyright © 2017 Endless Mobile, Inc.
*
* SPDX-License-Identifier: LGPL-2.0+
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <https://www.gnu.org/licenses/>.
*
* Authors:
* - Philip Withnall <withnall@endlessm.com>
*/
#pragma once
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
#include "libglnx.h"
G_BEGIN_DECLS
/**
* OstreeBloom:
*
* An implementation of a [bloom filter](https://en.wikipedia.org/wiki/Bloom_filter)
* which is suitable for building a filter and looking keys up in an existing
* filter.
*
* Since: 2017.8
*/
typedef struct _OstreeBloom OstreeBloom;
/**
* OstreeBloomHashFunc:
* @element: a pointer to the element to hash
* @k: hash function parameter
*
* Function prototype for a
* [universal hash function](https://en.wikipedia.org/wiki/Universal_hashing),
* parameterised on @k, which hashes @element to a #guint64 hash value.
*
* It is up to the implementer of the hash function whether %NULL is valid for
* @element.
*
* Since: 2017.8
*/
typedef guint64 (*OstreeBloomHashFunc) (gconstpointer element,
guint8 k);
#define OSTREE_TYPE_BLOOM (ostree_bloom_get_type ())
G_GNUC_INTERNAL
GType ostree_bloom_get_type (void);
G_GNUC_INTERNAL
OstreeBloom *ostree_bloom_new (gsize n_bytes,
guint8 k,
OstreeBloomHashFunc hash_func);
G_GNUC_INTERNAL
OstreeBloom *ostree_bloom_new_from_bytes (GBytes *bytes,
guint8 k,
OstreeBloomHashFunc hash_func);
G_GNUC_INTERNAL
OstreeBloom *ostree_bloom_ref (OstreeBloom *bloom);
G_GNUC_INTERNAL
void ostree_bloom_unref (OstreeBloom *bloom);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeBloom, ostree_bloom_unref)
G_GNUC_INTERNAL
gboolean ostree_bloom_maybe_contains (OstreeBloom *bloom,
gconstpointer element);
G_GNUC_INTERNAL
GBytes *ostree_bloom_seal (OstreeBloom *bloom);
G_GNUC_INTERNAL
void ostree_bloom_add_element (OstreeBloom *bloom,
gconstpointer element);
G_GNUC_INTERNAL
gsize ostree_bloom_get_size (OstreeBloom *bloom);
G_GNUC_INTERNAL
guint8 ostree_bloom_get_k (OstreeBloom *bloom);
G_GNUC_INTERNAL
OstreeBloomHashFunc ostree_bloom_get_hash_func (OstreeBloom *bloom);
G_GNUC_INTERNAL
guint64 ostree_str_bloom_hash (gconstpointer element,
guint8 k);
G_END_DECLS
|