/** * Unescape commas in the string using the default escape char * @param str a string * @return an unescaped string */ public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); }
/** * Unescape <code>charToEscape</code> in the string * with the escape char <code>escapeChar</code> * * @param str string * @param escapeChar escape char * @param charToEscape the escaped char * @return an unescaped string */ public static String unEscapeString( String str, char escapeChar, char charToEscape) { return unEscapeString(str, escapeChar, new char[] {charToEscape}); }
/** * replaces all occurrences of "\," with ","; returns {@code s} if no modifications needed */ public static String unEscapeString(String s) { return s != null && s.contains("\\,") ? StringUtils.unEscapeString(s) : s; }
/** * Take an encode strings and decode it into an array of strings. */ public static String[] decodeArray(String s) { if (s == null) return null; String[] escaped = StringUtils.split(s); String[] plain = new String[escaped.length]; for (int i = 0; i < escaped.length; ++i) plain[i] = StringUtils.unEscapeString(escaped[i]); return plain; }
/** * Get the list of input {@link Path}s for the map-reduce job. * * @param conf The configuration of the job * @return the list of input {@link Path}s for the map-reduce job. */ static Path[] getInputPaths(Configuration conf) throws IOException { String dirs = conf.get("mapred.input.dir"); if (dirs == null) { throw new IOException("Configuration mapred.input.dir is not defined."); } String [] list = StringUtils.split(dirs); Path[] result = new Path[list.length]; for (int i = 0; i < list.length; i++) { result[i] = new Path(StringUtils.unEscapeString(list[i])); } return result; }
/** * When a Pig job is submitted and it uses HCat, WebHCat may be configured to ship hive tar * to the target node. Pig on the target node needs some env vars configured. */ private static void handlePigEnvVars(Configuration conf, Map<String, String> env) { if(conf.get(PigConstants.HIVE_HOME) != null) { env.put(PigConstants.HIVE_HOME, new File(conf.get(PigConstants.HIVE_HOME)).getAbsolutePath()); } if(conf.get(PigConstants.HCAT_HOME) != null) { env.put(PigConstants.HCAT_HOME, new File(conf.get(PigConstants.HCAT_HOME)).getAbsolutePath()); } if(conf.get(PigConstants.PIG_OPTS) != null) { StringBuilder pigOpts = new StringBuilder(); for(String prop : StringUtils.split(conf.get(PigConstants.PIG_OPTS))) { pigOpts.append("-D").append(StringUtils.unEscapeString(prop)).append(" "); } env.put(PigConstants.PIG_OPTS, pigOpts.toString()); } }
/** * Get the list of input {@link Path}s for the map-reduce job. * * @param conf The configuration of the job * @return the list of input {@link Path}s for the map-reduce job. */ static Path[] getInputPaths(Configuration conf) throws IOException { String dirs = conf.get("mapred.input.dir"); if (dirs == null) { throw new IOException("Configuration mapred.input.dir is not defined."); } String [] list = StringUtils.split(dirs); Path[] result = new Path[list.length]; for (int i = 0; i < list.length; i++) { result[i] = new Path(StringUtils.unEscapeString(list[i])); } return result; }
/** * Unescape commas in the string using the default escape char * @param str a string * @return an unescaped string */ public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); }
/** * Unescape commas in the string using the default escape char * @param str a string * @return an unescaped string */ public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); }
/** * Unescape commas in the string using the default escape char * @param str a string * @return an unescaped string */ public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); }
/** * Unescape commas in the string using the default escape char * @param str a string * @return an unescaped string */ public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); }
/** * Unescape commas in the string using the default escape char * @param str a string * @return an unescaped string */ public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); }
/** * Unescape commas in the string using the default escape char * @param str a string * @return an unescaped string */ public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); }
/** * Take an encode strings and decode it into an array of strings. */ public static String[] decodeArray(String s) { if (s == null) return null; String[] escaped = StringUtils.split(s); String[] plain = new String[escaped.length]; for (int i = 0; i < escaped.length; ++i) plain[i] = StringUtils.unEscapeString(escaped[i]); return plain; }
public static Path[] getInputPaths(Configuration conf) { String dirs = conf.get(INPUT_DIR, ""); String[] list = StringUtils.split(dirs); Path[] result = new Path[list.length]; for (int i = 0; i < list.length; i++) { result[i] = new Path(StringUtils.unEscapeString(list[i])); } return result; }
public static Path[] getInputPaths(JobContext context) { String dirs = context.getConfiguration().get(CommonConstants.CROSS_VALIDATION_DIR, ""); LOG.info("crossValidation_dir:" + dirs); String[] list = StringUtils.split(dirs); Path[] result = new Path[list.length]; for(int i = 0; i < list.length; i++) { result[i] = new Path(StringUtils.unEscapeString(list[i])); } return result; } }
/** * Get the list of input {@link Path}s for the map-reduce job. */ private static Path[] getInputPaths(String inputs) { String[] list = StringUtils.split(inputs); Path[] result = new Path[list.length]; for(int i = 0; i < list.length; i++) { result[i] = new Path(StringUtils.unEscapeString(list[i])); } return result; }
/** * Get the list of input {@link Path}s for the map-reduce job. */ private static Path[] getInputPaths(String inputs) { String[] list = StringUtils.split(inputs); Path[] result = new Path[list.length]; for(int i = 0; i < list.length; i++) { result[i] = new Path(StringUtils.unEscapeString(list[i])); } return result; }
/** * Get the list of input {@link Path}s for the map-reduce job. */ private static Path[] getInputPaths(String inputs) { String[] list = StringUtils.split(inputs); Path[] result = new Path[list.length]; for(int i = 0; i < list.length; i++) { result[i] = new Path(StringUtils.unEscapeString(list[i])); } return result; }
/** * Get the list of input {@link Path}s for the map-reduce job. */ private static Path[] getInputPaths(String inputs) { String[] list = StringUtils.split(inputs); Path[] result = new Path[list.length]; for(int i = 0; i < list.length; i++) { result[i] = new Path(StringUtils.unEscapeString(list[i])); } return result; }