com.mongodb.hadoop.input.BSONFileSplit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongo-hadoop-core Show documentation
Show all versions of mongo-hadoop-core Show documentation
The MongoDB Connector for Hadoop is a plugin for Hadoop that provides the ability to use MongoDB as an input source and/or an output destination.
package com.mongodb.hadoop.input;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class BSONFileSplit extends FileSplit {
// CHECKSTYLE:OFF
protected String keyField = "_id";
// CHECKSTYLE:ON
public BSONFileSplit(final Path file, final long start, final long length,
final String[] hosts) {
super(file, start, length, hosts);
}
public BSONFileSplit() { this(null, 0, 0, null); }
public String getKeyField() {
return keyField;
}
public void setKeyField(final String keyField) {
this.keyField = keyField;
}
@Override
public void write(final DataOutput out) throws IOException {
super.write(out);
Text.writeString(out, getKeyField());
}
@Override
public void readFields(final DataInput in) throws IOException {
super.readFields(in);
setKeyField(Text.readString(in));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy