All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mongodb.hadoop.streaming.io.MongoInputWriter Maven / Gradle / Ivy

Go to download

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.

The newest version!
package com.mongodb.hadoop.streaming.io;

import com.mongodb.hadoop.io.BSONWritable;
import org.apache.hadoop.streaming.PipeMapRed;
import org.apache.hadoop.streaming.io.InputWriter;

import java.io.DataOutput;
import java.io.IOException;

public class MongoInputWriter extends InputWriter {

    private DataOutput out;

    @Override
    public void initialize(final PipeMapRed pipeMapRed) throws IOException {
        super.initialize(pipeMapRed);
        out = pipeMapRed.getClientOutput();
    }

    @Override
    public void writeKey(final Object key) throws IOException {
        // We skip the key COMPLETELY as it's just a copy of _id
        // and readable by the BSON implementation
    }

    @Override
    public void writeValue(final BSONWritable value) throws IOException {
        value.write(out);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy