@Test public void testToDecimal() { class DecimalData { private String str; private int precision, scale; private DecimalData(String str, int precision, int scale) { this.str = str; this.precision = precision; this.scale = scale; } } DecimalData[] data = { new DecimalData("12.345", 5, 3), new DecimalData("-12.345", 5, 3), new DecimalData("+12345", 5, 0), new DecimalData("-12345", 5, 0), new DecimalData("12345.", 5, 0), new DecimalData("-12345.", 5, 0), new DecimalData(".12345", 5, 5), new DecimalData("-.12345", 5, 5), new DecimalData("+12.345E3", 5, 0), new DecimalData("-12.345e3", 5, 0), new DecimalData("12.345e-3", 6, 6), new DecimalData("-12.345E-3", 6, 6), new DecimalData("12345E3", 8, 0), new DecimalData("-12345e3", 8, 0), new DecimalData("12345e-3", 5, 3), new DecimalData("-12345E-3", 5, 3), new DecimalData("+.12345E3", 5, 2), new DecimalData("-.12345e3", 5, 2), new DecimalData(".12345e-3", 8, 8), new DecimalData("-.12345E-3", 8, 8), new DecimalData("1234512345.1234", 18, 8), new DecimalData("-1234512345.1234", 18, 8), new DecimalData("1234512345.1234", 12, 2), new DecimalData("-1234512345.1234", 12, 2), new DecimalData("1234512345.1299", 12, 2), new DecimalData("-1234512345.1299", 12, 2), new DecimalData("999999999999999999", 18, 0), new DecimalData("1234512345.1234512345", 20, 10), new DecimalData("-1234512345.1234512345", 20, 10), new DecimalData("1234512345.1234512345", 15, 5), new DecimalData("-1234512345.1234512345", 15, 5), new DecimalData("12345123451234512345E-10", 20, 10), new DecimalData("-12345123451234512345E-10", 20, 10), new DecimalData("12345123451234512345E-10", 15, 5), new DecimalData("-12345123451234512345E-10", 15, 5), new DecimalData("999999999999999999999", 21, 0), new DecimalData("-999999999999999999999", 21, 0), new DecimalData("0.00000000000000000000123456789123456789", 38, 38), new DecimalData("-0.00000000000000000000123456789123456789", 38, 38), new DecimalData("0.00000000000000000000123456789123456789", 29, 29), new DecimalData("-0.00000000000000000000123456789123456789", 29, 29), new DecimalData("123456789123E-27", 18, 18), new DecimalData("-123456789123E-27", 18, 18), new DecimalData("123456789999E-27", 18, 18), new DecimalData("-123456789999E-27", 18, 18), new DecimalData("123456789123456789E-36", 18, 18), new DecimalData("-123456789123456789E-36", 18, 18), new DecimalData("123456789999999999E-36", 18, 18), new DecimalData("-123456789999999999E-36", 18, 18) }; for (DecimalData d : data) { assertEquals( Decimal.fromBigDecimal(new BigDecimal(d.str), d.precision, d.scale), toDecimal(fromString(d.str), d.precision, d.scale)); } BinaryRow row = new BinaryRow(data.length); BinaryRowWriter writer = new BinaryRowWriter(row); for (int i = 0; i < data.length; i++) { writer.writeString(i, BinaryString.fromString(data[i].str)); } writer.complete(); for (int i = 0; i < data.length; i++) { DecimalData d = data[i]; assertEquals( Decimal.fromBigDecimal(new BigDecimal(d.str), d.precision, d.scale), toDecimal(row.getString(i), d.precision, d.scale)); } }
public static BinaryString fromString(String str) { if (str == null) { return null; } else { return new BinaryString(str); } }
BinaryString extends LazyBinaryFormat<String> implements Comparable<BinaryString> { public static BinaryString fromString(String str) { if (str == null) { return null; } else { return new BinaryString(str); } } }
BinaryString extends LazyBinaryFormat<String> implements Comparable<BinaryString> { public static BinaryString fromString(String str) { if (str == null) { return null; } else { return new BinaryString(str); } } BinaryString(); private  BinaryString(MemorySegment[] segments, int offset, int sizeInBytes); private  BinaryString(String javaObject); private  BinaryString(MemorySegment[] segments, int offset, int sizeInBytes, String javaObject); }
BinaryString extends LazyBinaryFormat<String> implements Comparable<BinaryString> { public static BinaryString fromString(String str) { if (str == null) { return null; } else { return new BinaryString(str); } } BinaryString(); private  BinaryString(MemorySegment[] segments, int offset, int sizeInBytes); private  BinaryString(String javaObject); private  BinaryString(MemorySegment[] segments, int offset, int sizeInBytes, String javaObject); static BinaryString fromAddress(
			MemorySegment[] segments, int offset, int numBytes); static BinaryString fromString(String str); static BinaryString fromBytes(byte[] bytes); static BinaryString fromBytes(byte[] bytes, int offset, int numBytes); static BinaryString blankString(int length); int numChars(); byte byteAt(int index); byte[] getBytes(); @Override boolean equals(Object o); @Override String toString(); @Override void materialize(); BinaryString copy(); @Override int compareTo(@Nonnull BinaryString other); BinaryString substring(int beginIndex, int endIndex); boolean contains(final BinaryString s); boolean startsWith(final BinaryString prefix); boolean endsWith(final BinaryString suffix); BinaryString trim(); int indexOf(BinaryString str, int fromIndex); BinaryString toUpperCase(); BinaryString toLowerCase(); }
BinaryString extends LazyBinaryFormat<String> implements Comparable<BinaryString> { public static BinaryString fromString(String str) { if (str == null) { return null; } else { return new BinaryString(str); } } BinaryString(); private  BinaryString(MemorySegment[] segments, int offset, int sizeInBytes); private  BinaryString(String javaObject); private  BinaryString(MemorySegment[] segments, int offset, int sizeInBytes, String javaObject); static BinaryString fromAddress(
			MemorySegment[] segments, int offset, int numBytes); static BinaryString fromString(String str); static BinaryString fromBytes(byte[] bytes); static BinaryString fromBytes(byte[] bytes, int offset, int numBytes); static BinaryString blankString(int length); int numChars(); byte byteAt(int index); byte[] getBytes(); @Override boolean equals(Object o); @Override String toString(); @Override void materialize(); BinaryString copy(); @Override int compareTo(@Nonnull BinaryString other); BinaryString substring(int beginIndex, int endIndex); boolean contains(final BinaryString s); boolean startsWith(final BinaryString prefix); boolean endsWith(final BinaryString suffix); BinaryString trim(); int indexOf(BinaryString str, int fromIndex); BinaryString toUpperCase(); BinaryString toLowerCase(); static final BinaryString EMPTY_UTF8; }