Robin008

 

   这是FileInputFormat中的一个方法,看一下它的功能,多看源码,理解hadoop,同时提高自己的java编程能力:

private static String[] getPathStrings(String commaSeparatedPaths) {
int length = commaSeparatedPaths.length();
int curlyOpen = 0;
int pathStart = 0;
boolean globPattern = false;
List<String> pathStrings = new ArrayList<String>();

for (int i=0; i<length; i++) {
char ch = commaSeparatedPaths.charAt(i);
switch(ch) {
case \'{\' : {
curlyOpen++;
if (!globPattern) {
globPattern = true;
}
break;
}
case \'}\' : {
curlyOpen--;
if (curlyOpen == 0 && globPattern) {
globPattern = false;
}
break;
}
case \',\' : {
if (!globPattern) {
pathStrings.add(commaSeparatedPaths.substring(pathStart, i));
pathStart = i + 1 ;
}
break;
}
default:
continue; // nothing special to do for this character
}
}
pathStrings.add(commaSeparatedPaths.substring(pathStart, length));

return pathStrings.toArray(new String[0]);  //这句我都看不懂额。The simple form with no arguments creates a new array of Object. The more complex form allows the caller to //provide an array or to choose the runtime type of the output array
}

分类:

技术点:

相关文章:

  • 2021-08-15
  • 2021-08-31
  • 2021-10-03
  • 2021-09-14
  • 2022-01-15
  • 2019-01-17
  • 2021-09-08
  • 2021-08-15
猜你喜欢
  • 2021-08-23
  • 2021-08-15
  • 2021-08-15
  • 2021-11-04
  • 2021-09-27
  • 2021-08-15
  • 2021-08-15
相关资源
相似解决方案