Parse comma separated path strings into a string array. This method escapes commas in the Hadoop glob pattern of the given paths. This method is borrowed from org.apache.hadoop.mapreduce.lib.input.FileInputFormat. A jira (MAPREDUCE-1205) is opened to make the same name method there accessib
(String commaSeparatedPaths)
| 174 | * @return an array of path strings |
| 175 | */ |
| 176 | public static String[] getPathStrings(String commaSeparatedPaths) { |
| 177 | int length = commaSeparatedPaths.length(); |
| 178 | int curlyOpen = 0; |
| 179 | int pathStart = 0; |
| 180 | boolean globPattern = false; |
| 181 | List<String> pathStrings = new ArrayList<String>(); |
| 182 | |
| 183 | for (int i=0; i<length; i++) { |
| 184 | char ch = commaSeparatedPaths.charAt(i); |
| 185 | switch(ch) { |
| 186 | case '{' : { |
| 187 | curlyOpen++; |
| 188 | if (!globPattern) { |
| 189 | globPattern = true; |
| 190 | } |
| 191 | break; |
| 192 | } |
| 193 | case '}' : { |
| 194 | curlyOpen--; |
| 195 | if (curlyOpen == 0 && globPattern) { |
| 196 | globPattern = false; |
| 197 | } |
| 198 | break; |
| 199 | } |
| 200 | case ',' : { |
| 201 | if (!globPattern) { |
| 202 | pathStrings.add(commaSeparatedPaths.substring(pathStart, i)); |
| 203 | pathStart = i + 1 ; |
| 204 | } |
| 205 | break; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | pathStrings.add(commaSeparatedPaths.substring(pathStart, length)); |
| 210 | |
| 211 | return pathStrings.toArray(new String[0]); |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Construct the absolute path from the file location and the current |