HBASE-21843 RegionGroupingProvider breaks the meta wal file name pattern which may...
[hbase.git] / hbase-server / src / main / java / org / apache / hadoop / hbase / util / RowPrefixFixedLengthBloomContext.java
blob5abbf1c159c7627574fe7db061c182d087aeb3dc
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.util;
20 import java.io.IOException;
22 import org.apache.hadoop.hbase.Cell;
23 import org.apache.hadoop.hbase.CellBuilderType;
24 import org.apache.hadoop.hbase.CellComparator;
25 import org.apache.hadoop.hbase.CellUtil;
26 import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
27 import org.apache.yetus.audience.InterfaceAudience;
29 /**
30 * Handles ROWPREFIX bloom related context.
31 * It works with both ByteBufferedCell and byte[] backed cells
33 @InterfaceAudience.Private
34 public class RowPrefixFixedLengthBloomContext extends RowBloomContext {
35 private final int prefixLength;
37 public RowPrefixFixedLengthBloomContext(BloomFilterWriter bloomFilterWriter,
38 CellComparator comparator, int prefixLength) {
39 super(bloomFilterWriter, comparator);
40 this.prefixLength = prefixLength;
43 public void writeBloom(Cell cell) throws IOException {
44 super.writeBloom(getRowPrefixCell(cell));
47 /**
48 * @param cell the cell
49 * @return the new cell created by row prefix
51 private Cell getRowPrefixCell(Cell cell) {
52 byte[] row = CellUtil.copyRow(cell);
53 return ExtendedCellBuilderFactory.create(CellBuilderType.DEEP_COPY)
54 .setRow(row, 0, Math.min(prefixLength, row.length))
55 .setType(Cell.Type.Put)
56 .build();