Copy splitToList from Guava (#6800)

* Copy splitToList from Guava

* add comment

* fix commit tag
This commit is contained in:
Jihoon Son 2019-01-03 02:42:13 -08:00 committed by Mingming Qiu
parent 6761663509
commit a7391b396b
2 changed files with 25 additions and 2 deletions

2
NOTICE
View File

@ -77,7 +77,7 @@ This product contains a modified version of The Guava Authors's Closer class fro
* HOMEPAGE:
* https://github.com/google/guava
* COMMIT TAG:
* https://github.com/google/guava/blob/c462d69329709f72a17a64cb229d15e76e72199c
* https://github.com/google/guava/commit/0ba7ccf36f5384a321cb78d62375bf7574e7bc24
This product contains code adapted from Apache Hadoop
* LICENSE:

View File

@ -24,6 +24,9 @@ import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class DelimitedParser extends AbstractFlatTextFormatParser
@ -74,6 +77,26 @@ public class DelimitedParser extends AbstractFlatTextFormatParser
@Override
protected List<String> parseLine(String input)
{
return splitter.splitToList(input);
return splitToList(input);
}
/**
* Copied from Guava's {@link Splitter#splitToList(CharSequence)}.
* This is to avoid the error of the missing method signature when using an old Guava library.
* For example, it may happen when running Druid Hadoop indexing jobs, since we may inherit the version provided by
* the Hadoop cluster. See https://github.com/apache/incubator-druid/issues/6801.
*/
private List<String> splitToList(String input)
{
Preconditions.checkNotNull(input);
Iterator<String> iterator = splitter.split(input).iterator();
List<String> result = new ArrayList<String>();
while (iterator.hasNext()) {
result.add(iterator.next());
}
return Collections.unmodifiableList(result);
}
}