2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org
.apache
.hadoop
.hbase
.spark
20 import org
.apache
.hadoop
.hbase
.util
.Bytes
23 * A wrapper class that will allow both columnFamily and qualifier to
24 * be the key of a hashMap. Also allow for finding the value in a hashmap
25 * with out cloning the HBase value from the HBase Cell object
26 * @param columnFamily ColumnFamily byte array
27 * @param columnFamilyOffSet Offset of columnFamily value in the array
28 * @param columnFamilyLength Length of the columnFamily value in the columnFamily array
29 * @param qualifier Qualifier byte array
30 * @param qualifierOffSet Offset of qualifier value in the array
31 * @param qualifierLength Length of the qualifier value with in the array
33 class ColumnFamilyQualifierMapKeyWrapper(val columnFamily
:Array
[Byte
],
34 val columnFamilyOffSet
:Int
,
35 val columnFamilyLength
:Int
,
36 val qualifier
:Array
[Byte
],
37 val qualifierOffSet
:Int
,
38 val qualifierLength
:Int
)
41 override def equals(other
:Any
): Boolean
= {
42 val otherWrapper
= other
.asInstanceOf
[ColumnFamilyQualifierMapKeyWrapper
]
44 Bytes
.compareTo(columnFamily
,
47 otherWrapper
.columnFamily
,
48 otherWrapper
.columnFamilyOffSet
,
49 otherWrapper
.columnFamilyLength
) == 0 && Bytes
.compareTo(qualifier
,
52 otherWrapper
.qualifier
,
53 otherWrapper
.qualifierOffSet
,
54 otherWrapper
.qualifierLength
) == 0
57 override def hashCode():Int
= {
58 Bytes
.hashCode(columnFamily
, columnFamilyOffSet
, columnFamilyLength
) +
59 Bytes
.hashCode(qualifier
, qualifierOffSet
, qualifierLength
)
62 def cloneColumnFamily():Array
[Byte
] = {
63 val resultArray
= new Array
[Byte
](columnFamilyLength
)
64 System
.arraycopy(columnFamily
, columnFamilyOffSet
, resultArray
, 0, columnFamilyLength
)
68 def cloneQualifier():Array
[Byte
] = {
69 val resultArray
= new Array
[Byte
](qualifierLength
)
70 System
.arraycopy(qualifier
, qualifierOffSet
, resultArray
, 0, qualifierLength
)