/** * Converts a byte array to a BigDecimal * * @param bytes * @return the char value */ public static BigDecimal toBigDecimal(byte[] bytes) { return toBigDecimal(bytes, 0, bytes.length); }
@Override public int compareTo(byte[] value, int offset, int length) { BigDecimal that = Bytes.toBigDecimal(value, offset, length); return this.bigDecimal.compareTo(that); }
@Override public BigDecimal getCellValueFromProto(BigDecimalMsg q) { return Bytes.toBigDecimal(q.getBigdecimalMsg().toByteArray()); } }
@Override public BigDecimal getPromotedValueFromProto(BigDecimalMsg r) { return Bytes.toBigDecimal(r.getBigdecimalMsg().toByteArray()); }
public void testToBigDecimal() throws Exception { BigDecimal [] decimals = {new BigDecimal("-1"), new BigDecimal("123.123"), new BigDecimal("123123123123")}; for (int i = 0; i < decimals.length; i++) { byte [] b = Bytes.toBytes(decimals[i]); assertEquals(decimals[i], Bytes.toBigDecimal(b)); byte [] b2 = bytesWithOffset(b); assertEquals(decimals[i], Bytes.toBigDecimal(b2, 1, b.length)); } }
return new Time(Bytes.toLong(value)); case 12: return Bytes.toBigDecimal(value); case 13: return new BigInteger(value);
res = bytes; } else if (type == Type.BIGDECIMAL) { res = Bytes.toBigDecimal(bytes); } else { throw new IllegalArgumentException("mismatch class type");
res = bytes[0]; } else if (BigDecimal.class == clazz) { res = Bytes.toBigDecimal(bytes); } else if (BigInteger.class == clazz) { res = Bytes.toLong(bytes);
/** * Converts the value bytes of the given cell into a BigDecimal * @param cell * @return value as BigDecimal */ public static BigDecimal getValueAsBigDecimal(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toBigDecimal(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition(), cell.getValueLength()); } return Bytes.toBigDecimal(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); }
/** * @param pbBytes A pb serialized {@link BigDecimalComparator} instance * @return An instance of {@link BigDecimalComparator} made from <code>bytes</code> * @throws DeserializationException A deserialization exception * @see #toByteArray */ public static BigDecimalComparator parseFrom(final byte[] pbBytes) throws DeserializationException { ComparatorProtos.BigDecimalComparator proto; try { proto = ComparatorProtos.BigDecimalComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new BigDecimalComparator(Bytes.toBigDecimal(proto.getComparable().getValue() .toByteArray())); }
@Override public int compareTo(byte[] value, int offset, int length) { BigDecimal that = Bytes.toBigDecimal(value, offset, length); return this.bigDecimal.compareTo(that); }
@Override public BigDecimal getCellValueFromProto(BigDecimalMsg q) { return Bytes.toBigDecimal(q.getBigdecimalMsg().toByteArray()); } }
@Override public BigDecimal getPromotedValueFromProto(BigDecimalMsg r) { return Bytes.toBigDecimal(r.getBigdecimalMsg().toByteArray()); }
return Bytes.toBigDecimal(b);
return Bytes.toBigDecimal(b);
/** * @param pbBytes A pb serialized {@link BigDecimalComparator} instance * @return An instance of {@link BigDecimalComparator} made from <code>bytes</code> * @throws DeserializationException A deserialization exception * @see #toByteArray */ public static BigDecimalComparator parseFrom(final byte[] pbBytes) throws DeserializationException { ComparatorProtos.BigDecimalComparator proto; try { proto = ComparatorProtos.BigDecimalComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new BigDecimalComparator(Bytes.toBigDecimal(proto.getComparable().getValue() .toByteArray())); }
/** * Converts a byte array to a BigDecimal * * @param bytes * @return the char value */ public static BigDecimal toBigDecimal(byte[] bytes) { return toBigDecimal(bytes, 0, bytes.length); }
@Override public BigDecimal getCellValueFromProto(BigDecimalMsg q) { return Bytes.toBigDecimal(q.getBigdecimalMsg().toByteArray()); } }
public void testToBigDecimal() throws Exception { BigDecimal [] decimals = {new BigDecimal("-1"), new BigDecimal("123.123"), new BigDecimal("123123123123")}; for (int i = 0; i < decimals.length; i++) { byte [] b = Bytes.toBytes(decimals[i]); assertEquals(decimals[i], Bytes.toBigDecimal(b)); byte [] b2 = bytesWithOffset(b); assertEquals(decimals[i], Bytes.toBigDecimal(b2, 1, b.length)); } }
/** * Converts the value bytes of the given cell into a BigDecimal * @param cell * @return value as BigDecimal */ public static BigDecimal getValueAsBigDecimal(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toBigDecimal(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition(), cell.getValueLength()); } return Bytes.toBigDecimal(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); }