Merge pull request #2084 from binlijin/master

minor optimize IndexMerger's MMappedIndexRowIterable
This commit is contained in:
Fangjin Yang 2015-12-18 11:42:55 -08:00
commit 9e6874cc7e
1 changed files with 14 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
@ -1157,6 +1158,18 @@ public class IndexMerger
@Override
public Iterator<Rowboat> iterator()
{
final IntBuffer[] converterArray = FluentIterable
.from(convertedDims)
.transform(
new Function<String, IntBuffer>()
{
@Override
public IntBuffer apply(String input)
{
return converters.get(input);
}
}
).toArray(IntBuffer.class);
return Iterators.transform(
index.iterator(),
new Function<Rowboat, Rowboat>()
@ -1169,7 +1182,7 @@ public class IndexMerger
int[][] dims = input.getDims();
int[][] newDims = new int[convertedDims.size()][];
for (int i = 0; i < convertedDims.size(); ++i) {
IntBuffer converter = converters.get(convertedDims.get(i));
IntBuffer converter = converterArray[i];
if (converter == null) {
continue;