Search in sources :

Example 1 with FunctionSerializer

use of org.apache.hadoop.hive.ql.parse.repl.dump.io.FunctionSerializer in project hive by apache.

the class CreateFunctionHandler method handle.

@Override
public void handle(Context withinContext) throws Exception {
    CreateFunctionMessage createFunctionMessage = deserializer.getCreateFunctionMessage(event.getMessage());
    LOG.info("Processing#{} CREATE_MESSAGE message : {}", fromEventId(), event.getMessage());
    Path metadataPath = new Path(withinContext.eventRoot, EximUtil.METADATA_NAME);
    FileSystem fileSystem = metadataPath.getFileSystem(withinContext.hiveConf);
    try (JsonWriter jsonWriter = new JsonWriter(fileSystem, metadataPath)) {
        new FunctionSerializer(createFunctionMessage.getFunctionObj(), withinContext.hiveConf).writeTo(jsonWriter, withinContext.replicationSpec);
    }
    withinContext.createDmd(this).write();
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) CreateFunctionMessage(org.apache.hadoop.hive.metastore.messaging.CreateFunctionMessage) FunctionSerializer(org.apache.hadoop.hive.ql.parse.repl.dump.io.FunctionSerializer) JsonWriter(org.apache.hadoop.hive.ql.parse.repl.dump.io.JsonWriter)

Example 2 with FunctionSerializer

use of org.apache.hadoop.hive.ql.parse.repl.dump.io.FunctionSerializer in project hive by apache.

the class ReplDumpTask method dumpFunctionMetadata.

private void dumpFunctionMetadata(String dbName, Path dumpRoot) throws Exception {
    Path functionsRoot = new Path(new Path(dumpRoot, dbName), FUNCTIONS_ROOT_DIR_NAME);
    List<String> functionNames = getHive().getFunctions(dbName, "*");
    for (String functionName : functionNames) {
        HiveWrapper.Tuple<Function> tuple = functionTuple(functionName, dbName);
        if (tuple == null) {
            continue;
        }
        Path functionRoot = new Path(functionsRoot, functionName);
        Path functionMetadataFile = new Path(functionRoot, FUNCTION_METADATA_FILE_NAME);
        try (JsonWriter jsonWriter = new JsonWriter(functionMetadataFile.getFileSystem(conf), functionMetadataFile)) {
            FunctionSerializer serializer = new FunctionSerializer(tuple.object, conf);
            serializer.writeTo(jsonWriter, tuple.replicationSpec);
        }
        replLogger.functionLog(functionName);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Function(org.apache.hadoop.hive.metastore.api.Function) HiveWrapper(org.apache.hadoop.hive.ql.parse.repl.dump.HiveWrapper) FunctionSerializer(org.apache.hadoop.hive.ql.parse.repl.dump.io.FunctionSerializer) JsonWriter(org.apache.hadoop.hive.ql.parse.repl.dump.io.JsonWriter)

Aggregations

Path (org.apache.hadoop.fs.Path)2 FunctionSerializer (org.apache.hadoop.hive.ql.parse.repl.dump.io.FunctionSerializer)2 JsonWriter (org.apache.hadoop.hive.ql.parse.repl.dump.io.JsonWriter)2 FileSystem (org.apache.hadoop.fs.FileSystem)1 Function (org.apache.hadoop.hive.metastore.api.Function)1 CreateFunctionMessage (org.apache.hadoop.hive.metastore.messaging.CreateFunctionMessage)1 HiveWrapper (org.apache.hadoop.hive.ql.parse.repl.dump.HiveWrapper)1