From f210754ee351da48b5b7d555200750a837fa579b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=84=9E?= Date: Sat, 7 Dec 2024 19:47:07 +0800 Subject: [PATCH] up --- rxlib/src/main/java/org/rx/io/KeyValueStore.java | 14 ++++++-------- rxlib/src/main/java/org/rx/io/WALFileStream.java | 4 +--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/rxlib/src/main/java/org/rx/io/KeyValueStore.java b/rxlib/src/main/java/org/rx/io/KeyValueStore.java index 41679cd8..e74c31d9 100644 --- a/rxlib/src/main/java/org/rx/io/KeyValueStore.java +++ b/rxlib/src/main/java/org/rx/io/KeyValueStore.java @@ -12,6 +12,7 @@ import org.rx.core.Disposable; import org.rx.core.Linq; import org.rx.core.Reflects; +import org.rx.core.StringBuilder; import org.rx.core.Strings; import org.rx.exception.ExceptionLevel; import org.rx.exception.InvalidException; @@ -156,9 +157,6 @@ public KeyValueStore(@NonNull KeyValueStoreConfig config, @NonNull Serializer se pos = endPos.v; } }); - if (wal.extra == null) { - wal.extra = new AtomicInteger(); - } if (config.getApiPort() > 0) { startApiServer(config.getApiPort()); @@ -257,11 +255,11 @@ private Entry unsafeRead(long logPosition, TK k, $ position) { val = serializer.deserialize(wal, true); if (k != null && !k.equals(val.key)) { - AtomicInteger counter = (AtomicInteger) wal.extra; - int total = counter == null ? -1 : counter.incrementAndGet(); - log.warn("LogPosError hash collision {} total={}", k, total); - Files.writeLines("./hc_err.log", Linq.from(String.format("%s %s hc=%s total=%s", DateTime.now(), logName - , k, total)), StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.APPEND); + String msg = new StringBuilder() + .appendMessageFormat("{} {} KeyValueStore hash collision {}", + DateTime.now().toDateTimeString(), logName, k).toString(); + Files.writeLines("./rx_err.log", Linq.from(msg), + StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.APPEND); return null; } return val; diff --git a/rxlib/src/main/java/org/rx/io/WALFileStream.java b/rxlib/src/main/java/org/rx/io/WALFileStream.java index 518398a8..ce0deb8d 100644 --- a/rxlib/src/main/java/org/rx/io/WALFileStream.java +++ b/rxlib/src/main/java/org/rx/io/WALFileStream.java @@ -72,7 +72,7 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE private CompositeMmap writer; private final LinkedTransferQueue readers = new LinkedTransferQueue<>(); private final Serializer serializer; - final MetaHeader meta; + private final MetaHeader meta; @Setter long flushDelayMillis = 1000; private transient InputStream _reader; @@ -173,8 +173,6 @@ public long getLength() { return lock.readInvoke(file::getLength); } - Object extra; - public long getSize() { return lock.readInvoke(() -> meta.size); }