public int getTrailerSize() { return getTrailerSize(majorVersion); }
private static int getMaxTrailerSize() { int maxSize = 0; for (int version = HFile.MIN_FORMAT_VERSION; version <= HFile.MAX_FORMAT_VERSION; ++version) maxSize = Math.max(getTrailerSize(version), maxSize); return maxSize; }
/** * Write trailer data as protobuf. * NOTE: we run a translation on the comparator name and will serialize the old hbase-1.x where * it makes sense. See {@link #getHBase1CompatibleName(String)}. */ void serializeAsPB(DataOutputStream output) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); // We need this extra copy unfortunately to determine the final size of the // delimited output, see use of baos.size() below. toProtobuf().writeDelimitedTo(baos); baos.writeTo(output); // Pad to make up the difference between variable PB encoding length and the // length when encoded as writable under earlier V2 formats. Failure to pad // properly or if the PB encoding is too big would mean the trailer wont be read // in properly by HFile. int padding = getTrailerSize() - NOT_PB_SIZE - baos.size(); if (padding < 0) { throw new IOException("Pbuf encoding size exceeded fixed trailer size limit"); } for (int i = 0; i < padding; i++) { output.write(0); } }
int trailerSize = getTrailerSize(majorVersion);
protected void finishClose(FixedFileTrailer trailer) throws IOException { // Write out encryption metadata before finalizing if we have a valid crypto context Encryption.Context cryptoContext = hFileContext.getEncryptionContext(); if (cryptoContext != Encryption.Context.NONE) { // Wrap the context's key and write it as the encryption metadata, the wrapper includes // all information needed for decryption trailer.setEncryptionKey(EncryptionUtil.wrapKey(cryptoContext.getConf(), cryptoContext.getConf().get(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY, User.getCurrent().getShortName()), cryptoContext.getKey())); } // Now we can finish the close trailer.setMetaIndexCount(metaNames.size()); trailer.setTotalUncompressedBytes(totalUncompressedBytes+ trailer.getTrailerSize()); trailer.setEntryCount(entryCount); trailer.setCompressionCodec(hFileContext.getCompression()); long startTime = System.currentTimeMillis(); trailer.serialize(outputStream); HFile.updateWriteLatency(System.currentTimeMillis() - startTime); if (closeOutputStream) { outputStream.close(); outputStream = null; } } }
serializeAsWritable(dos, t); dos.flush(); assertEquals(FixedFileTrailer.getTrailerSize(version), dos.size()); assertEquals(bytes.length, FixedFileTrailer.getTrailerSize(version));
t.serialize(dos); dos.flush(); assertEquals(dos.size(), FixedFileTrailer.getTrailerSize(version)); baos.reset(); assertEquals(bytes.length, FixedFileTrailer.getTrailerSize(version));
HFileProtos.FileTrailerProto.PARSER.parseDelimitedFrom(inputStream); int size = start - inputStream.available(); inputStream.skip(getTrailerSize() - NOT_PB_SIZE - size);
fileSize - trailer.getTrailerSize());
fileSize - trailer.getTrailerSize());
public int getTrailerSize() { return getTrailerSize(majorVersion); }
public int getTrailerSize() { return getTrailerSize(majorVersion); }
private static int getMaxTrailerSize() { int maxSize = 0; for (int version = MIN_FORMAT_VERSION; version <= MAX_FORMAT_VERSION; ++version) maxSize = Math.max(getTrailerSize(version), maxSize); return maxSize; }
private static int getMaxTrailerSize() { int maxSize = 0; for (int version = HFile.MIN_FORMAT_VERSION; version <= HFile.MAX_FORMAT_VERSION; ++version) maxSize = Math.max(getTrailerSize(version), maxSize); return maxSize; }
int trailerSize = getTrailerSize(majorVersion);
int trailerSize = getTrailerSize(majorVersion);
/** * Sets remaining trailer fields, writes the trailer to disk, and optionally * closes the output stream. */ protected void finishClose(FixedFileTrailer trailer) throws IOException { trailer.setMetaIndexCount(metaNames.size()); trailer.setTotalUncompressedBytes(totalUncompressedBytes+ trailer.getTrailerSize()); trailer.setEntryCount(entryCount); trailer.setCompressionCodec(compressAlgo); trailer.serialize(outputStream); if (closeOutputStream) { outputStream.close(); outputStream = null; } }
/** * Sets remaining trailer fields, writes the trailer to disk, and optionally * closes the output stream. */ protected void finishClose(FixedFileTrailer trailer) throws IOException { trailer.setMetaIndexCount(metaNames.size()); trailer.setTotalUncompressedBytes(totalUncompressedBytes+ trailer.getTrailerSize()); trailer.setEntryCount(entryCount); trailer.setCompressionCodec(hFileContext.getCompression()); trailer.serialize(outputStream); if (closeOutputStream) { outputStream.close(); outputStream = null; } }
int padding = getTrailerSize() - NOT_PB_SIZE - baos.size(); if (padding < 0) { throw new IOException("Pbuf encoding size exceeded fixed trailer size limit");
serializeAsWritable(dos, t); dos.flush(); assertEquals(FixedFileTrailer.getTrailerSize(version), dos.size()); assertEquals(bytes.length, FixedFileTrailer.getTrailerSize(version));