| 29 | import java.util.Random; |
| 30 | |
| 31 | public interface HadoopShims { |
| 32 | |
| 33 | enum DirectCompressionType { |
| 34 | NONE, |
| 35 | ZLIB_NOHEADER, |
| 36 | ZLIB, |
| 37 | SNAPPY, |
| 38 | } |
| 39 | |
| 40 | interface DirectDecompressor { |
| 41 | /** |
| 42 | * Decompress the in buffer to the out buffer. |
| 43 | * @param var1 the bytes to decompress |
| 44 | * @param var2 the decompressed bytes |
| 45 | * @throws IOException if there is an error |
| 46 | */ |
| 47 | void decompress(ByteBuffer var1, ByteBuffer var2) throws IOException; |
| 48 | /** |
| 49 | * Reset the decompressor. |
| 50 | */ |
| 51 | void reset(); |
| 52 | /** |
| 53 | * End the decompressor. |
| 54 | */ |
| 55 | void end(); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Get a direct decompressor codec, if it is available |
| 60 | * @param codec the kind of decompressor that we need |
| 61 | * @return a direct decompressor or null, if it isn't available |
| 62 | */ |
| 63 | DirectDecompressor getDirectDecompressor(DirectCompressionType codec); |
| 64 | |
| 65 | /** |
| 66 | * a hadoop.io ByteBufferPool shim. |
| 67 | */ |
| 68 | interface ByteBufferPoolShim { |
| 69 | /** |
| 70 | * Get a new ByteBuffer from the pool. The pool can provide this from |
| 71 | * removing a buffer from its internal cache, or by allocating a |
| 72 | * new buffer. |
| 73 | * |
| 74 | * @param direct Whether the buffer should be direct. |
| 75 | * @param length The minimum length the buffer will have. |
| 76 | * @return A new ByteBuffer. Its capacity can be less |
| 77 | * than what was requested, but must be at |
| 78 | * least 1 byte. |
| 79 | */ |
| 80 | ByteBuffer getBuffer(boolean direct, int length); |
| 81 | |
| 82 | /** |
| 83 | * Release a buffer back to the pool. |
| 84 | * The pool may choose to put this buffer into its cache/free it. |
| 85 | * |
| 86 | * @param buffer a direct bytebuffer |
| 87 | */ |
| 88 | void putBuffer(ByteBuffer buffer); |
no outgoing calls
no test coverage detected