hi,
I am implementing PIG in java. following is the code that i am using to
achieve.
1. I am appending the result that is being taken from the HBASE table into
TUPLE which is defined outside.
2. I want to reuse that TUPLE back in PIG commands
public static void runIdQuery(PigServer pigServer, String inputFile,
String columnname, int version) throws IOException {
String result = null;
TupleFactory TUPLEFACTORY = TupleFactory.getInstance();
Tuple resultuple = TUPLEFACTORY.newTuple(1);
Tuple t ;
pigServer.registerJar(inputFile);
// fetching the data from HBASE table.
pigServer.registerQuery("b = load 'hbase://logdata' using
HBase.HBaseStorage('cf:" + columnname + "','-loadKey true -gt " +
startindex + " -lte " + endindex + "') as
(id:chararray,name:chararray);");
Iterator<Tuple> it_b = pigServer.openIterator("b");
while (it_b.hasNext()) {
// the result is being added to a tuple which is external to the PIG
t = it_b.next();
resultuple.set(version, t.get(1).toString());
result = t.get(1).toString();
System.out.println("result b : " + result);
}
// now i want to use that tuple again back inside PIG
pigServer.store("t", "id.out");
}
Thanks & Regards
Chethan Prakash