/** Write and flush the file header. */ void writeFileHeader() throws IOException { if (useNewMagic) { out.writeBoolean(isCompressed()); } else { Text.writeString(out, KeyBuffer.class.getName()); Text.writeString(out, ValueBuffer.class.getName()); out.writeBoolean(isCompressed()); out.writeBoolean(false); } if (isCompressed()) { Text.writeString(out, (codec.getClass()).getName()); } metadata.write(out); }
/** Write and flush the file header. */ void writeFileHeader() throws IOException { if (useNewMagic) { out.writeBoolean(isCompressed()); } else { Text.writeString(out, KeyBuffer.class.getName()); Text.writeString(out, ValueBuffer.class.getName()); out.writeBoolean(isCompressed()); out.writeBoolean(false); } if (isCompressed()) { Text.writeString(out, (codec.getClass()).getName()); } metadata.write(out); }
CompressionOutputStream deflateFilter = null; DataOutputStream deflateOut = null; boolean isCompressed = isCompressed(); int valueLength = 0; if (isCompressed) {
CompressionOutputStream deflateFilter = null; DataOutputStream deflateOut = null; boolean isCompressed = isCompressed(); int valueLength = 0; if (isCompressed) {
if (isCompressed()) { compressionBuffer[columnIndex].reset(); deflateFilter[columnIndex].resetState(); if (!isCompressed()) { out.writeInt(keyLength);
private void writeKey(KeyBuffer keyBuffer, int recordLen, int keyLength) throws IOException { checkAndWriteSync(); // sync out.writeInt(recordLen); // total record length out.writeInt(keyLength); // key portion length if(this.isCompressed()) { Compressor compressor = CodecPool.getCompressor(codec); NonSyncDataOutputBuffer compressionBuffer = new NonSyncDataOutputBuffer(); CompressionOutputStream deflateFilter = codec.createOutputStream(compressionBuffer, compressor); DataOutputStream deflateOut = new DataOutputStream(deflateFilter); //compress key and write key out compressionBuffer.reset(); deflateFilter.resetState(); keyBuffer.write(deflateOut); deflateOut.flush(); deflateFilter.finish(); int compressedKeyLen = compressionBuffer.getLength(); out.writeInt(compressedKeyLen); out.write(compressionBuffer.getData(), 0, compressedKeyLen); CodecPool.returnCompressor(compressor); } else { out.writeInt(keyLength); keyBuffer.write(out); } }
public synchronized void close() throws IOException { if (bufferedRecords > 0) { flushRecords(); } clearColumnBuffers(); if (isCompressed()) { for (int i = 0; i < columnNumber; i++) { deflateFilter[i].close(); IOUtils.closeStream(deflateOut[i]); } keyDeflateFilter.close(); IOUtils.closeStream(keyDeflateOut); CodecPool.returnCompressor(keyCompressor); keyCompressor = null; CodecPool.returnCompressor(compressor); compressor = null; } if (out != null) { // Close the underlying stream if we own it... out.flush(); out.close(); out = null; } } }
/** Write and flush the file header. */ void writeFileHeader() throws IOException { if (useNewMagic) { out.writeBoolean(isCompressed()); } else { Text.writeString(out, KeyBuffer.class.getName()); Text.writeString(out, ValueBuffer.class.getName()); out.writeBoolean(isCompressed()); out.writeBoolean(false); } if (isCompressed()) { Text.writeString(out, (codec.getClass()).getName()); } metadata.write(out); }
/** Write and flush the file header. */ void writeFileHeader() throws IOException { Text.writeString(out, KeyBuffer.class.getName()); Text.writeString(out, ValueBuffer.class.getName()); out.writeBoolean(isCompressed()); out.writeBoolean(false); if (isCompressed()) { Text.writeString(out, (codec.getClass()).getName()); } metadata.write(out); }
CompressionOutputStream deflateFilter = null; DataOutputStream deflateOut = null; boolean isCompressed = isCompressed(); int valueLength = 0; if (isCompressed) {
private void writeKey(KeyBuffer keyBuffer, int recordLen, int keyLength) throws IOException { checkAndWriteSync(); // sync out.writeInt(recordLen); // total record length out.writeInt(keyLength); // key portion length if(this.isCompressed()) { Compressor compressor = CodecPool.getCompressor(codec); NonSyncDataOutputBuffer compressionBuffer = new NonSyncDataOutputBuffer(); CompressionOutputStream deflateFilter = codec.createOutputStream(compressionBuffer, compressor); DataOutputStream deflateOut = new DataOutputStream(deflateFilter); //compress key and write key out compressionBuffer.reset(); deflateFilter.resetState(); keyBuffer.write(deflateOut); deflateOut.flush(); deflateFilter.finish(); int compressedKeyLen = compressionBuffer.getLength(); out.writeInt(compressedKeyLen); out.write(compressionBuffer.getData(), 0, compressedKeyLen); CodecPool.returnCompressor(compressor); } else { out.writeInt(keyLength); keyBuffer.write(out); } }
private void writeKey(KeyBuffer keyBuffer, int recordLen, int keyLength) throws IOException { checkAndWriteSync(); // sync out.writeInt(recordLen); // total record length out.writeInt(keyLength); // key portion length if(this.isCompressed()) { Compressor compressor = CodecPool.getCompressor(codec); NonSyncDataOutputBuffer compressionBuffer = new NonSyncDataOutputBuffer(); CompressionOutputStream deflateFilter = codec.createOutputStream(compressionBuffer, compressor); DataOutputStream deflateOut = new DataOutputStream(deflateFilter); //compress key and write key out compressionBuffer.reset(); deflateFilter.resetState(); keyBuffer.write(deflateOut); deflateOut.flush(); deflateFilter.finish(); int compressedKeyLen = compressionBuffer.getLength(); out.writeInt(compressedKeyLen); out.write(compressionBuffer.getData(), 0, compressedKeyLen); CodecPool.returnCompressor(compressor); } else { out.writeInt(keyLength); keyBuffer.write(out); } }