Skip to content

Commit 4e4a4c6

Browse files
committed
chore: fix (#364)
1 parent 3a799b7 commit 4e4a4c6

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/compact/CompactExecutor.java

-5
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ public void compact(short slot) {
108108
for (Pair<KeyInfo, byte[]> pair : surviving) {
109109
stringReadWrite.put(slot, pair.getFirst(), pair.getSecond());
110110
keyReadWrite.put(slot, pair.getFirst());
111-
if (Utils.bytesToString(pair.getFirst().getKey()).startsWith("k")) {
112-
ValueLocation valueLocation = pair.getFirst().getValueLocation();
113-
logger.info("compact put, key = {}, fileId = {}, blockId = {}, offset = {}",
114-
Utils.bytesToString(pair.getFirst().getKey()), valueLocation.blockLocation().fileId(), valueLocation.blockLocation().blockId(), valueLocation.offset());
115-
}
116111
}
117112
}
118113
for (BlockLocation block : blocks) {

camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/value/string/StringReadWrite.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,21 @@ public void put(short slot, KeyInfo keyInfo, byte[] data) throws IOException {
5353

5454
public byte[] get(short slot, KeyInfo keyInfo) throws IOException {
5555
Key key = new Key(keyInfo.getKey());
56-
byte[] bytes = readCache.get(key);
57-
if (bytes != null) {
58-
return bytes;
56+
byte[] data = readCache.get(key);
57+
if (data != null) {
58+
return data;
5959
}
60-
bytes = writeCache.get(key);
61-
if (bytes != null) {
62-
readCache.put(key, bytes);
60+
data = writeCache.get(key);
61+
if (data != null) {
62+
readCache.put(key, data);
6363
writeCache.delete(key);
64-
return bytes;
64+
return data;
65+
}
66+
data = get(slot).get(keyInfo);
67+
if (data != null) {
68+
readCache.put(key, data);
6569
}
66-
bytes = get(slot).get(keyInfo);
67-
readCache.put(key, bytes);
68-
return bytes;
70+
return data;
6971
}
7072

7173
public ValueWrapper<byte[]> getForRunToCompletion(short slot, KeyInfo keyInfo) {

camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/value/string/block/StringBlockReadWrite.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.netease.nim.camellia.redis.proxy.upstream.local.storage.value.block.BlockLocation;
1212
import com.netease.nim.camellia.redis.proxy.upstream.local.storage.value.block.BlockType;
1313
import com.netease.nim.camellia.redis.proxy.upstream.local.storage.value.block.IValueManifest;
14+
import com.netease.nim.camellia.redis.proxy.upstream.local.storage.value.block.ValueLocation;
1415
import org.slf4j.Logger;
1516
import org.slf4j.LoggerFactory;
1617

@@ -67,7 +68,11 @@ private void warm() {
6768

6869
@Override
6970
public byte[] get(KeyInfo keyInfo) throws IOException {
70-
BlockLocation blockLocation = keyInfo.getValueLocation().blockLocation();
71+
ValueLocation valueLocation = keyInfo.getValueLocation();
72+
if (valueLocation == null) {
73+
return null;
74+
}
75+
BlockLocation blockLocation = valueLocation.blockLocation();
7176
BlockType blockType = valueManifest.blockType(blockLocation.fileId());
7277
long fileId = blockLocation.fileId();
7378
long fileOffset = (long) blockType.getBlockSize() * blockLocation.blockId();

0 commit comments

Comments
 (0)