/** * Split a string using the default separator/escape character, * then unescape the resulting array of strings * @param str * @return an array of unescaped strings */ public static String[] splitAndUnEscape(String str) { return splitAndUnEscape(str, ESCAPE_CHAR, COMMA); }
/** * Strip comments from a sql statement, tracking when the statement contains a string literal. * * @param statement the input string * @return a stripped statement */ public static String removeComments(String statement) { if (statement == null) { return null; } Iterator<String> iterator = Splitter.on("\n").omitEmptyStrings().split(statement).iterator(); int[] startQuote = {-1}; StringBuilder ret = new StringBuilder(statement.length()); while (iterator.hasNext()) { String lineWithComments = iterator.next(); String lineNoComments = removeComments(lineWithComments, startQuote); ret.append(lineNoComments); if (iterator.hasNext() && !lineNoComments.isEmpty()) { ret.append("\n"); } } return ret.toString(); }
public static void main(String[] args) { HiveConf.setLoadHiveServer2Config(true); try { ServerOptionsProcessor oproc = new ServerOptionsProcessor("hiveserver2"); ServerOptionsProcessorResponse oprocResponse = oproc.parse(args); // NOTE: It is critical to do this here so that log4j is reinitialized // before any of the other core hive classes are loaded String initLog4jMessage = LogUtils.initHiveLog4j(); LOG.debug(initLog4jMessage); HiveStringUtils.startupShutdownMessage(HiveServer2.class, args, LOG); // Logger debug message from "oproc" after log4j initialize properly LOG.debug(oproc.getDebugMessage().toString()); // Call the executor which will execute the appropriate command based on the parsed options oprocResponse.getServerOptionsExecutor().execute(); } catch (LogInitializationException e) { LOG.error("Error initializing log: " + e.getMessage(), e); System.exit(-1); } }
final String hostname = getHostname(); final String classname = clazz.getSimpleName(); LOG.info( toStartupShutdownString("STARTUP_MSG: ", new String[] { "Starting " + classname, " host = " + hostname,
public int getCharacterLength() { return HiveStringUtils.getTextUtfLength(value); }
/** * Escape commas in the string using the default escape char * @param str a string * @return an escaped string */ public static String escapeString(String str) { return escapeString(str, ESCAPE_CHAR, COMMA); }
/** Same as byteToHexString(bytes, 0, bytes.length). */ public static String byteToHexString(byte bytes[]) { return byteToHexString(bytes, 0, bytes.length); }
/** * Split a string using the given separator * @param str a string that may have escaped separator * @param escapeChar a char that be used to escape the separator * @param separator a separator char * @return an array of strings */ public static String[] split( String str, char escapeChar, char separator) { if (str==null) { return null; } ArrayList<String> strList = new ArrayList<String>(); StringBuilder split = new StringBuilder(); int index = 0; while ((index = findNext(str, separator, escapeChar, index, split)) >= 0) { ++index; // move over the separator for next search strList.add(split.toString()); split.setLength(0); // reset the buffer } strList.add(split.toString()); // remove trailing empty split(s) int last = strList.size(); // last split while (--last>=0 && "".equals(strList.get(last))) { strList.remove(last); } return strList.toArray(new String[strList.size()]); }
@SuppressWarnings({ "rawtypes", "unchecked" }) LlapInputFormat(InputFormat sourceInputFormat, Deserializer sourceSerDe, ColumnVectorProducer cvp, ExecutorService executor, Configuration daemonConf) { this.executor = executor; this.cvp = cvp; this.daemonConf = daemonConf; this.sourceInputFormat = sourceInputFormat; this.sourceASC = (sourceInputFormat instanceof AvoidSplitCombination) ? (AvoidSplitCombination)sourceInputFormat : null; this.sourceSerDe = sourceSerDe; this.hostName = HiveStringUtils.getHostname(); }
final String hostname = getHostname(); final String classname = clazz.getSimpleName(); LOG.info( toStartupShutdownString("STARTUP_MSG: ", new String[] { "Starting " + classname, " host = " + hostname,
public int getCharacterLength() { return HiveStringUtils.getTextUtfLength(getStrippedValue()); }
/** * Escape <code>charToEscape</code> in the string * with the escape char <code>escapeChar</code> * * @param str string * @param escapeChar escape char * @param charToEscape the char to be escaped * @return an escaped string */ public static String escapeString( String str, char escapeChar, char charToEscape) { return escapeString(str, escapeChar, new char[] {charToEscape}); }
/** Same as byteToHexString(bytes, 0, bytes.length). */ public static String byteToHexString(byte bytes[]) { return byteToHexString(bytes, 0, bytes.length); }
/** * Split a string using the given separator * @param str a string that may have escaped separator * @param escapeChar a char that be used to escape the separator * @param separator a separator char * @return an array of strings */ public static String[] split( String str, char escapeChar, char separator) { if (str==null) { return null; } ArrayList<String> strList = new ArrayList<String>(); StringBuilder split = new StringBuilder(); int index = 0; while ((index = findNext(str, separator, escapeChar, index, split)) >= 0) { ++index; // move over the separator for next search strList.add(split.toString()); split.setLength(0); // reset the buffer } strList.add(split.toString()); // remove trailing empty split(s) int last = strList.size(); // last split while (--last>=0 && "".equals(strList.get(last))) { strList.remove(last); } return strList.toArray(new String[strList.size()]); }
@SuppressWarnings({ "rawtypes", "unchecked" }) LlapInputFormat(InputFormat sourceInputFormat, Deserializer sourceSerDe, ColumnVectorProducer cvp, ExecutorService executor, Configuration daemonConf) { this.executor = executor; this.cvp = cvp; this.daemonConf = daemonConf; this.sourceInputFormat = sourceInputFormat; this.sourceASC = (sourceInputFormat instanceof AvoidSplitCombination) ? (AvoidSplitCombination)sourceInputFormat : null; this.sourceSerDe = sourceSerDe; this.hostName = HiveStringUtils.getHostname(); }
HiveStringUtils.splitAndUnEscape(tbl.getProperty(serdeConstants.TIMESTAMP_FORMATS)); if (timestampFormatsArray != null) { timestampFormats = Arrays.asList(timestampFormatsArray);
/** * check that statement is unchanged after stripping */ private void assertUnchanged(String statement) { assertEquals("statement should not have been affected by stripping commnents", statement, removeComments(statement)); } }
final String hostname = getHostname(); final String classname = clazz.getSimpleName(); LOG.info( toStartupShutdownString("STARTUP_MSG: ", new String[] { "Starting " + classname, " host = " + hostname,
public int getCharacterLength() { return HiveStringUtils.getTextUtfLength(value); }
public static void main(String[] args) { HiveConf.setLoadHiveServer2Config(true); try { ServerOptionsProcessor oproc = new ServerOptionsProcessor("hiveserver2"); ServerOptionsProcessorResponse oprocResponse = oproc.parse(args); // NOTE: It is critical to do this here so that log4j is reinitialized // before any of the other core hive classes are loaded String initLog4jMessage = LogUtils.initHiveLog4j(); LOG.debug(initLog4jMessage); HiveStringUtils.startupShutdownMessage(HiveServer2.class, args, LOG); // Logger debug message from "oproc" after log4j initialize properly LOG.debug(oproc.getDebugMessage().toString()); // Call the executor which will execute the appropriate command based on the parsed options oprocResponse.getServerOptionsExecutor().execute(); } catch (LogInitializationException e) { LOG.error("Error initializing log: " + e.getMessage(), e); System.exit(-1); } }