public static ObjectInputDecoder createDecoder(Type type, TypeManager typeManager)
    {
        String base = type.getTypeSignature().getBase();
        switch (base) {
            case UnknownType.NAME:
                return o -> o;
            case BIGINT:
                return o -> (Long) o;
            case INTEGER:
                return o -> ((Long) o).intValue();
            case SMALLINT:
                return o -> ((Long) o).shortValue();
            case TINYINT:
                return o -> ((Long) o).byteValue();
            case BOOLEAN:
                return o -> (Boolean) o;
            case DATE:
                return DateTimeUtils::createDate;
            case DECIMAL:
                if (Decimals.isShortDecimal(type)) {
                    final int scale = ((DecimalType) type).getScale();
                    return o -> HiveDecimal.create(BigInteger.valueOf((long) o), scale);
                }
                else if (Decimals.isLongDecimal(type)) {
                    final int scale = ((DecimalType) type).getScale();
                    return o -> HiveDecimal.create(Decimals.decodeUnscaledValue((Slice) o), scale);
                }
                break;
            case REAL:
                return o -> intBitsToFloat(((Number) o).intValue());
            case DOUBLE:
                return o -> ((Double) o);
            case TIMESTAMP:
                return o -> new Timestamp(((long) o));
            case VARBINARY:
                return o -> ((Slice) o).getBytes();
            case VARCHAR:
                return o -> ((Slice) o).toStringUtf8();
            case CHAR:
                return o -> ((Slice) o).toStringUtf8();
            case ROW:
                return RowObjectInputDecoder.create(((RowType) type), typeManager);
            case ARRAY:
                return ArrayObjectInputDecoder.create(((ArrayType) type), typeManager);
            case MAP:
                return MapObjectInputDecoder.create(((MapType) type), typeManager);
        }

        throw unsupportedType(type);
    }
@Test
    public void testBlockObjectDecoders()
    {
        ObjectInputDecoder decoder;

        decoder = createDecoder(new ArrayType(BIGINT), typeManager);
        assertTrue(decoder instanceof ObjectInputDecoders.ArrayObjectInputDecoder);
        assertEquals(((ArrayList) decoder.decode(createLongArrayBlock())).get(0), 2L);

        decoder = createDecoder(new MapType(
                BIGINT,
                BIGINT,
                methodHandle(TestRowType.class, "throwUnsupportedOperation"),
                methodHandle(TestRowType.class, "throwUnsupportedOperation")), typeManager);
        assertTrue(decoder instanceof ObjectInputDecoders.MapObjectInputDecoder);
        HashMap map = (HashMap) decoder.decode(createLongArrayBlock());
        assertEquals(map.get(2L), 1L);
    }