summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2017-07-03 17:30:59 -0700
committerShawn Pearce <spearce@spearce.org>2017-07-17 08:15:37 -0700
commit8c566be72fd4d2cf7aab9accaa5b869e5bcc73f0 (patch)
tree2a0270be597a62ec49db69b128e5afb12aa00d67 /org.eclipse.jgit
parente924de52950c871d34d8e734a8eabb5620490219 (diff)
downloadjgit-8c566be72fd4d2cf7aab9accaa5b869e5bcc73f0.tar.gz
jgit-8c566be72fd4d2cf7aab9accaa5b869e5bcc73f0.zip
Use separate DfsStreamKey for PackIndex
Instead of overloading the pack's DfsStreamKey with negative positions for the idx, reverse idx and bitmap, assign a unique DfsStreamKey for each of these related streams. Change-Id: Ie048036c74a1d1bbf5ea7e888452dc0c1adf992f
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java26
1 files changed, 6 insertions, 20 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
index e995a9e25a..2f10cd31d0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
@@ -90,23 +90,6 @@ import org.eclipse.jgit.util.LongList;
* objects are similar.
*/
public final class DfsPackFile {
- /**
- * File offset used to cache {@link #index} in {@link DfsBlockCache}.
- * <p>
- * To better manage memory, the forward index is stored as a single block in
- * the block cache under this file position. A negative value is used
- * because it cannot occur in a normal pack file, and it is less likely to
- * collide with a valid data block from the file as the high bits will all
- * be set when treated as an unsigned long by the cache code.
- */
- private static final long POS_INDEX = -1;
-
- /** Offset used to cache {@link #reverseIndex}. See {@link #POS_INDEX}. */
- private static final long POS_REVERSE_INDEX = -2;
-
- /** Offset used to cache {@link #bitmapIndex}. See {@link #POS_INDEX}. */
- private static final long POS_BITMAP_INDEX = -3;
-
/** Cache that owns this pack file and its data. */
private final DfsBlockCache cache;
@@ -115,6 +98,9 @@ public final class DfsPackFile {
/** Unique identity of this pack while in-memory. */
final DfsStreamKey key;
+ final DfsStreamKey idxKey = new DfsStreamKey();
+ final DfsStreamKey reverseIdxKey = new DfsStreamKey();
+ final DfsStreamKey bitmapKey = new DfsStreamKey();
/**
* Total number of bytes in this pack file.
@@ -211,7 +197,7 @@ public final class DfsPackFile {
long objCnt = idx.getObjectCount();
int recSize = Constants.OBJECT_ID_LENGTH + 8;
int sz = (int) Math.min(objCnt * recSize, Integer.MAX_VALUE);
- index = cache.put(key, POS_INDEX, sz, idx);
+ index = cache.put(idxKey, 0, sz, idx);
}
/**
@@ -356,7 +342,7 @@ public final class DfsPackFile {
throw e2;
}
- bitmapIndex = cache.put(key, POS_BITMAP_INDEX,
+ bitmapIndex = cache.put(bitmapKey, 0,
(int) Math.min(size, Integer.MAX_VALUE), idx);
return idx;
}
@@ -382,7 +368,7 @@ public final class DfsPackFile {
PackReverseIndex revidx = new PackReverseIndex(idx);
int sz = (int) Math.min(
idx.getObjectCount() * 8, Integer.MAX_VALUE);
- reverseIndex = cache.put(key, POS_REVERSE_INDEX, sz, revidx);
+ reverseIndex = cache.put(reverseIdxKey, 0, sz, revidx);
return revidx;
}
}