com.google.common.primitives.SignedBytes Java Examples

The following examples show how to use com.google.common.primitives.SignedBytes. 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: DecimalCasts.java    From presto with Apache License 2.0 6 votes vote down vote up
@UsedByGeneratedCode
public static long shortDecimalToTinyint(long decimal, long precision, long scale, long tenToScale)
{
    // this rounds the decimal value to the nearest integral value
    long longResult = (decimal + tenToScale / 2) / tenToScale;
    if (decimal < 0) {
        longResult = -((-decimal + tenToScale / 2) / tenToScale);
    }

    try {
        return SignedBytes.checkedCast(longResult);
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(INVALID_CAST_ARGUMENT, format("Cannot cast '%s' to TINYINT", longResult));
    }
}
 
Example #2
Source File: Ideas_2011_08_01.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@ExpectWarning(value="RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE", num = 9)
public static int testGuavaPrimitiveCompareCalls() {
    int count = 0;
    if (Booleans.compare(false, true) == -1)
        count++;
    if (Chars.compare('a', 'b') == -1)
        count++;
    if (Doubles.compare(1, 2) == -1)
        count++;
    if (Floats.compare(1, 2) == -1)
        count++;
    if (Ints.compare(1, 2) == -1)
        count++;
    if (Longs.compare(1, 2) == -1)
        count++;
    if (Shorts.compare((short) 1, (short) 2) == -1)
        count++;
    if (SignedBytes.compare((byte) 1, (byte) 2) == -1)
        count++;
    if (UnsignedBytes.compare((byte) 1, (byte) 2) == -1)
        count++;
    return count;

}
 
Example #3
Source File: BloomFilter.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Writes this {@code BloomFilter} to an output stream, with a custom format (not Java
 * serialization). This has been measured to save at least 400 bytes compared to regular
 * serialization.
 *
 * <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter.
 */


public void writeTo(OutputStream out) throws IOException {
  // Serial form:
  // 1 signed byte for the strategy
  // 1 unsigned byte for the number of hash functions
  // 1 big endian int, the number of longs in our bitset
  // N big endian longs of our bitset
  DataOutputStream dout = new DataOutputStream(out);
  dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
  dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
  dout.writeInt(bits.data.length);
  for (long value : bits.data) {
    dout.writeLong(value);
  }
}
 
Example #4
Source File: BloomFilter.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Writes this {@code BloomFilter} to an output stream, with a custom format (not Java
 * serialization). This has been measured to save at least 400 bytes compared to regular
 * serialization.
 *
 * <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter.
 */


public void writeTo(OutputStream out) throws IOException {
  // Serial form:
  // 1 signed byte for the strategy
  // 1 unsigned byte for the number of hash functions
  // 1 big endian int, the number of longs in our bitset
  // N big endian longs of our bitset
  DataOutputStream dout = new DataOutputStream(out);
  dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
  dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
  dout.writeInt(bits.data.length);
  for (long value : bits.data) {
    dout.writeLong(value);
  }
}
 
Example #5
Source File: BloomFilter.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Writes this {@code BloomFilter} to an output stream, with a custom format (not Java
 * serialization). This has been measured to save at least 400 bytes compared to regular
 * serialization.
 *
 * <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter.
 */


public void writeTo(OutputStream out) throws IOException {
  // Serial form:
  // 1 signed byte for the strategy
  // 1 unsigned byte for the number of hash functions
  // 1 big endian int, the number of longs in our bitset
  // N big endian longs of our bitset
  DataOutputStream dout = new DataOutputStream(out);
  dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
  dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
  dout.writeInt(bits.data.length);
  for (long value : bits.data) {
    dout.writeLong(value);
  }
}
 
Example #6
Source File: HilbertSFCTest.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetId_2DSpatialLexicographicOrdering() throws Exception {

  final int LATITUDE_BITS = 31;
  final int LONGITUDE_BITS = 31;

  final double[] minValue = new double[] {-90, -180};
  final double[] maxValue = new double[] {90, 180};

  final SFCDimensionDefinition[] SPATIAL_DIMENSIONS =
      new SFCDimensionDefinition[] {
          new SFCDimensionDefinition(new LatitudeDefinition(), LATITUDE_BITS),
          new SFCDimensionDefinition(new LongitudeDefinition(), LONGITUDE_BITS)};

  final SpaceFillingCurve hilbertSFC =
      SFCFactory.createSpaceFillingCurve(SPATIAL_DIMENSIONS, SFCType.HILBERT);

  Assert.assertTrue(
      SignedBytes.lexicographicalComparator().compare(
          hilbertSFC.getId(minValue),
          hilbertSFC.getId(maxValue)) < 0);
}
 
Example #7
Source File: BloomFilter.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Writes this {@code BloomFilter} to an output stream, with a custom format (not Java
 * serialization). This has been measured to save at least 400 bytes compared to regular
 * serialization.
 *
 * <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter.
 */


public void writeTo(OutputStream out) throws IOException {
  // Serial form:
  // 1 signed byte for the strategy
  // 1 unsigned byte for the number of hash functions
  // 1 big endian int, the number of longs in our bitset
  // N big endian longs of our bitset
  DataOutputStream dout = new DataOutputStream(out);
  dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
  dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
  dout.writeInt(bits.data.length);
  for (long value : bits.data) {
    dout.writeLong(value);
  }
}
 
Example #8
Source File: MetastoreHiveStatisticsProvider.java    From presto with Apache License 2.0 6 votes vote down vote up
private static long normalizeIntegerValue(Type type, long value)
{
    if (type.equals(BIGINT)) {
        return value;
    }
    if (type.equals(INTEGER)) {
        return Ints.saturatedCast(value);
    }
    if (type.equals(SMALLINT)) {
        return Shorts.saturatedCast(value);
    }
    if (type.equals(TINYINT)) {
        return SignedBytes.saturatedCast(value);
    }
    throw new IllegalArgumentException("Unexpected type: " + type);
}
 
Example #9
Source File: JsonUtil.java    From presto with Apache License 2.0 6 votes vote down vote up
public static Long currentTokenAsTinyint(JsonParser parser)
        throws IOException
{
    switch (parser.currentToken()) {
        case VALUE_NULL:
            return null;
        case VALUE_STRING:
        case FIELD_NAME:
            return VarcharOperators.castToTinyint(Slices.utf8Slice(parser.getText()));
        case VALUE_NUMBER_FLOAT:
            return DoubleOperators.castToTinyint(parser.getDoubleValue());
        case VALUE_NUMBER_INT:
            return (long) SignedBytes.checkedCast(parser.getLongValue());
        case VALUE_TRUE:
            return BooleanOperators.castToTinyint(true);
        case VALUE_FALSE:
            return BooleanOperators.castToTinyint(false);
        default:
            throw new JsonCastException(format("Unexpected token when cast to %s: %s", StandardTypes.TINYINT, parser.getText()));
    }
}
 
Example #10
Source File: ByteColumnWriter.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public void writeBlock(Block block)
{
    checkState(!closed);
    checkArgument(block.getPositionCount() > 0, "Block is empty");

    // record nulls
    for (int position = 0; position < block.getPositionCount(); position++) {
        presentStream.writeBoolean(!block.isNull(position));
    }

    // record values
    for (int position = 0; position < block.getPositionCount(); position++) {
        if (!block.isNull(position)) {
            dataStream.writeByte(SignedBytes.checkedCast(type.getLong(block, position)));
            nonNullValueCount++;
        }
    }
}
 
Example #11
Source File: DFSUtil.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** Compare two byte arrays by lexicographical order. */
public static int compareBytes(byte[] left, byte[] right) {
  if (left == null) {
    left = EMPTY_BYTES;
  }
  if (right == null) {
    right = EMPTY_BYTES;
  }
  return SignedBytes.lexicographicalComparator().compare(left, right);
}
 
Example #12
Source File: SnapshotDiffInfo.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(INode left, INode right) {
  if (left == null) {
    return right == null ? 0 : -1;
  } else {
    if (right == null) {
      return 1;
    } else {
      int cmp = compare(left.getParent(), right.getParent());
      return cmp == 0 ? SignedBytes.lexicographicalComparator().compare(
          left.getLocalNameBytes(), right.getLocalNameBytes()) : cmp;
    }
  }
}
 
Example #13
Source File: IntegerOperators.java    From presto with Apache License 2.0 5 votes vote down vote up
@ScalarOperator(CAST)
@SqlType(StandardTypes.TINYINT)
public static long castToTinyint(@SqlType(StandardTypes.INTEGER) long value)
{
    try {
        return SignedBytes.checkedCast(value);
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, "Out of range for tinyint: " + value, e);
    }
}
 
Example #14
Source File: DFSUtil.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/** Compare two byte arrays by lexicographical order. */
public static int compareBytes(byte[] left, byte[] right) {
  if (left == null) {
    left = EMPTY_BYTES;
  }
  if (right == null) {
    right = EMPTY_BYTES;
  }
  return SignedBytes.lexicographicalComparator().compare(left, right);
}
 
Example #15
Source File: SnapshotDiffInfo.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(INode left, INode right) {
  if (left == null) {
    return right == null ? 0 : -1;
  } else {
    if (right == null) {
      return 1;
    } else {
      int cmp = compare(left.getParent(), right.getParent());
      return cmp == 0 ? SignedBytes.lexicographicalComparator().compare(
          left.getLocalNameBytes(), right.getLocalNameBytes()) : cmp;
    }
  }
}
 
Example #16
Source File: BloomFilter.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Writes this {@code BloomFilter} to an output stream, with a custom format (not Java
 * serialization). This has been measured to save at least 400 bytes compared to regular
 * serialization.
 *
 * <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter.
 */
public void writeTo(OutputStream out) throws IOException {
  // Serial form:
  // 1 signed byte for the strategy
  // 1 unsigned byte for the number of hash functions
  // 1 big endian int, the number of longs in our bitset
  // N big endian longs of our bitset
  DataOutputStream dout = new DataOutputStream(out);
  dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
  dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
  dout.writeInt(bits.data.length);
  for (long value : bits.data) {
    dout.writeLong(value);
  }
}
 
Example #17
Source File: MongoSession.java    From presto with Apache License 2.0 5 votes vote down vote up
private static Optional<Object> translateValue(Object prestoNativeValue, Type type)
{
    requireNonNull(prestoNativeValue, "prestoNativeValue is null");
    requireNonNull(type, "type is null");
    checkArgument(Primitives.wrap(type.getJavaType()).isInstance(prestoNativeValue), "%s (%s) is not a valid representation for %s", prestoNativeValue, prestoNativeValue.getClass(), type);

    if (type == TINYINT) {
        return Optional.of((long) SignedBytes.checkedCast(((Long) prestoNativeValue)));
    }

    if (type == SMALLINT) {
        return Optional.of((long) Shorts.checkedCast(((Long) prestoNativeValue)));
    }

    if (type == IntegerType.INTEGER) {
        return Optional.of((long) toIntExact(((Long) prestoNativeValue)));
    }

    if (type == BIGINT) {
        return Optional.of(prestoNativeValue);
    }

    if (type instanceof ObjectIdType) {
        return Optional.of(new ObjectId(((Slice) prestoNativeValue).getBytes()));
    }

    if (type instanceof VarcharType) {
        return Optional.of(((Slice) prestoNativeValue).toStringUtf8());
    }

    return Optional.empty();
}
 
Example #18
Source File: CuckooFilter.java    From guava-probably with Apache License 2.0 5 votes vote down vote up
/**
 * Writes this cuckoo filter to an output stream, with a custom format (not Java serialization).
 * This has been measured to save at least 400 bytes compared to regular serialization. <p/>
 *
 * Use {@link #readFrom(InputStream, Funnel)} to reconstruct the written CuckooFilter.
 */
public void writeTo(OutputStream out) throws IOException {
  /*
   * Serial form:
   * 1 signed byte for the strategy
   * 1 IEEE 754 floating-point double, the expected FPP
   * 1 big endian long, the number of entries
   * 1 big endian long, the checksum of entries
   * 1 big endian long for the number of buckets
   * 1 big endian int for the number of entries per bucket
   * 1 big endian int for the fingerprint size in bits
   * 1 big endian int, the number of longs in the filter table's data
   * N big endian longs of the filter table's data
   */
  DataOutputStream dout = new DataOutputStream(out);
  dout.writeByte(SignedBytes.checkedCast(cuckooStrategy.ordinal()));
  dout.writeDouble(fpp);
  dout.writeLong(table.size());
  dout.writeLong(table.checksum());
  dout.writeLong(table.numBuckets());
  dout.writeInt(table.numEntriesPerBucket());
  dout.writeInt(table.numBitsPerEntry());
  dout.writeInt(table.data().length);

  for (long value : table.data()) {
    dout.writeLong(value);
  }
}
 
Example #19
Source File: DoubleOperators.java    From presto with Apache License 2.0 5 votes vote down vote up
@ScalarOperator(CAST)
@SqlType(StandardTypes.TINYINT)
public static long castToTinyint(@SqlType(StandardTypes.DOUBLE) double value)
{
    if (Double.isNaN(value)) {
        throw new PrestoException(INVALID_CAST_ARGUMENT, "Cannot cast double NaN to tinyint");
    }
    try {
        return SignedBytes.checkedCast((long) MathFunctions.round(value));
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, "Out of range for tinyint: " + value, e);
    }
}
 
Example #20
Source File: RealOperators.java    From presto with Apache License 2.0 5 votes vote down vote up
@ScalarOperator(CAST)
@SqlType(StandardTypes.TINYINT)
public static long castToTinyint(@SqlType(StandardTypes.REAL) long value)
{
    float floatValue = intBitsToFloat((int) value);
    if (Float.isNaN(floatValue)) {
        throw new PrestoException(INVALID_CAST_ARGUMENT, "Cannot cast real NaN to tinyint");
    }
    try {
        return SignedBytes.checkedCast((long) MathFunctions.round((double) floatValue));
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, "Out of range for tinyint: " + floatValue, e);
    }
}
 
Example #21
Source File: CuckooFilter.java    From guava-probably with Apache License 2.0 5 votes vote down vote up
/**
 * Writes this cuckoo filter to an output stream, with a custom format (not Java serialization).
 * This has been measured to save at least 400 bytes compared to regular serialization. <p/>
 *
 * Use {@link #readFrom(InputStream, Funnel)} to reconstruct the written CuckooFilter.
 */
public void writeTo(OutputStream out) throws IOException {
  /*
   * Serial form:
   * 1 signed byte for the strategy
   * 1 IEEE 754 floating-point double, the expected FPP
   * 1 big endian long, the number of entries
   * 1 big endian long, the checksum of entries
   * 1 big endian long for the number of buckets
   * 1 big endian int for the number of entries per bucket
   * 1 big endian int for the fingerprint size in bits
   * 1 big endian int, the number of longs in the filter table's data
   * N big endian longs of the filter table's data
   */
  DataOutputStream dout = new DataOutputStream(out);
  dout.writeByte(SignedBytes.checkedCast(cuckooStrategy.ordinal()));
  dout.writeDouble(fpp);
  dout.writeLong(table.size());
  dout.writeLong(table.checksum());
  dout.writeLong(table.numBuckets());
  dout.writeInt(table.numEntriesPerBucket());
  dout.writeInt(table.numBitsPerEntry());
  dout.writeInt(table.data().length);

  for (long value : table.data()) {
    dout.writeLong(value);
  }
}
 
Example #22
Source File: SmallintOperators.java    From presto with Apache License 2.0 5 votes vote down vote up
@ScalarOperator(CAST)
@SqlType(StandardTypes.TINYINT)
public static long castToTinyint(@SqlType(StandardTypes.SMALLINT) long value)
{
    try {
        return SignedBytes.checkedCast(value);
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, "Out of range for tinyint: " + value, e);
    }
}
 
Example #23
Source File: BigintOperators.java    From presto with Apache License 2.0 5 votes vote down vote up
@ScalarOperator(CAST)
@SqlType(StandardTypes.TINYINT)
public static long castToTinyint(@SqlType(StandardTypes.BIGINT) long value)
{
    try {
        return SignedBytes.checkedCast(value);
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, "Out of range for tinyint: " + value, e);
    }
}
 
Example #24
Source File: DecimalCasts.java    From presto with Apache License 2.0 5 votes vote down vote up
@UsedByGeneratedCode
public static long longDecimalToTinyint(Slice decimal, long precision, long scale, BigInteger tenToScale)
{
    try {
        return SignedBytes.checkedCast(unscaledDecimalToUnscaledLong(rescale(decimal, DecimalConversions.intScale(-scale))));
    }
    catch (ArithmeticException | IllegalArgumentException e) {
        throw new PrestoException(INVALID_CAST_ARGUMENT, format("Cannot cast '%s' to TINYINT", Decimals.toString(decimal, DecimalConversions.intScale(scale))));
    }
}
 
Example #25
Source File: TinyintOperators.java    From presto with Apache License 2.0 5 votes vote down vote up
@ScalarOperator(NEGATION)
@SqlType(StandardTypes.TINYINT)
public static long negate(@SqlType(StandardTypes.TINYINT) long value)
{
    try {
        return SignedBytes.checkedCast(-value);
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, "tinyint negation overflow: " + value, e);
    }
}
 
Example #26
Source File: TinyintOperators.java    From presto with Apache License 2.0 5 votes vote down vote up
@ScalarOperator(MULTIPLY)
@SqlType(StandardTypes.TINYINT)
public static long multiply(@SqlType(StandardTypes.TINYINT) long left, @SqlType(StandardTypes.TINYINT) long right)
{
    try {
        return SignedBytes.checkedCast(left * right);
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, format("tinyint multiplication overflow: %s * %s", left, right), e);
    }
}
 
Example #27
Source File: TinyintOperators.java    From presto with Apache License 2.0 5 votes vote down vote up
@ScalarOperator(SUBTRACT)
@SqlType(StandardTypes.TINYINT)
public static long subtract(@SqlType(StandardTypes.TINYINT) long left, @SqlType(StandardTypes.TINYINT) long right)
{
    try {
        return SignedBytes.checkedCast(left - right);
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, format("tinyint subtraction overflow: %s - %s", left, right), e);
    }
}
 
Example #28
Source File: TinyintOperators.java    From presto with Apache License 2.0 5 votes vote down vote up
@ScalarOperator(ADD)
@SqlType(StandardTypes.TINYINT)
public static long add(@SqlType(StandardTypes.TINYINT) long left, @SqlType(StandardTypes.TINYINT) long right)
{
    try {
        return SignedBytes.checkedCast(left + right);
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, format("tinyint addition overflow: %s + %s", left, right), e);
    }
}
 
Example #29
Source File: MathFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
@Description("Round to nearest integer")
@ScalarFunction("round")
@SqlType(StandardTypes.TINYINT)
public static long roundTinyint(@SqlType(StandardTypes.TINYINT) long num, @SqlType(StandardTypes.INTEGER) long decimals)
{
    long rounded = roundLong(num, decimals);
    try {
        return SignedBytes.checkedCast(rounded);
    }
    catch (IllegalArgumentException e) {
        throw new PrestoException(NUMERIC_VALUE_OUT_OF_RANGE, "Out of range for tinyint: " + rounded, e);
    }
}
 
Example #30
Source File: KuduPageSink.java    From presto with Apache License 2.0 4 votes vote down vote up
private void appendColumn(PartialRow row, Page page, int position, int channel, int destChannel)
{
    Block block = page.getBlock(channel);
    Type type = columnTypes.get(destChannel);
    if (block.isNull(position)) {
        row.setNull(destChannel);
    }
    else if (TIMESTAMP.equals(type)) {
        row.addLong(destChannel, type.getLong(block, position) * 1000);
    }
    else if (REAL.equals(type)) {
        row.addFloat(destChannel, intBitsToFloat(toIntExact(type.getLong(block, position))));
    }
    else if (BIGINT.equals(type)) {
        row.addLong(destChannel, type.getLong(block, position));
    }
    else if (INTEGER.equals(type)) {
        row.addInt(destChannel, toIntExact(type.getLong(block, position)));
    }
    else if (SMALLINT.equals(type)) {
        row.addShort(destChannel, Shorts.checkedCast(type.getLong(block, position)));
    }
    else if (TINYINT.equals(type)) {
        row.addByte(destChannel, SignedBytes.checkedCast(type.getLong(block, position)));
    }
    else if (BOOLEAN.equals(type)) {
        row.addBoolean(destChannel, type.getBoolean(block, position));
    }
    else if (DOUBLE.equals(type)) {
        row.addDouble(destChannel, type.getDouble(block, position));
    }
    else if (isVarcharType(type)) {
        Type originalType = originalColumnTypes.get(destChannel);
        if (DATE.equals(originalType)) {
            SqlDate date = (SqlDate) originalType.getObjectValue(connectorSession, block, position);
            LocalDateTime ldt = LocalDateTime.ofEpochSecond(TimeUnit.DAYS.toSeconds(date.getDays()), 0, ZoneOffset.UTC);
            byte[] bytes = ldt.format(DateTimeFormatter.ISO_LOCAL_DATE).getBytes(StandardCharsets.UTF_8);
            row.addStringUtf8(destChannel, bytes);
        }
        else {
            row.addString(destChannel, type.getSlice(block, position).toStringUtf8());
        }
    }
    else if (VARBINARY.equals(type)) {
        row.addBinary(destChannel, type.getSlice(block, position).toByteBuffer());
    }
    else if (type instanceof DecimalType) {
        SqlDecimal sqlDecimal = (SqlDecimal) type.getObjectValue(connectorSession, block, position);
        row.addDecimal(destChannel, sqlDecimal.toBigDecimal());
    }
    else {
        throw new UnsupportedOperationException("Type is not supported: " + type);
    }
}