use of com.facebook.airlift.json.JsonObjectMapperProvider in project presto by prestodb.
the class MetadataManager method createTestingViewCodec.
private static JsonCodec<ViewDefinition> createTestingViewCodec(FunctionAndTypeManager functionAndTypeManager) {
JsonObjectMapperProvider provider = new JsonObjectMapperProvider();
provider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(functionAndTypeManager)));
return new JsonCodecFactory(provider).jsonCodec(ViewDefinition.class);
}
use of com.facebook.airlift.json.JsonObjectMapperProvider in project presto by prestodb.
the class TestCustomDateTimeJsonFieldDecoder method testInvalidFormatHint.
@Test
public void testInvalidFormatHint() {
DecoderTestColumnHandle columnHandle = new DecoderTestColumnHandle(0, "some_column", TIMESTAMP, "mappedField", "custom-date-time", "XXMM/yyyy/dd H:m:sXX", false, false, false);
assertThatThrownBy(() -> new JsonRowDecoderFactory(new JsonObjectMapperProvider().get()).create(emptyMap(), ImmutableSet.of(columnHandle))).isInstanceOf(PrestoException.class).hasMessageMatching("invalid joda pattern 'XXMM/yyyy/dd H:m:sXX' passed as format hint for column 'some_column'");
}
use of com.facebook.airlift.json.JsonObjectMapperProvider in project presto by prestodb.
the class RecordingHiveMetastore method writeRecording.
@Managed
public void writeRecording() throws IOException {
if (replay) {
throw new IllegalStateException("Cannot write recording in replay mode");
}
Recording recording = new Recording(allDatabases, allRoles, toPairs(databaseCache), toPairs(tableCache), toPairs(supportedColumnStatisticsCache), toPairs(tableStatisticsCache), toPairs(partitionStatisticsCache), toPairs(allTablesCache), toPairs(allViewsCache), toPairs(partitionCache), toPairs(partitionNamesCache), toPairs(partitionNamesByFilterCache), toPairs(partitionsByNamesCache), toPairs(tablePrivilegesCache), toPairs(roleGrantsCache));
new JsonObjectMapperProvider().get().writerWithDefaultPrettyPrinter().writeValue(new File(recordingPath), recording);
}
use of com.facebook.airlift.json.JsonObjectMapperProvider in project presto by prestodb.
the class RecordingHiveMetastore method loadRecording.
@VisibleForTesting
void loadRecording() throws IOException {
Recording recording = new JsonObjectMapperProvider().get().readValue(new File(recordingPath), Recording.class);
allDatabases = recording.getAllDatabases();
allRoles = recording.getAllRoles();
databaseCache.putAll(toMap(recording.getDatabases()));
tableCache.putAll(toMap(recording.getTables()));
supportedColumnStatisticsCache.putAll(toMap(recording.getSupportedColumnStatistics()));
tableStatisticsCache.putAll(toMap(recording.getTableStatistics()));
partitionStatisticsCache.putAll(toMap(recording.getPartitionStatistics()));
allTablesCache.putAll(toMap(recording.getAllTables()));
allViewsCache.putAll(toMap(recording.getAllViews()));
partitionCache.putAll(toMap(recording.getPartitions()));
partitionNamesCache.putAll(toMap(recording.getPartitionNames()));
partitionNamesByFilterCache.putAll(toMap(recording.getPartitionNamesByFilter()));
partitionsByNamesCache.putAll(toMap(recording.getPartitionsByNames()));
tablePrivilegesCache.putAll(toMap(recording.getTablePrivileges()));
roleGrantsCache.putAll(toMap(recording.getRoleGrants()));
}
use of com.facebook.airlift.json.JsonObjectMapperProvider in project presto by prestodb.
the class TestSignature method testSerializationRoundTrip.
@Test
public void testSerializationRoundTrip() {
JsonObjectMapperProvider objectMapperProvider = new JsonObjectMapperProvider();
objectMapperProvider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(createTestFunctionAndTypeManager())));
JsonCodec<Signature> codec = new JsonCodecFactory(objectMapperProvider, true).jsonCodec(Signature.class);
Signature expected = new Signature(QualifiedObjectName.valueOf(DEFAULT_NAMESPACE, "function"), SCALAR, parseTypeSignature(StandardTypes.BIGINT), ImmutableList.of(parseTypeSignature(StandardTypes.BOOLEAN), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.VARCHAR)));
String json = codec.toJson(expected);
Signature actual = codec.fromJson(json);
assertEquals(actual.getNameSuffix(), expected.getNameSuffix());
assertEquals(actual.getKind(), expected.getKind());
assertEquals(actual.getReturnType(), expected.getReturnType());
assertEquals(actual.getArgumentTypes(), expected.getArgumentTypes());
}
Aggregations