MCPcopy Create free account
hub / github.com/apache/pig / sortString

Method sortString

test/org/apache/pig/test/utils/TestHelper.java:410–426  ·  view source on GitHub ↗

Find out the string which matches "regex" from "target", and sort the string with spacial order. The string elements are split by "split".

(String regex, String target, String split)

Source from the content-addressed store, hash-verified

408 * order. The string elements are split by "split".
409 */
410 public static String sortString(String regex, String target, String split) {
411 Pattern p = Pattern.compile(regex);
412 Matcher matcher = p.matcher(target);
413 String original = null;
414 String replaceString = new String();
415
416 if (matcher.find()) {
417 original = matcher.group(1);
418 String[] out = original.split(split);
419 Collections.sort(Arrays.asList(out));
420 for (int j = 0; j < out.length; j++) {
421 replaceString += (j > 0 ? ", " + out[j] : out[j]);
422 }
423 return target.replace(original, replaceString);
424 }
425 return target;
426 }
427
428 /**
429 * Sort UDFs for golden plan

Callers 3

sortUDFsMethod · 0.95
sortSubFieldsMethod · 0.95

Calls 5

findMethod · 0.80
splitMethod · 0.80
sortMethod · 0.80
replaceMethod · 0.65
compileMethod · 0.45

Tested by

no test coverage detected