Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package org.apache.hadoop.hive.ql.hooks;
import  org.apache.hadoop.security.UserGroupInformation;

Implementation of a pre execute hook that simply prints out its parameters to standard output.
public class PreExecutePrinter implements ExecuteWithHookContext {
  public void run(HookContext hookContextthrows Exception {
    SessionState ss = SessionState.get();
    Set<ReadEntityinputs = hookContext.getInputs();
    Set<WriteEntityoutputs = hookContext.getOutputs();
    UserGroupInformation ugi = hookContext.getUgi();
    this.run(ss,inputs,outputs,ugi);
  }
  public void run(SessionState sessSet<ReadEntityinputs,
      Set<WriteEntityoutputs, UserGroupInformation ugi)
    throws Exception {
    LogHelper console = SessionState.getConsole();
    if (console == null) {
      return;
    }
    if (sess != null) {
      console.printError("PREHOOK: query: " + sess.getCmd().trim());
      console.printError("PREHOOK: type: " + sess.getCommandType());
    }
    printEntities(consoleinputs"PREHOOK: Input: ");
    printEntities(consoleoutputs"PREHOOK: Output: ");
  }
  static void printEntities(LogHelper consoleSet<?> entitiesString prefix) {
    List<Stringstrings = new ArrayList<String>();
    for (Object o : entities) {
      strings.add(o.toString());
    }
    Collections.sort(strings);
    for (String s : strings) {
      console.printError(prefix + s);
    }
  }
New to GrepCode? Check out our FAQ X