@Override public boolean getBoolean(int field) { return getFieldValueProvider(field, boolean.class).getBoolean(); }
@Override public double getDouble(int field) { return getFieldValueProvider(field, double.class).getDouble(); }
@Override public long getLong(int field) { return getFieldValueProvider(field, long.class).getLong(); }
public void assertDecodedAs(String jsonValue, Type type, long expectedValue) { checkArgument(type.getJavaType() == long.class, "Wrong (not long based) presto type '%s'", type); FieldValueProvider decodedValue = decode(Optional.of(jsonValue), type); assertFalse(decodedValue.isNull(), format("expected non null when decoding %s as %s", jsonValue, type)); assertEquals(decodedValue.getLong(), expectedValue); }
public void assertDecodedAs(String jsonValue, Type type, Slice expectedValue) { checkArgument(type.getJavaType() == Slice.class, "Wrong (not Slice based) presto type '%s'", type); FieldValueProvider decodedValue = decode(Optional.of(jsonValue), type); assertFalse(decodedValue.isNull(), format("expected non null when decoding %s as %s", jsonValue, type)); assertEquals(decodedValue.getSlice(), expectedValue); }
public void assertDecodedAs(String jsonValue, Type type, boolean expectedValue) { checkArgument(type.getJavaType() == boolean.class, "Wrong (not boolean based) presto type '%s'", type); FieldValueProvider decodedValue = decode(Optional.of(jsonValue), type); assertFalse(decodedValue.isNull(), format("expected non null when decoding %s as %s", jsonValue, type)); assertEquals(decodedValue.getBoolean(), expectedValue); }
public void assertDecodedAs(String jsonValue, Type type, double expectedValue) { checkArgument(type.getJavaType() == double.class, "Wrong (not double based) presto type '%s'", type); FieldValueProvider decodedValue = decode(Optional.of(jsonValue), type); assertFalse(decodedValue.isNull(), format("expected non null when decoding %s as %s", jsonValue, type)); assertEquals(decodedValue.getDouble(), expectedValue); }
@Override public boolean isNull(int field) { checkArgument(field < columnHandles.size(), "Invalid field index"); return currentRowValues == null || currentRowValues[field].isNull(); }
@Override public Slice getSlice(int field) { return getFieldValueProvider(field, Slice.class).getSlice(); }
@Override public Object getObject(int field) { return getFieldValueProvider(field, Block.class).getBlock(); }
private static FieldValueProvider findValueProvider(Set<FieldValueProvider> providers, DecoderColumnHandle handle) { for (FieldValueProvider provider : providers) { if (provider.accept(handle)) { return provider; } } return null; }
@Override public boolean isNull(int field) { checkArgument(field < columnHandles.size(), "Invalid field index"); return currentRowValues[field] == null || currentRowValues[field].isNull(); }
@Override public Slice getSlice(int field) { return getFieldValueProvider(field, Slice.class).getSlice(); }
private static Block getBlock(Map<DecoderColumnHandle, FieldValueProvider> decodedRow, DecoderColumnHandle handle) { FieldValueProvider provider = decodedRow.get(handle); assertNotNull(provider); return provider.getBlock(); }
public static void checkIsNull(Map<DecoderColumnHandle, FieldValueProvider> decodedRow, DecoderColumnHandle handle) { FieldValueProvider provider = decodedRow.get(handle); assertNotNull(provider); assertTrue(provider.isNull()); } }
@Override public long getLong(int field) { return getFieldValueProvider(field, long.class).getLong(); }
@Override public boolean getBoolean(int field) { return getFieldValueProvider(field, boolean.class).getBoolean(); }
@Override public double getDouble(int field) { return getFieldValueProvider(field, double.class).getDouble(); }
public static void checkValue(Map<DecoderColumnHandle, FieldValueProvider> decodedRow, DecoderColumnHandle handle, String value) { FieldValueProvider provider = decodedRow.get(handle); assertNotNull(provider); assertEquals(provider.getSlice().toStringUtf8(), value); }
public void assertMissingDecodedAsNull(Type type) { FieldValueProvider decodedValue = decode(Optional.empty(), type); assertTrue(decodedValue.isNull(), format("expected null when decoding missing field as %s", type)); }