Java Code Examples for org.apache.hadoop.hbase.util.Bytes#SIZEOF_LONG
The following examples show how to use
org.apache.hadoop.hbase.util.Bytes#SIZEOF_LONG .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiByteBuff.java From hbase with Apache License 2.0 | 6 votes |
/** * Writes a long to this MBB at its current position. Also advances the position by size of long * @param val Long value to write * @return this object */ @Override public MultiByteBuff putLong(long val) { checkRefCount(); if (this.curItem.remaining() >= Bytes.SIZEOF_LONG) { this.curItem.putLong(val); return this; } if (this.curItemIndex == this.items.length - 1) { throw new BufferOverflowException(); } // During read, we will read as byte by byte for this case. So just write in Big endian put(long7(val)); put(long6(val)); put(long5(val)); put(long4(val)); put(long3(val)); put(long2(val)); put(long1(val)); put(long0(val)); return this; }
Example 2
Source File: PDouble.java From phoenix with Apache License 2.0 | 6 votes |
@Override public double decodeDouble(byte[] bytes, int o, SortOrder sortOrder) { Preconditions.checkNotNull(sortOrder); checkForSufficientLength(bytes, o, Bytes.SIZEOF_LONG); long l; if (sortOrder == SortOrder.DESC) { // Copied from Bytes.toLong(), but without using the toLongUnsafe // TODO: would it be possible to use the toLongUnsafe? l = 0; for(int i = o; i < o + Bytes.SIZEOF_LONG; i++) { l <<= 8; l ^= (bytes[i] ^ 0xff) & 0xFF; } } else { l = Bytes.toLong(bytes, o); } l--; l ^= (~l >> Long.SIZE - 1) | Long.MIN_VALUE; return Double.longBitsToDouble(l); }
Example 3
Source File: PhTypeUtil.java From canal with Apache License 2.0 | 6 votes |
private static int encodeUnsignedDate(Object v, byte[] b, int o) { if (v instanceof Date) { encodeUnsignedLong(((Date) v).getTime(), b, 0); } else if (v instanceof String) { String dateStr = (String) v; Date date; try { date = Util.parseDate(dateStr); if (date != null) { encodeUnsignedLong(date.getTime(), b, 0); } } catch (Exception e) { throw new RuntimeException(e); } } return Bytes.SIZEOF_LONG; }
Example 4
Source File: PLong.java From phoenix with Apache License 2.0 | 6 votes |
@Override public long decodeLong(byte[] bytes, int o, SortOrder sortOrder) { Preconditions.checkNotNull(sortOrder); checkForSufficientLength(bytes, o, Bytes.SIZEOF_LONG); long v; byte b = bytes[o]; if (sortOrder == SortOrder.ASC) { v = b ^ 0x80; // Flip sign bit back for (int i = 1; i < Bytes.SIZEOF_LONG; i++) { b = bytes[o + i]; v = (v << 8) + (b & 0xff); } } else { b = (byte) (b ^ 0xff); v = b ^ 0x80; // Flip sign bit back for (int i = 1; i < Bytes.SIZEOF_LONG; i++) { b = bytes[o + i]; b ^= 0xff; v = (v << 8) + (b & 0xff); } } return v; }
Example 5
Source File: PhTypeUtil.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private static long decodeLong(byte[] bytes, int o) { checkForSufficientLength(bytes, o, Bytes.SIZEOF_LONG); long v; byte b = bytes[o]; v = b ^ 0x80; // Flip sign bit back for (int i = 1; i < Bytes.SIZEOF_LONG; i++) { b = bytes[o + i]; v = (v << 8) + (b & 0xff); } return v; }
Example 6
Source File: ValueBitSet.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @return Max serialization size */ public int getEstimatedLength() { if (schema == null) { return 0; } return Bytes.SIZEOF_SHORT + (isVarLength() ? (maxSetBit + BITS_PER_LONG - 1) / BITS_PER_LONG * Bytes.SIZEOF_LONG : 0); }
Example 7
Source File: PhTypeUtil.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private static int encodeUnsignedLong(long v, byte[] b, int o) { checkForSufficientLength(b, o, Bytes.SIZEOF_LONG); if (v < 0) { throw new RuntimeException(); } Bytes.putLong(b, o, v); return Bytes.SIZEOF_LONG; }
Example 8
Source File: DynamicPositionedMutableByteRange.java From hgraphdb with Apache License 2.0 | 5 votes |
@Override public PositionedByteRange putLong(int index, long val) { // This writing is same as BB's putLong. When byte[] is wrapped in a BB and // call putLong(), one // can get the same result. for (int i = Bytes.SIZEOF_LONG - 1; i > 0; i--) { bytes[offset + index + i] = (byte) val; val >>>= 8; } bytes[offset + index] = (byte) val; clearHashCache(); return this; }
Example 9
Source File: PhTypeUtil.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private static int encodeUnsignedTimestamp(Object v, byte[] b, int o) { if (v instanceof Timestamp) { Timestamp ts = (Timestamp) v; encodeUnsignedLong(ts.getTime(), b, o); Bytes.putInt(b, Bytes.SIZEOF_LONG, ts.getNanos() % 1000000); } else { encodeUnsignedDate(v, b, o); } return Bytes.SIZEOF_LONG + Bytes.SIZEOF_INT; }
Example 10
Source File: BitSet.java From phoenix with Apache License 2.0 | 5 votes |
public static int getByteSize(int capacity) { if (capacity <= BitSet.BITS_PER_BYTE) { return Bytes.SIZEOF_BYTE; } else if (capacity <= BitSet.BITS_PER_SHORT) { return Bytes.SIZEOF_SHORT; } else if (capacity <= BitSet.BITS_PER_INT) { return Bytes.SIZEOF_INT; } else if (capacity <= BitSet.BITS_PER_LONG) { return Bytes.SIZEOF_LONG; } else { int nLongs = (capacity-1) / BitSet.BITS_PER_LONG + 1; return nLongs * Bytes.SIZEOF_LONG; } }
Example 11
Source File: PUnsignedTime.java From phoenix with Apache License 2.0 | 4 votes |
@Override public Integer getByteSize() { return Bytes.SIZEOF_LONG; }
Example 12
Source File: PUnsignedLong.java From phoenix with Apache License 2.0 | 4 votes |
@Override public Integer getByteSize() { return Bytes.SIZEOF_LONG; }
Example 13
Source File: PUnsignedTime.java From phoenix with Apache License 2.0 | 4 votes |
@Override public Integer getByteSize() { return Bytes.SIZEOF_LONG; }
Example 14
Source File: RawLong.java From hbase with Apache License 2.0 | 4 votes |
@Override public int skip(PositionedByteRange src) { src.setPosition(src.getPosition() + Bytes.SIZEOF_LONG); return Bytes.SIZEOF_LONG; }
Example 15
Source File: PUnsignedLong.java From phoenix with Apache License 2.0 | 4 votes |
@Override public byte[] toBytes(Object object) { byte[] b = new byte[Bytes.SIZEOF_LONG]; toBytes(object, b, 0); return b; }
Example 16
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 4 votes |
private byte[] getEmptyRegionFromKey(byte[] key) { int prefixLen = EMPTY_REGION_TIME_KEY_PREFIX.length + Bytes.SIZEOF_LONG; return Bytes.copy(key, prefixLen, key.length - prefixLen); }
Example 17
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 4 votes |
private byte[] getEmptyRegionFromKey(byte[] key) { int prefixLen = EMPTY_REGION_TIME_KEY_PREFIX.length + Bytes.SIZEOF_LONG; return Bytes.copy(key, prefixLen, key.length - prefixLen); }
Example 18
Source File: PTime.java From phoenix with Apache License 2.0 | 4 votes |
@Override public Integer getByteSize() { return Bytes.SIZEOF_LONG; }
Example 19
Source File: PDate.java From phoenix with Apache License 2.0 | 4 votes |
@Override public Integer getByteSize() { return Bytes.SIZEOF_LONG; }
Example 20
Source File: PUnsignedLong.java From phoenix with Apache License 2.0 | 4 votes |
@Override public byte[] toBytes(Object object) { byte[] b = new byte[Bytes.SIZEOF_LONG]; toBytes(object, b, 0); return b; }