1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.types;
19
20 import org.apache.hadoop.hbase.classification.InterfaceAudience;
21 import org.apache.hadoop.hbase.classification.InterfaceStability;
22 import org.apache.hadoop.hbase.util.Bytes;
23 import org.apache.hadoop.hbase.util.Order;
24 import org.apache.hadoop.hbase.util.PositionedByteRange;
25
26
27
28
29
30
31
32 @InterfaceAudience.Public
33 @InterfaceStability.Evolving
34 public class RawByte implements DataType<Byte> {
35
36 @Override
37 public boolean isOrderPreserving() { return false; }
38
39 @Override
40 public Order getOrder() { return null; }
41
42 @Override
43 public boolean isNullable() { return false; }
44
45 @Override
46 public boolean isSkippable() { return true; }
47
48 @Override
49 public int encodedLength(Byte val) { return Bytes.SIZEOF_BYTE; }
50
51 @Override
52 public Class<Byte> encodedClass() { return Byte.class; }
53
54 @Override
55 public int skip(PositionedByteRange src) {
56 src.setPosition(src.getPosition() + Bytes.SIZEOF_BYTE);
57 return Bytes.SIZEOF_BYTE;
58 }
59
60 @Override
61 public Byte decode(PositionedByteRange src) {
62 byte val = src.getBytes()[src.getOffset() + src.getPosition()];
63 skip(src);
64 return val;
65 }
66
67 @Override
68 public int encode(PositionedByteRange dst, Byte val) {
69 Bytes.putByte(dst.getBytes(), dst.getOffset() + dst.getPosition(), val);
70 return skip(dst);
71 }
72
73
74
75
76 public byte decodeByte(byte[] buff, int offset) {
77 return buff[offset];
78 }
79
80
81
82
83 public int encodeByte(byte[] buff, int offset, byte val) {
84 return Bytes.putByte(buff, offset, val);
85 }
86 }