Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Fix MongoInsertStorage documentation #105

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Fix MongoInsertStorage documentation #105

wants to merge 12 commits into from

Conversation

peterableda
Copy link

  • Create simple constructor to MongoInsertStorage
  • Fix readme documentations and examples
  • Add datetime support


private final MongoOutputFormat outputFormat = new MongoOutputFormat();

public MongoInsertStorage() {
}

public MongoInsertStorage(final String idField, final String useUpsert) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing (or really here you're just renaming) useUpsert is a breaking change. You'll need to add toIgnore as a third parameter.

@dggrj
Copy link

dggrj commented Dec 24, 2014

The inability to store DateTime's to mongo right now is infuriating! I hope this gets accepted.

@llvtt llvtt self-assigned this Dec 24, 2014
@evanchooly
Copy link
Contributor

My concern with the PR is the "hijacking" of the second string parameter in the MongoInsertStorage constructor. That parameter is currently unused internally (which is probably a bug or at least a partially completed feature) but there's no telling if that constructor is used in the wild. By changing how that String is used, it silently changes (and possibly breaks) anyone who uses that constructor. There are a number of ways to do this PR but I'm really uncomfortable with that constructor change as it is.

@peterableda
Copy link
Author

I see your point. I will change that.

@evanchooly
Copy link
Contributor

It's an ugly wart (that should have at least been a boolean) but it predates my involvement. :(

@dggrj
Copy link

dggrj commented Jan 6, 2015

I wanted to issue a pull request for just the datetime conversion but knew that my local changes were possibly overkill, then got hung up trying to get tests to run & pass (I'm a maven user, new to both hadoop and gradle).

Will this change also handle datetime fix for updates? Locally I added handling for DateTime in both BSONStorage and MongoStorage (but like I said, may've been overkill).

Conflicts:
	pig/README.md
	pig/src/main/java/com/mongodb/hadoop/pig/MongoInsertStorage.java
@peterableda
Copy link
Author

@dggrj It should work for updates too.

@peterableda
Copy link
Author

@evanchooly I put back the problematic constructor. Please review my code; I will make changes if you say so.

I merged master to my fork. Is it ok like this or should I rebase my changes?

@a-bhreddy
Copy link

Hi Peter,

I am trying to load the data from hdfs to mongo. I was able to do that but I want my own index like group in the below case. But still it is mapping to objectid.

The data is loaded to mongo but _id is not apped to group still it is being mapped to objectid. Can you please check below code and let me know if some thing is wrong?

Thanks in advance....

SET mapred.job.queue.name edwdev;
REGISTER ../mongo-hadoop/mongo-java-driver-2.13.0.jar;
REGISTER ../mongo-hadoop/mongo-hadoop-core-1.3.2.jar;
REGISTER ../mongo-hadoop/mongo-hadoop-pig-1.3.2.jar;

DEFINE MongoInsertStorage com.mongodb.hadoop.pig.MongoInsertStorage();
SET mapreduce.reduce.speculative false;
test_mongo1 = LOAD '../mongo-hadoop-test.txt' USING PigStorage(',') AS (hotelid:int,supplierscore:double,supplierstate:chararray,tophotel:chararray);
out1 = FOREACH out GENERATE group;
STORE out1 INTO 'mongodb://localhost:37017/test.test1' USING MongoInsertStorage('group');

@llvtt llvtt added the pig label Mar 13, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants