Skip to content

Instantly share code, notes, and snippets.

@wavescholar
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wavescholar/39e0fa6da94d953a9cda to your computer and use it in GitHub Desktop.
Save wavescholar/39e0fa6da94d953a9cda to your computer and use it in GitHub Desktop.
BytesWriteable snippet
Writable key = (Writable) ReflectionUtils.newInstance(
sequenceFileReader.getKeyClass(), conf);
Writable value = (Writable) ReflectionUtils.newInstance(
sequenceFileReader.getValueClass(), conf);
boolean next = true;
while (next) {
try {
if (sequenceFileReader.next(key, value)) {
next = true;
} else {
next = false;
continue;
}
DataOutputStream output = new DataOutputStream(
new FileOutputStream(key.toString()));
BytesWritable bw = (BytesWritable) value;
byte[] bytes = bw.copyBytes();
int length = bytes.length;
//Only One of These
output.write(bytes);
//Can't do this
//value.write(output);
output.flush();
output.close();
} catch (Exception ex) {
log.error(ex.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment