summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2017-07-03 17:22:52 -0700
committerShawn Pearce <spearce@spearce.org>2017-07-17 08:15:37 -0700
commite924de52950c871d34d8e734a8eabb5620490219 (patch)
treed78af7cc8039653ec7b27aab921da7b0b372045d /org.eclipse.jgit
parentdfb9884dbcbf2ea789e097d5a0edc1d8d13aae79 (diff)
downloadjgit-e924de52950c871d34d8e734a8eabb5620490219.tar.gz
jgit-e924de52950c871d34d8e734a8eabb5620490219.zip
Rename DfsPackKey to DfsStreamKey
This renaming supports reusing DfsStreamKey in a future commit to index other PackExt type streams inside of the DfsBlockCache. Change-Id: Ib52d374e47724ccb837f4fbab1fc85c486c5b408
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DeltaBaseCache.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java28
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java (renamed from org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackKey.java)9
7 files changed, 34 insertions, 37 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DeltaBaseCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DeltaBaseCache.java
index 64a63d7c75..bd4b4d23f4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DeltaBaseCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DeltaBaseCache.java
@@ -75,7 +75,7 @@ final class DeltaBaseCache {
table = new Entry[1 << TABLE_BITS];
}
- Entry get(DfsPackKey key, long position) {
+ Entry get(DfsStreamKey key, long position) {
Entry e = table[hash(position)];
for (; e != null; e = e.tableNext) {
if (e.offset == position && key.equals(e.pack)) {
@@ -86,7 +86,7 @@ final class DeltaBaseCache {
return null;
}
- void put(DfsPackKey key, long offset, int objectType, byte[] data) {
+ void put(DfsStreamKey key, long offset, int objectType, byte[] data) {
if (data.length > maxByteCount)
return; // Too large to cache.
@@ -189,7 +189,7 @@ final class DeltaBaseCache {
}
static class Entry {
- final DfsPackKey pack;
+ final DfsStreamKey pack;
final long offset;
final int type;
final byte[] data;
@@ -198,7 +198,7 @@ final class DeltaBaseCache {
Entry lruPrev;
Entry lruNext;
- Entry(DfsPackKey key, long offset, int type, byte[] data) {
+ Entry(DfsStreamKey key, long offset, int type, byte[] data) {
this.pack = key;
this.offset = offset;
this.type = type;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java
index 4a33fb87e1..7ac5f25f1a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java
@@ -54,7 +54,7 @@ import org.eclipse.jgit.internal.storage.pack.PackOutputStream;
/** A cached slice of a {@link DfsPackFile}. */
final class DfsBlock {
- final DfsPackKey pack;
+ final DfsStreamKey stream;
final long start;
@@ -62,8 +62,8 @@ final class DfsBlock {
private final byte[] block;
- DfsBlock(DfsPackKey p, long pos, byte[] buf) {
- pack = p;
+ DfsBlock(DfsStreamKey p, long pos, byte[] buf) {
+ stream = p;
start = pos;
end = pos + buf.length;
block = buf;
@@ -73,8 +73,8 @@ final class DfsBlock {
return block.length;
}
- boolean contains(DfsPackKey want, long pos) {
- return pack == want && start <= pos && pos < end;
+ boolean contains(DfsStreamKey want, long pos) {
+ return stream == want && start <= pos && pos < end;
}
int copy(long pos, byte[] dstbuf, int dstoff, int cnt) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java
index 96a2db9748..232c763e92 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java
@@ -195,7 +195,7 @@ public final class DfsBlockCache {
blockSizeShift = Integer.numberOfTrailingZeros(blockSize);
clockLock = new ReentrantLock(true /* fair */);
- clockHand = new Ref<>(new DfsPackKey(), -1, 0, null);
+ clockHand = new Ref<>(new DfsStreamKey(), -1, 0, null);
clockHand.next = clockHand;
packCache = new ConcurrentHashMap<>(
@@ -260,7 +260,7 @@ public final class DfsBlockCache {
return packFiles;
}
- DfsPackFile getOrCreate(DfsPackDescription dsc, DfsPackKey key) {
+ DfsPackFile getOrCreate(DfsPackDescription dsc, DfsStreamKey key) {
// TODO This table grows without bound. It needs to clean up
// entries that aren't in cache anymore, and aren't being used
// by a live DfsObjDatabase reference.
@@ -277,7 +277,7 @@ public final class DfsBlockCache {
return v; // another thread
} else {
return new DfsPackFile(
- this, dsc, key != null ? key : new DfsPackKey());
+ this, dsc, key != null ? key : new DfsStreamKey());
}
});
}
@@ -320,7 +320,7 @@ public final class DfsBlockCache {
final long requestedPosition = position;
position = pack.alignToBlock(position);
- DfsPackKey key = pack.key;
+ DfsStreamKey key = pack.key;
int slot = slot(key, position);
HashEntry e1 = table.get(slot);
DfsBlock v = scan(e1, key, position);
@@ -442,10 +442,10 @@ public final class DfsBlockCache {
}
void put(DfsBlock v) {
- put(v.pack, v.start, v.size(), v);
+ put(v.stream, v.start, v.size(), v);
}
- <T> Ref<T> put(DfsPackKey key, long pos, int size, T v) {
+ <T> Ref<T> put(DfsStreamKey key, long pos, int size, T v) {
int slot = slot(key, pos);
HashEntry e1 = table.get(slot);
Ref<T> ref = scanRef(e1, key, pos);
@@ -481,12 +481,12 @@ public final class DfsBlockCache {
return ref;
}
- boolean contains(DfsPackKey key, long position) {
+ boolean contains(DfsStreamKey key, long position) {
return scan(table.get(slot(key, position)), key, position) != null;
}
@SuppressWarnings("unchecked")
- <T> T get(DfsPackKey key, long position) {
+ <T> T get(DfsStreamKey key, long position) {
T val = (T) scan(table.get(slot(key, position)), key, position);
if (val == null)
statMiss.incrementAndGet();
@@ -495,13 +495,13 @@ public final class DfsBlockCache {
return val;
}
- private <T> T scan(HashEntry n, DfsPackKey pack, long position) {
+ private <T> T scan(HashEntry n, DfsStreamKey pack, long position) {
Ref<T> r = scanRef(n, pack, position);
return r != null ? r.get() : null;
}
@SuppressWarnings("unchecked")
- private <T> Ref<T> scanRef(HashEntry n, DfsPackKey pack, long position) {
+ private <T> Ref<T> scanRef(HashEntry n, DfsStreamKey pack, long position) {
for (; n != null; n = n.next) {
Ref<T> r = n.ref;
if (r.pack == pack && r.position == position)
@@ -514,11 +514,11 @@ public final class DfsBlockCache {
packCache.remove(pack.getPackDescription());
}
- private int slot(DfsPackKey pack, long position) {
+ private int slot(DfsStreamKey pack, long position) {
return (hash(pack.hash, position) >>> 1) % tableSize;
}
- private ReentrantLock lockFor(DfsPackKey pack, long position) {
+ private ReentrantLock lockFor(DfsStreamKey pack, long position) {
return loadLocks[(hash(pack.hash, position) >>> 1) % loadLocks.length];
}
@@ -545,14 +545,14 @@ public final class DfsBlockCache {
}
static final class Ref<T> {
- final DfsPackKey pack;
+ final DfsStreamKey pack;
final long position;
final int size;
volatile T value;
Ref next;
volatile boolean hot;
- Ref(DfsPackKey pack, long position, int size, T v) {
+ Ref(DfsStreamKey pack, long position, int size, T v) {
this.pack = pack;
this.position = position;
this.size = size;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
index e65c9fda7a..cc9484aca9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
@@ -104,7 +104,7 @@ public class DfsInserter extends ObjectInserter {
ObjectIdOwnerMap<PackedObjectInfo> objectMap;
DfsBlockCache cache;
- DfsPackKey packKey;
+ DfsStreamKey packKey;
DfsPackDescription packDsc;
PackStream packOut;
private boolean rollback;
@@ -282,7 +282,7 @@ public class DfsInserter extends ObjectInserter {
rollback = true;
packDsc = db.newPack(DfsObjDatabase.PackSource.INSERT);
packOut = new PackStream(db.writeFile(packDsc, PACK));
- packKey = new DfsPackKey();
+ packKey = new DfsStreamKey();
// Write the header as though it were a single object pack.
byte[] buf = packOut.hdrBuf;
@@ -633,11 +633,11 @@ public class DfsInserter extends ObjectInserter {
private final int type;
private final long size;
- private final DfsPackKey srcPack;
+ private final DfsStreamKey srcPack;
private final long pos;
StreamLoader(ObjectId id, int type, long sz,
- DfsPackKey key, long pos) {
+ DfsStreamKey key, long pos) {
this.id = id;
this.type = type;
this.size = sz;
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 81972cde91..e995a9e25a 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
@@ -114,7 +114,7 @@ public final class DfsPackFile {
private final DfsPackDescription packDesc;
/** Unique identity of this pack while in-memory. */
- final DfsPackKey key;
+ final DfsStreamKey key;
/**
* Total number of bytes in this pack file.
@@ -171,7 +171,7 @@ public final class DfsPackFile {
* @param key
* interned key used to identify blocks in the block cache.
*/
- DfsPackFile(DfsBlockCache cache, DfsPackDescription desc, DfsPackKey key) {
+ DfsPackFile(DfsBlockCache cache, DfsPackDescription desc, DfsStreamKey key) {
this.cache = cache;
this.packDesc = desc;
this.key = key;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java
index 6430ea9c2a..aa57f1abbe 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java
@@ -94,7 +94,7 @@ public class DfsPackParser extends PackParser {
private DfsPackDescription packDsc;
/** Key used during delta resolution reading delta chains. */
- private DfsPackKey packKey;
+ private DfsStreamKey packKey;
/** If the index was small enough, the entire index after writing. */
private PackIndex packIndex;
@@ -206,7 +206,7 @@ public class DfsPackParser extends PackParser {
}
packDsc = objdb.newPack(DfsObjDatabase.PackSource.RECEIVE);
- packKey = new DfsPackKey();
+ packKey = new DfsStreamKey();
out = objdb.writeFile(packDsc, PACK);
int size = out.blockSize();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackKey.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java
index 98a2a943e3..65208832b5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackKey.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java
@@ -45,16 +45,13 @@ package org.eclipse.jgit.internal.storage.dfs;
import java.util.concurrent.atomic.AtomicLong;
-final class DfsPackKey {
+final class DfsStreamKey {
final int hash;
+ final AtomicLong cachedSize = new AtomicLong();
- final AtomicLong cachedSize;
-
- DfsPackKey() {
+ DfsStreamKey() {
// Multiply by 31 here so we can more directly combine with another
// value without doing the multiply there.
- //
hash = System.identityHashCode(this) * 31;
- cachedSize = new AtomicLong();
}
}