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 39fefaa349d63598de53547a389641b38b4ddade
Author: Bertil Chapuis <[email protected]>
AuthorDate: Sat Apr 5 12:55:23 2025 +0200

    Use the builder pattern for the MemoryAlignedDataMap
---
 .../main/java/org/apache/baremaps/workflow/WorkflowContext.java    | 7 ++++---
 .../org/apache/baremaps/data/collection/MemoryAlignedDataMap.java  | 2 +-
 .../apache/baremaps/data/collection/MemoryAlignedDataMapTest.java  | 5 ++++-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git 
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java 
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java
index 4f828d60f..bfcbf7cc0 100644
--- 
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java
+++ 
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java
@@ -74,9 +74,10 @@ public class WorkflowContext {
   private <T> DataMap<Long, T> getMemoryAlignedDataMap(String name, 
FixedSizeDataType<T> dataType)
       throws IOException {
     Path coordinateDir = Files.createDirectories(cacheDir.resolve(name));
-    return new MemoryAlignedDataMap<>(
-        dataType,
-        new MemoryMappedDirectory(coordinateDir));
+    return MemoryAlignedDataMap.<T>builder()
+        .dataType(dataType)
+        .memory(new MemoryMappedDirectory(coordinateDir))
+        .build();
   }
 
   private <T> DataMap<Long, T> getMonotonicDataMap(String name, DataType<T> 
dataType)
diff --git 
a/baremaps-data/src/main/java/org/apache/baremaps/data/collection/MemoryAlignedDataMap.java
 
b/baremaps-data/src/main/java/org/apache/baremaps/data/collection/MemoryAlignedDataMap.java
index 00f0cc69f..9fdcb0ef0 100644
--- 
a/baremaps-data/src/main/java/org/apache/baremaps/data/collection/MemoryAlignedDataMap.java
+++ 
b/baremaps-data/src/main/java/org/apache/baremaps/data/collection/MemoryAlignedDataMap.java
@@ -110,7 +110,7 @@ public class MemoryAlignedDataMap<E> implements 
DataMap<Long, E> {
    * @param dataType the data type
    * @param memory the memory
    */
-  public MemoryAlignedDataMap(FixedSizeDataType<E> dataType, Memory<?> memory) 
{
+  private MemoryAlignedDataMap(FixedSizeDataType<E> dataType, Memory<?> 
memory) {
     if (dataType.size() > memory.segmentSize()) {
       throw new DataCollectionException("The segment size is too small for the 
data type");
     }
diff --git 
a/baremaps-data/src/test/java/org/apache/baremaps/data/collection/MemoryAlignedDataMapTest.java
 
b/baremaps-data/src/test/java/org/apache/baremaps/data/collection/MemoryAlignedDataMapTest.java
index 241cc4c26..912b2b26c 100644
--- 
a/baremaps-data/src/test/java/org/apache/baremaps/data/collection/MemoryAlignedDataMapTest.java
+++ 
b/baremaps-data/src/test/java/org/apache/baremaps/data/collection/MemoryAlignedDataMapTest.java
@@ -37,7 +37,10 @@ class MemoryAlignedDataMapTest {
 
   @BeforeEach
   void setUp() {
-    map = new MemoryAlignedDataMap<>(new IntegerDataType(), new 
OnHeapMemory(1024));
+    map = MemoryAlignedDataMap.<Integer>builder()
+        .dataType(new IntegerDataType())
+        .memory(new OnHeapMemory(1024))
+        .build();
   }
 
   @AfterEach

Reply via email to