use of cascading.tuple.Tuple in project SpyGlass by ParallelAI.
the class HBaseScheme method source.
@Override
public boolean source(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
Tuple result = new Tuple();
Object key = sourceCall.getContext()[0];
Object value = sourceCall.getContext()[1];
boolean hasNext = sourceCall.getInput().next(key, value);
if (!hasNext) {
return false;
}
// Skip nulls
if (key == null || value == null) {
return true;
}
ImmutableBytesWritable keyWritable = (ImmutableBytesWritable) key;
Result row = (Result) value;
result.add(keyWritable);
for (int i = 0; i < this.familyNames.length; i++) {
String familyName = this.familyNames[i];
byte[] familyNameBytes = Bytes.toBytes(familyName);
Fields fields = this.valueFields[i];
for (int k = 0; k < fields.size(); k++) {
String fieldName = (String) fields.get(k);
byte[] fieldNameBytes = Bytes.toBytes(fieldName);
byte[] cellValue = row.getValue(familyNameBytes, fieldNameBytes);
result.add(cellValue != null ? new ImmutableBytesWritable(cellValue) : null);
}
}
sourceCall.getIncomingEntry().setTuple(result);
return true;
}
use of cascading.tuple.Tuple in project elephant-bird by twitter.
the class LzoBinaryScheme method source.
@Override
public boolean source(FlowProcess<? extends Configuration> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
Object[] context = sourceCall.getContext();
while (sourceCall.getInput().next(context[0], context[1])) {
Object out = ((T) context[1]).get();
if (out != null) {
sourceCall.getIncomingEntry().setTuple(new Tuple(out));
return true;
}
LOG.warn("failed to decode record");
}
return false;
}
use of cascading.tuple.Tuple in project elephant-bird by twitter.
the class LzoBinaryScheme method source.
@Override
public boolean source(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
Object[] context = sourceCall.getContext();
while (sourceCall.getInput().next(context[0], context[1])) {
Object out = ((T) context[1]).get();
if (out != null) {
sourceCall.getIncomingEntry().setTuple(new Tuple(out));
return true;
}
LOG.warn("failed to decode record");
}
return false;
}
Aggregations