@Override public byte[] toBytes(Object object) { byte[] b = new byte[Bytes.SIZEOF_INT]; toBytes(object, b, 0); return b; }
private PUnsignedIntArray() { super("UNSIGNED_INT ARRAY", PDataType.ARRAY_TYPE_BASE + PUnsignedInt.INSTANCE.getSqlType(), PhoenixArray.class, null, 43); }
@Override public boolean isCoercibleTo(PDataType targetType) { return targetType.equals(this) || PUnsignedInt.INSTANCE.isCoercibleTo(targetType) || PSmallint.INSTANCE .isCoercibleTo(targetType); }
@Override public int toBytes(Object object, byte[] b, int o) { if (object == null) { throw newIllegalDataException(this + " may not be null"); } return this.getCodec().encodeInt(((Number) object).intValue(), b, o); }
@Override public int getNanos(ImmutableBytesWritable ptr, SortOrder sortOrder) { int nanos = PUnsignedInt.INSTANCE.getCodec() .decodeInt(ptr.get(), ptr.getOffset() + PLong.INSTANCE.getByteSize(), sortOrder); return nanos; }
int size = PVarchar.INSTANCE.estimateByteSizeFromLength(chrom.length()) + QueryConstants.SEPARATOR_BYTE_ARRAY.length + PUnsignedInt.INSTANCE.getByteSize() + PVarchar.INSTANCE.estimateByteSizeFromLength(ref.length()); alt = buildSVAlternate(alt, end, sv); offset += PVarchar.INSTANCE.toBytes(chrom, rk, offset); rk[offset++] = QueryConstants.SEPARATOR_BYTE; offset += PUnsignedInt.INSTANCE.toBytes(start, rk, offset);
@Override public Object toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { Integer v = (Integer) PInteger.INSTANCE.toObject(b, o, l, actualType, sortOrder); throwIfNonNegativeNumber(v); return v; }
public static Variant extractVariantFromVariantRowKey(byte[] variantRowKey) { int chrPosSeparator = ArrayUtils.indexOf(variantRowKey, (byte) 0); String chromosome = (String) PVarchar.INSTANCE.toObject(variantRowKey, 0, chrPosSeparator, PVarchar.INSTANCE); Integer intSize = PUnsignedInt.INSTANCE.getByteSize(); int position = (Integer) PUnsignedInt.INSTANCE.toObject(variantRowKey, chrPosSeparator + 1, intSize, PUnsignedInt.INSTANCE); int referenceOffset = chrPosSeparator + 1 + intSize; int refAltSeparator = ArrayUtils.indexOf(variantRowKey, (byte) 0, referenceOffset); String reference; String alternate; if (refAltSeparator < 0) { reference = (String) PVarchar.INSTANCE.toObject(variantRowKey, referenceOffset, variantRowKey.length - referenceOffset, PVarchar.INSTANCE); alternate = ""; } else { reference = (String) PVarchar.INSTANCE.toObject(variantRowKey, referenceOffset, refAltSeparator - referenceOffset, PVarchar.INSTANCE); alternate = (String) PVarchar.INSTANCE.toObject(variantRowKey, refAltSeparator + 1, variantRowKey.length - (refAltSeparator + 1), PVarchar.INSTANCE); } try { return buildVariant(chromosome, position, reference, alternate, null); } catch (RuntimeException e) { throw new IllegalStateException("Fail to parse variant: " + chromosome + ':' + position + ':' + (reference == null ? "-" : reference) + ':' + (alternate == null ? "-" : alternate) + " from RowKey: " + Bytes.toStringBinary(variantRowKey), e); } }
@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } try { Integer i = Integer.parseInt(value); if (i.intValue() < 0) { throw newIllegalDataException("Value may not be negative(" + i + ")"); } return i; } catch (NumberFormatException e) { throw newIllegalDataException(e); } }
os.println("\t" + key + " = " + length(entry.getValue()) + ", " + PFloatArray.INSTANCE.toObject(entry.getValue())); } else if (key.endsWith(VariantPhoenixHelper.STUDY_SUFIX)) { os.println("\t" + key + " = " + PUnsignedInt.INSTANCE.toObject(entry.getValue())); } else if (key.endsWith(VariantPhoenixHelper.SAMPLE_DATA_SUFIX) || key.endsWith(VariantPhoenixHelper.FILE_SUFIX)) { os.println("\t" + key + " = " + result.getColumnLatestCell(genomeHelper.getColumnFamily(), entry.getKey()).getTimestamp()+", " + PVarcharArray.INSTANCE.toObject(entry.getValue())); Object o = null; try { o = PUnsignedInt.INSTANCE.toObject(entry.getValue()); } catch (IllegalDataException ignore) {
@Override public int getNanos(ImmutableBytesWritable ptr, SortOrder sortOrder) { int nanos = PUnsignedInt.INSTANCE.getCodec() .decodeInt(ptr.get(), ptr.getOffset() + PLong.INSTANCE.getByteSize(), sortOrder); return nanos; }
@Override public int toBytes(Object object, byte[] b, int o) { if (object == null) { throw newIllegalDataException(this + " may not be null"); } return this.getCodec().encodeInt(((Number) object).intValue(), b, o); }
@Override public Object toObject(Object object, PDataType actualType) { Integer v = (Integer) PInteger.INSTANCE.toObject(object, actualType); throwIfNonNegativeNumber(v); return v; }
@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } try { Integer i = Integer.parseInt(value); if (i.intValue() < 0) { throw newIllegalDataException("Value may not be negative(" + i + ")"); } return i; } catch (NumberFormatException e) { throw newIllegalDataException(e); } }
private void assertTable(String tableName1,List<Cell> keyValues1,String tableName2,List<Cell> keyValues2) { assertTrue("MUTATION_TEST1".equals(tableName1)); assertTrue(Bytes.equals(PUnsignedInt.INSTANCE.toBytes(111),CellUtil.cloneRow(keyValues1.get(0)))); assertTrue("app1".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues1.get(1))))); assertTrue("MUTATION_TEST2".equals(tableName2)); assertTrue(Bytes.equals(PUnsignedInt.INSTANCE.toBytes(222),CellUtil.cloneRow(keyValues2.get(0)))); assertTrue("app2".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues2.get(1))))); }
v = new java.sql.Timestamp(millisDeserialized); int nanosDeserialized = PUnsignedInt.INSTANCE.getCodec().decodeInt(b, o + Bytes.SIZEOF_LONG, sortOrder);
@Override public int toBytes(Object object, byte[] b, int o) { if (object == null) { throw newIllegalDataException(this + " may not be null"); } return this.getCodec().encodeInt(((Number) object).intValue(), b, o); }
private PUnsignedIntArray() { super("UNSIGNED_INT ARRAY", PDataType.ARRAY_TYPE_BASE + PUnsignedInt.INSTANCE.getSqlType(), PhoenixArray.class, null, 43); }
@Override public boolean isCoercibleTo(PDataType targetType) { return targetType.equals(this) || PUnsignedInt.INSTANCE.isCoercibleTo(targetType) || PSmallint.INSTANCE .isCoercibleTo(targetType); }