This is an automated email from the ASF dual-hosted git repository.

bchapuis pushed a commit to branch data-refactoring
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git

commit e32db65dbf339a1dc6e386daef04078eb48c6735
Author: Bertil Chapuis <[email protected]>
AuthorDate: Sat Apr 5 09:28:25 2025 +0200

    Persist size to memory in AppendOnlyLog
---
 .../java/org/apache/baremaps/data/collection/AppendOnlyLog.java  | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git 
a/baremaps-data/src/main/java/org/apache/baremaps/data/collection/AppendOnlyLog.java
 
b/baremaps-data/src/main/java/org/apache/baremaps/data/collection/AppendOnlyLog.java
index fbb549988..4be438bdc 100644
--- 
a/baremaps-data/src/main/java/org/apache/baremaps/data/collection/AppendOnlyLog.java
+++ 
b/baremaps-data/src/main/java/org/apache/baremaps/data/collection/AppendOnlyLog.java
@@ -69,6 +69,13 @@ public class AppendOnlyLog<E> implements DataCollection<E> {
     this.size = memory.segment(0).getLong(0);
   }
 
+  /**
+   * Persists the current size to memory.
+   */
+  public void persistSize() {
+    memory.segment(0).putLong(0, size);
+  }
+
   /**
    * Appends the value to the log and returns its position in the memory.
    *
@@ -130,6 +137,8 @@ public class AppendOnlyLog<E> implements DataCollection<E> {
   public void clear() {
     try {
       memory.clear();
+      this.size = 0;
+      persistSize();
     } catch (IOException e) {
       throw new DataCollectionException(e);
     }

Reply via email to