Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Sample Usage

In job setup:

Code Block
JobConfJob jobConfjob = new JobConfJob();
...
jobConfjob.setOutputFormatsetOutputFormatClass(TextOutputFormat.class);
FileOutputFormat.setOutputPath(jobConfjob, new Path("/foo"));

Map<String,String>properties = new HashMap<String,String>();
HCatSchema inputSchema = ...;
HCatSchema outputSchema = ...;
Map<String,String>properties = new HashMap<String,String>();
HCatSchema inputSchema = null;
HCatSchema outputSchema = null;
RandomAccess.addRandomAccess("myTableAlias", HBaseRandomAccess.class,
    HCatRandomAccess.createProperties("my_db","my_table",inputSchema,outputSchema,properties),
    jobConfjob.getConfiguration());

JobClientjob.runJobwaitForCompletion(jobConftrue);

In MR job:

Code Block
    public static class SampleMap implementsextends Mapper<LongWritable,Text,LongWritable,Text> {
        RandomAccess access;

        @Override
        publicprotected void configuresetup(JobConfContext jobConf)context) throws IOException, InterruptedException {
            access = RandomAccess.getRandomAccess("myTable", Object.classnew byte[]{}.getClass(), HCatRecordResult.class, HCatRecordPut.class);
        }

        @Override
        publicprotected void map(LongWritable longWritablekey, Text textvalue, OutputCollector<LongWritable, Text> longWritableTextOutputCollector, Reporter reporterContext context) throws IOException, InterruptedException {
            access.get("row1"new byte[]{});
          //key is ignored
          access.put(null,record);
        }

        @Override
        public void close() throws IOException {new byte[]{}, new Put());
        }

    }