Example usage for org.apache.mahout.common.iterator.sequencefile SequenceFileDirIterator SequenceFileDirIterator

List of usage examples for org.apache.mahout.common.iterator.sequencefile SequenceFileDirIterator SequenceFileDirIterator

Introduction

In this page you can find the example usage for org.apache.mahout.common.iterator.sequencefile SequenceFileDirIterator SequenceFileDirIterator.

Prototype

public SequenceFileDirIterator(Path path, PathType pathType, PathFilter filter, Comparator<FileStatus> ordering,
        boolean reuseKeyValueInstances, Configuration conf) throws IOException 

Source Link

Document

Constructor that uses either FileSystem#listStatus(Path) or FileSystem#globStatus(Path) to obtain list of files to iterate over (depending on pathType parameter).

Usage

From source file:at.illecker.hadoop.rootbeer.examples.matrixmultiplication.DistributedRowMatrix.java

License:Apache License

@Override
public Iterator<MatrixSlice> iterateAll() {
    try {/*from  w  ww  .  j  ava  2  s. co  m*/
        Path pathPattern = rowPath;
        if (FileSystem.get(conf).getFileStatus(rowPath).isDir()) {
            pathPattern = new Path(rowPath, "*");
        }
        return Iterators.transform(
                new SequenceFileDirIterator<IntWritable, VectorWritable>(pathPattern, PathType.GLOB,
                        PathFilters.logsCRCFilter(), null, true, conf),
                new Function<Pair<IntWritable, VectorWritable>, MatrixSlice>() {
                    @Override
                    public MatrixSlice apply(Pair<IntWritable, VectorWritable> from) {
                        return new MatrixSlice(from.getSecond().get(), from.getFirst().get());
                    }
                });
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}