Last active
August 29, 2015 14:16
-
-
Save wavescholar/39e0fa6da94d953a9cda to your computer and use it in GitHub Desktop.
BytesWriteable snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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