1 /*
2 * Copyright 2011 The Apache Software Foundation
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21 package org.apache.hadoop.hbase.util;
22
23 import org.apache.hadoop.io.Writable;
24
25 /**
26 * Specifies methods needed to add elements to a Bloom filter and serialize the
27 * resulting Bloom filter as a sequence of bytes.
28 */
29 public interface BloomFilterWriter extends BloomFilterBase {
30
31 /** Allocate memory for the bloom filter data. */
32 void allocBloom();
33
34 /** Compact the Bloom filter before writing metadata & data to disk. */
35 void compactBloom();
36
37 /**
38 * Get a writable interface into bloom filter meta data.
39 *
40 * @return a writable instance that can be later written to a stream
41 */
42 Writable getMetaWriter();
43
44 /**
45 * Get a writable interface into bloom filter data (the actual Bloom bits).
46 * Not used for compound Bloom filters.
47 *
48 * @return a writable instance that can be later written to a stream
49 */
50 Writable getDataWriter();
51
52 /**
53 * Add the specified binary to the bloom filter.
54 *
55 * @param buf data to be added to the bloom
56 * @param offset offset into the data to be added
57 * @param len length of the data to be added
58 */
59 void add(byte[] buf, int offset, int len);
60
61 }