*/
public static H2ODrm drmFromSeqfile(String filename, int parMin) {
long rows = 0;
int cols = 0;
Frame frame = null;
Vec labels = null;
SequenceFile.Reader reader = null;
try {
String uri = filename;
Configuration conf = new Configuration();
Path path = new Path(uri);
FileSystem fs = FileSystem.get(URI.create(uri), conf);
Vec.Writer writers[];
Vec.Writer labelwriter = null;
boolean isIntKey = false, isLongKey = false, isStringKey = false;
reader = new SequenceFile.Reader(fs, path, conf);
if (reader.getValueClass() != VectorWritable.class) {
System.out.println("ValueClass in file " + filename +
"must be VectorWritable, but found " +
reader.getValueClassName());
return null;
}
Writable key = (Writable)
ReflectionUtils.newInstance(reader.getKeyClass(), conf);
VectorWritable value = (VectorWritable)
ReflectionUtils.newInstance(reader.getValueClass(), conf);
long start = reader.getPosition();
if (reader.getKeyClass() == Text.class) {
isStringKey = true;
} else if (reader.getKeyClass() == LongWritable.class) {
isLongKey = true;
} else {
isIntKey = true;
}
while (reader.next(key, value)) {
if (cols == 0) {
Vector v = value.get();
cols = Math.max(v.size(), cols);
}
if (isLongKey) {
rows = Math.max(((LongWritable)(key)).get()+1, rows);
}
if (isIntKey) {
rows = Math.max(((IntWritable)(key)).get()+1, rows);
}
if (isStringKey) {
rows++;
}
}
reader.seek(start);
frame = H2OHelper.emptyFrame(rows, cols, parMin, -1);
writers = new Vec.Writer[cols];
for (int i = 0; i < writers.length; i++) {
writers[i] = frame.vecs()[i].open();
}
if (reader.getKeyClass() == Text.class) {
labels = frame.anyVec().makeZero();
labelwriter = labels.open();
}
long r = 0;
while (reader.next(key, value)) {
Vector v = value.get();