/** * Construct an index from the source file. * * @param sourceBuffer * the source file's raw contents. The buffer will be held by the * index instance to facilitate matching, and therefore must not * be modified by the caller. */ public DeltaIndex(byte[] sourceBuffer) { src = sourceBuffer; DeltaIndexScanner scan = new DeltaIndexScanner(src, src.length); // Reuse the same table the scanner made. We will replace the // values at each position, but we want the same-length array. // table = scan.table; tableMask = scan.tableMask; // Because entry index 0 means there are no entries for the // slot in the table, we have to allocate one extra position. // entries = new long[1 + countEntries(scan)]; copyEntries(scan); }
DeltaIndexScanner(byte[] raw, int len) { // Clip the length so it falls on a block boundary. We won't // bother to scan the final partial block. // len -= (len % DeltaIndex.BLKSZ); final int worstCaseBlockCnt = len / DeltaIndex.BLKSZ; if (worstCaseBlockCnt < 1) { table = new int[] {}; tableMask = 0; entries = new long[] {}; next = new int[] {}; } else { table = new int[tableSize(worstCaseBlockCnt)]; tableMask = table.length - 1; // As we insert blocks we preincrement so that 0 is never a // valid entry. Therefore we have to allocate one extra space. // entries = new long[1 + worstCaseBlockCnt]; next = new int[entries.length]; scan(raw, len); } }
DeltaIndexScanner(byte[] raw, int len) { // Clip the length so it falls on a block boundary. We won't // bother to scan the final partial block. // len -= (len % DeltaIndex.BLKSZ); final int worstCaseBlockCnt = len / DeltaIndex.BLKSZ; if (worstCaseBlockCnt < 1) { table = new int[] {}; tableMask = 0; entries = new long[] {}; next = new int[] {}; } else { table = new int[tableSize(worstCaseBlockCnt)]; tableMask = table.length - 1; // As we insert blocks we preincrement so that 0 is never a // valid entry. Therefore we have to allocate one extra space. // entries = new long[1 + worstCaseBlockCnt]; next = new int[entries.length]; scan(raw, len); } }
/** * Construct an index from the source file. * * @param sourceBuffer * the source file's raw contents. The buffer will be held by the * index instance to facilitate matching, and therefore must not * be modified by the caller. */ public DeltaIndex(byte[] sourceBuffer) { src = sourceBuffer; DeltaIndexScanner scan = new DeltaIndexScanner(src, src.length); // Reuse the same table the scanner made. We will replace the // values at each position, but we want the same-length array. // table = scan.table; tableMask = scan.tableMask; // Because entry index 0 means there are no entries for the // slot in the table, we have to allocate one extra position. // entries = new long[1 + countEntries(scan)]; copyEntries(scan); }
DeltaIndexScanner(byte[] raw, int len) { // Clip the length so it falls on a block boundary. We won't // bother to scan the final partial block. // len -= (len % DeltaIndex.BLKSZ); final int worstCaseBlockCnt = len / DeltaIndex.BLKSZ; if (worstCaseBlockCnt < 1) { table = new int[] {}; tableMask = 0; entries = new long[] {}; next = new int[] {}; } else { table = new int[tableSize(worstCaseBlockCnt)]; tableMask = table.length - 1; // As we insert blocks we preincrement so that 0 is never a // valid entry. Therefore we have to allocate one extra space. // entries = new long[1 + worstCaseBlockCnt]; next = new int[entries.length]; scan(raw, len); } }
/** * Construct an index from the source file. * * @param sourceBuffer * the source file's raw contents. The buffer will be held by the * index instance to facilitate matching, and therefore must not * be modified by the caller. */ public DeltaIndex(byte[] sourceBuffer) { src = sourceBuffer; DeltaIndexScanner scan = new DeltaIndexScanner(src, src.length); // Reuse the same table the scanner made. We will replace the // values at each position, but we want the same-length array. // table = scan.table; tableMask = scan.tableMask; // Because entry index 0 means there are no entries for the // slot in the table, we have to allocate one extra position. // entries = new long[1 + countEntries(scan)]; copyEntries(scan); }