Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have connector do ORM mapping based on different object types.
Change-Id: I0dcec18292b658cc1f2d3a9d6fb17ce07956e75b
- Loading branch information
Showing
9 changed files
with
104 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/java/com/couchbase/sqoop/mapreduce/CouchbaseImportMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.couchbase.sqoop.mapreduce; | ||
|
||
import com.cloudera.sqoop.lib.LargeObjectLoader; | ||
import com.cloudera.sqoop.lib.SqoopRecord; | ||
import com.cloudera.sqoop.mapreduce.AutoProgressMapper; | ||
|
||
import java.io.IOException; | ||
import java.sql.SQLException; | ||
|
||
import org.apache.hadoop.io.NullWritable; | ||
import org.apache.hadoop.io.Text; | ||
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; | ||
|
||
public class CouchbaseImportMapper | ||
extends AutoProgressMapper<Text, SqoopRecord, Text, NullWritable> { | ||
|
||
private Text outkey; | ||
private LargeObjectLoader lobLoader; | ||
|
||
public CouchbaseImportMapper() { | ||
outkey = new Text(); | ||
} | ||
|
||
@Override | ||
protected void setup(Context context) | ||
throws IOException, InterruptedException { | ||
this.lobLoader = new LargeObjectLoader(context.getConfiguration(), | ||
FileOutputFormat.getWorkOutputPath(context)); | ||
} | ||
|
||
@Override | ||
public void map(Text key, SqoopRecord val, Context context) | ||
throws IOException, InterruptedException { | ||
try { | ||
val.loadLargeObjects(lobLoader); | ||
} catch (SQLException sqlE) { | ||
throw new IOException(sqlE); | ||
} | ||
|
||
outkey.set(val.toString()); | ||
context.write(outkey, NullWritable.get()); | ||
} | ||
|
||
@Override | ||
protected void cleanup(Context context) throws IOException { | ||
if (null != lobLoader) { | ||
lobLoader.close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters