/** * Computes the length of an index header. * * @param codec Codec name. * @return length of the entire index header. * @see #writeIndexHeader(DataOutput, String, int, byte[], String) */ public static int indexHeaderLength(String codec, String suffix) { return headerLength(codec) + StringHelper.ID_LENGTH + 1 + suffix.length(); }
private static int headerSizeInBytes(int version, int uuidLength) { int size = CodecUtil.headerLength(TRANSLOG_CODEC); size += Integer.BYTES + uuidLength; // uuid if (version >= VERSION_PRIMARY_TERM) { size += Long.BYTES; // primary term size += Integer.BYTES; // checksum } return size; }
/** Retrieves the full index header from the provided {@link IndexInput}. * This throws {@link CorruptIndexException} if this file does * not appear to be an index file. */ public static byte[] readIndexHeader(IndexInput in) throws IOException { in.seek(0); final int actualHeader = in.readInt(); if (actualHeader != CODEC_MAGIC) { throw new CorruptIndexException("codec header mismatch: actual header=" + actualHeader + " vs expected header=" + CODEC_MAGIC, in); } String codec = in.readString(); in.readInt(); in.seek(in.getFilePointer() + StringHelper.ID_LENGTH); int suffixLength = in.readByte() & 0xFF; byte[] bytes = new byte[headerLength(codec) + StringHelper.ID_LENGTH + 1 + suffixLength]; in.seek(0); in.readBytes(bytes, 0, bytes.length); return bytes; }
if (in.length() < footerLength() + headerLength("")) { throw new CorruptIndexException("compound sub-files must have a valid codec header and footer: file is too small (" + in.length() + " bytes)", in);
private static int headerSizeInBytes(int version, int uuidLength) { int size = CodecUtil.headerLength(TRANSLOG_CODEC); size += Integer.BYTES + uuidLength; // uuid if (version >= VERSION_PRIMARY_TERM) { size += Long.BYTES; // primary term size += Integer.BYTES; // checksum } return size; }
private static int headerSizeInBytes(int version, int uuidLength) { int size = CodecUtil.headerLength(TRANSLOG_CODEC); size += Integer.BYTES + uuidLength; // uuid if (version >= VERSION_PRIMARY_TERM) { size += Long.BYTES; // primary term size += Integer.BYTES; // checksum } return size; }
static int getHeaderLength(int uuidLength) { return CodecUtil.headerLength(TRANSLOG_CODEC) + uuidLength + Integer.BYTES; }
private static int getHeaderLength(int uuidLength) { return CodecUtil.headerLength(TRANSLOG_CODEC) + uuidLength + RamUsageEstimator.NUM_BYTES_INT; }
/** * Computes the length of an index header. * * @param codec Codec name. * @return length of the entire index header. * @see #writeIndexHeader(DataOutput, String, int, byte[], String) */ public static int indexHeaderLength(String codec, String suffix) { return headerLength(codec) + StringHelper.ID_LENGTH + 1 + suffix.length(); }
/** * Computes the length of an index header. * * @param codec Codec name. * @return length of the entire index header. * @see #writeIndexHeader(DataOutput, String, int, byte[], String) */ public static int indexHeaderLength(String codec, String suffix) { return headerLength(codec) + StringHelper.ID_LENGTH + 1 + suffix.length(); }
/** * Computes the length of an index header. * * @param codec Codec name. * @return length of the entire index header. * @see #writeIndexHeader(DataOutput, String, int, byte[], String) */ public static int indexHeaderLength(String codec, String suffix) { return headerLength(codec) + StringHelper.ID_LENGTH + 1 + suffix.length(); }
" this translog file belongs to a different translog. path:" + path); return new TranslogReader(checkpoint.generation, channel, path, ref.length + CodecUtil.headerLength(TranslogWriter.TRANSLOG_CODEC) + Integer.BYTES, checkpoint.offset, checkpoint.numOps); default: throw new TranslogCorruptedException("No known translog stream version: " + version + " path:" + path);
assert checkpoint.offset == Files.size(path) : "offset(" + checkpoint.offset + ") != file_size(" + Files.size(path) + ") for: " + path; return new LegacyTranslogReaderBase(channelReference.getGeneration(), channelReference, CodecUtil.headerLength(TranslogWriter.TRANSLOG_CODEC), checkpoint.offset); case TranslogWriter.VERSION_CHECKPOINTS: assert path.getFileName().toString().endsWith(Translog.TRANSLOG_FILE_SUFFIX) : "new file ends with old suffix: " + path; throw new TranslogCorruptedException("expected shard UUID [" + uuidBytes + "] but got: [" + ref + "] this translog file belongs to a different translog"); return new ImmutableTranslogReader(channelReference.getGeneration(), channelReference, ref.length + CodecUtil.headerLength(TranslogWriter.TRANSLOG_CODEC) + RamUsageEstimator.NUM_BYTES_INT, checkpoint.offset, checkpoint.numOps); default: throw new TranslogCorruptedException("No known translog stream version: " + version + " path:" + path);
/** Retrieves the full index header from the provided {@link IndexInput}. * This throws {@link CorruptIndexException} if this file does * not appear to be an index file. */ public static byte[] readIndexHeader(IndexInput in) throws IOException { in.seek(0); final int actualHeader = in.readInt(); if (actualHeader != CODEC_MAGIC) { throw new CorruptIndexException("codec header mismatch: actual header=" + actualHeader + " vs expected header=" + CODEC_MAGIC, in); } String codec = in.readString(); in.readInt(); in.seek(in.getFilePointer() + StringHelper.ID_LENGTH); int suffixLength = in.readByte() & 0xFF; byte[] bytes = new byte[headerLength(codec) + StringHelper.ID_LENGTH + 1 + suffixLength]; in.seek(0); in.readBytes(bytes, 0, bytes.length); return bytes; }
final String codecNameIdx = formatName + CODEC_SFX_IDX; version = CodecUtil.checkHeader(indexStream, codecNameIdx, VERSION_START, VERSION_CURRENT); assert CodecUtil.headerLength(codecNameIdx) == indexStream.getFilePointer(); indexReader = new Lucene41StoredFieldsIndexReader(indexStream, si); throw new CorruptIndexException("Version mismatch between stored fields index and data: " + version + " != " + version2, vectorsStream); assert CodecUtil.headerLength(codecNameDat) == vectorsStream.getFilePointer();
final String codecNameIdx = formatName + CODEC_SFX_IDX; version = CodecUtil.checkHeader(indexStream, codecNameIdx, VERSION_START, VERSION_CURRENT); assert CodecUtil.headerLength(codecNameIdx) == indexStream.getFilePointer(); indexReader = new Lucene41StoredFieldsIndexReader(indexStream, si); throw new CorruptIndexException("Version mismatch between stored fields index and data: " + version + " != " + fieldsVersion, fieldsStream); assert CodecUtil.headerLength(codecNameDat) == fieldsStream.getFilePointer();
if (in.length() < footerLength() + headerLength("")) { throw new CorruptIndexException("compound sub-files must have a valid codec header and footer: file is too small (" + in.length() + " bytes)", in);