Permalink
Browse files

Merge pull request #57 from 8thBridge/master

RE: HADOOP-51
  • Loading branch information...
2 parents 22a5d55 + a5df806 commit 3f7beef6d15b88cd8ee4148d9d16d3cc10c200c6 @mpobrien mpobrien committed Dec 18, 2012
@@ -60,6 +60,13 @@ public BSONWritable( BSONObject doc ){
this();
putAll( doc );
}
+
+ /**
+ * Clears the map of existing data, to make this object reusable since Hadoop expects it to be.
+ */
+ public void clear() {
+ ((BasicBSONObject)_doc).clear();
+ }
/**
* {@inheritDoc}
@@ -68,6 +68,7 @@ public float getProgress() throws IOException {
public boolean next(NullWritable key, BSONWritable value) throws IOException {
if ( nextKeyValue() ){
log.trace( "Had another k/v" );
+ value.clear();
value.putAll( this.value );
return true;
}
@@ -95,7 +95,7 @@ public void readFields( DataInput in ) throws IOException{
}
}
- DBCursor getCursor(){
+ public DBCursor getCursor(){
// Return the cursor with the split's query, etc. already slotted in for
// them.
// todo - support limit/skip
@@ -94,6 +94,7 @@ public boolean next( BSONWritable key, BSONWritable value ){
if ( nextKeyValue() ){
log.debug( "Had another k/v" );
key.put( "_id", getCurrentKey().get( "_id" ) );
+ value.clear();
value.putAll( getCurrentValue() );
return true;
}

0 comments on commit 3f7beef

Please sign in to comment.