Skip to content

Instantly share code, notes, and snippets.

@tdunning
Created September 29, 2014 00:47
Show Gist options
  • Save tdunning/22432450b9e27948b6b5 to your computer and use it in GitHub Desktop.
Save tdunning/22432450b9e27948b6b5 to your computer and use it in GitHub Desktop.
public class HbaseLookup {
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TrigoMathFunctions.class);
private HbaseLookup(){}
@FunctionTemplate(name = "hLookup", scope = FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
public static class Lookup implements DrillSimpleFunc {
@Param VarCharHolder table; // the table to read from
@Param VarCharHolder columns; // which columns to retrieve, comma-delimited
@Param VarCharHolder key; // the key to read
@Output BaseWriter.ComplexWriter writer;
public void setup(RecordBatch b) {
StringBuilder out = new StringBuilder();
for (int i = table.start; i < table.end; i++) {
out.append(table.buffer.getChar(i));
}
System.out.printf("table = %s\n", out);
out = new StringBuilder();
for (int i = table.start; i < table.end; i++) {
out.append(columns.buffer.getChar(i));
}
System.out.printf("columns = %s\n", out);
}
public void eval() {
System.out.printf("key = %s\n", key.toString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment