use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class AccumuloRecordCursor method getObject.
@Override
public Object getObject(int field) {
Type type = getType(field);
checkArgument(Types.isArrayType(type) || Types.isMapType(type), "Expected field %s to be a type of array or map but is %s", field, type);
if (Types.isArrayType(type)) {
return serializer.getArray(fieldToColumnName[field], type);
}
return serializer.getMap(fieldToColumnName[field], type);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestField method testDouble.
@Test
public void testDouble() throws Exception {
Type type = DOUBLE;
Double expected = 123.45678;
Field f1 = new Field(expected, type);
assertEquals(f1.getDouble(), expected);
assertEquals(f1.getObject(), expected);
assertEquals(f1.getType(), type);
assertEquals(f1.toString(), "123.45678");
Field f2 = new Field(f1);
assertEquals(f2, f1);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestField method testTime.
@Test
public void testTime() throws Exception {
Type type = TIME;
Time expected = new Time(new GregorianCalendar(1999, 0, 1, 12, 30, 0).getTime().getTime());
Field f1 = new Field(expected, type);
assertEquals(f1.getTime(), expected);
assertEquals(f1.getObject(), expected);
assertEquals(f1.getType(), type);
assertEquals(f1.toString(), "TIME '12:30:00'");
Field f2 = new Field(f1);
assertEquals(f2, f1);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestField method testInt.
@Test
public void testInt() throws Exception {
Type type = INTEGER;
Integer expected = 12345678;
Field f1 = new Field(expected, type);
assertEquals(f1.getInt(), expected);
assertEquals(f1.getObject(), expected);
assertEquals(f1.getType(), type);
assertEquals(f1.toString(), "12345678");
Field f2 = new Field(f1);
assertEquals(f2, f1);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestField method testVarbinary.
@Test
public void testVarbinary() throws Exception {
Type type = VARBINARY;
byte[] expected = "O'Leary".getBytes(UTF_8);
Field f1 = new Field(expected, type);
assertEquals(f1.getVarbinary(), expected);
assertEquals(f1.getObject(), expected);
assertEquals(f1.getType(), type);
assertEquals(f1.toString(), "CAST('O''Leary' AS VARBINARY)");
Field f2 = new Field(f1);
assertEquals(f2, f1);
}
Aggregations