You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by bc...@apache.org on 2023/01/12 22:57:46 UTC

[incubator-baremaps] 02/04: Improve the collection package

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

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

commit 14b5691a09ff7a02b7563de515770bc218c3b790
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Tue Jan 10 22:24:21 2023 +0100

    Improve the collection package
---
 .../baremaps/benchmarks/LongDataMapBenchmark.java  |  21 ++--
 .../OpenStreetMapGeometriesBenchmark.java          |  21 ++--
 .../org/apache/baremaps/collection/DataList.java   |  64 -----------
 .../{IntegerList.java => IndexedLongMap.java}      |  36 +++---
 .../baremaps/collection/LongDataOpenHashMap.java   |  49 --------
 .../collection/{LongList.java => LongLongMap.java} |  13 ++-
 .../collection/{LongDataMap.java => LongMap.java}  |   3 +-
 .../baremaps/collection/LongOpenHashMap.java       | 128 +++++++++++++++++++++
 ...java => MemoryAlignedLongFixedSizeDataMap.java} |  15 +--
 ...tedMap.java => SortedLongFixedSizeDataMap.java} |  39 ++++---
 ...Map.java => SortedLongVariableSizeDataMap.java} |  36 ++++--
 ...rseMap.java => SparseLongFixedSizeDataMap.java} |  11 +-
 .../{OnDiskFileMemory.java => MappedMemory.java}   |  14 +--
 .../collection/memory/OnDiskDirectoryMemory.java   |  78 -------------
 .../apache/baremaps/collection/sort/DataStack.java |   8 +-
 .../collection/sort/ExternalMergeSort.java         |  27 ++---
 .../{DataStore.java => store/AppendOnlyStore.java} |  22 +++-
 .../baremaps/collection/store/DataStore.java       |  50 ++++++++
 .../DataStoreException.java}                       |  12 +-
 .../FixedSizeDataStore.java}                       |  55 +++++----
 .../IndexedDataStore.java}                         |  37 +++---
 .../MemoryAlignedDataStore.java}                   |  55 +++++----
 .../baremaps/collection/type/ByteDataType.java     |   8 +-
 .../baremaps/collection/type/ByteListDataType.java |  37 +++---
 .../collection/type/CoordinateDataType.java        |  12 +-
 .../apache/baremaps/collection/type/DataType.java  |   6 +-
 .../baremaps/collection/type/DoubleDataType.java   |   8 +-
 .../collection/type/DoubleListDataType.java        |  23 ++--
 .../{SizedDataType.java => FixedSizeDataType.java} |  37 +++++-
 .../baremaps/collection/type/FloatDataType.java    |  20 ++--
 .../collection/type/FloatListDataType.java         |  19 +--
 .../baremaps/collection/type/GeometryDataType.java |  17 ++-
 .../baremaps/collection/type/IntegerDataType.java  |  20 ++--
 .../collection/type/IntegerListDataType.java       |  23 ++--
 .../baremaps/collection/type/ListDataType.java     |  36 +++---
 .../baremaps/collection/type/LonLatDataType.java   |  14 +--
 .../baremaps/collection/type/LongDataType.java     |   8 +-
 .../baremaps/collection/type/LongListDataType.java |  17 +--
 ...zedDataType.java => MemoryAlignedDataType.java} |  17 ++-
 .../baremaps/collection/type/NullableDataType.java |  11 +-
 .../baremaps/collection/type/PairDataType.java     |   9 +-
 .../baremaps/collection/type/ShortDataType.java    |   8 +-
 .../collection/type/ShortListDataType.java         |  23 ++--
 .../collection/type/SmallIntegerDataType.java      |   9 +-
 .../collection/type/SmallLongDataType.java         |   3 +-
 .../baremaps/collection/type/StringDataType.java   |  17 ++-
 .../collection/utils/CollectionAdapter.java        |   6 +-
 .../org/apache/baremaps/database/DiffService.java  |   8 +-
 .../apache/baremaps/database/ImportService.java    |  10 +-
 .../apache/baremaps/database/UpdateService.java    |   8 +-
 .../database/collection/PostgresCoordinateMap.java |  13 +--
 .../database/collection/PostgresReferenceMap.java  |  10 +-
 .../function/CoordinateMapBuilder.java             |   6 +-
 .../function/EntityGeometryBuilder.java            |   6 +-
 .../openstreetmap/function/GeometryMapBuilder.java |   6 +-
 .../function/ReferenceMapBuilder.java              |   6 +-
 .../function/RelationGeometryBuilder.java          |  10 +-
 .../openstreetmap/function/WayGeometryBuilder.java |   6 +-
 .../baremaps/openstreetmap/pbf/PbfBlockReader.java |  14 +--
 .../storage/geopackage/GeoPackageTable.java        |   2 +-
 .../storage/postgres/PostgresDatabase.java         |   5 +-
 .../workflow/tasks/ImportOpenStreetMap.java        |  40 ++++---
 .../workflow/tasks/SimplifyOpenStreetMap.java      | 107 +++++++++--------
 .../workflow/tasks/UpdateOpenStreetMap.java        |   6 +-
 .../{DataStoreTest.java => AppendStoreTest.java}   |   7 +-
 .../{LongDataMapTest.java => LongMapTest.java}     |  27 +++--
 .../baremaps/collection/SizedDataListTest.java     |   6 +-
 .../baremaps/collection/memory/MemoryProvider.java |   8 +-
 .../collection/sort/ExternalMergeSortTest.java     |  28 ++---
 .../baremaps/collection/type/DataTypeTest.java     |   1 +
 .../database/database/ImportUpdateDataTest.java    |  14 +--
 .../database/ImportUpdateLiechtensteinTest.java    |  14 +--
 .../database/database/ImportUpdateMonacoTest.java  |  14 +--
 .../geometry/EntityGeometryBuilderTest.java        |  10 +-
 .../geometry/RelationGeometryBuilderTest.java      |  10 +-
 .../{MockLongDataMap.java => MockLongMap.java}     |   6 +-
 .../baremaps/testing/PostgresContainerTest.java    |   3 +-
 77 files changed, 867 insertions(+), 746 deletions(-)

diff --git a/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/LongDataMapBenchmark.java b/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/LongDataMapBenchmark.java
index 19c185db..d249f4f6 100644
--- a/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/LongDataMapBenchmark.java
+++ b/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/LongDataMapBenchmark.java
@@ -19,12 +19,12 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.concurrent.TimeUnit;
-import org.apache.baremaps.collection.AlignedDataList;
+import org.apache.baremaps.collection.LongMap;
+import org.apache.baremaps.collection.MemoryAlignedLongFixedSizeDataMap;
+import org.apache.baremaps.collection.memory.MappedMemory;
 import org.apache.baremaps.collection.memory.OffHeapMemory;
-import org.apache.baremaps.collection.memory.OnDiskDirectoryMemory;
 import org.apache.baremaps.collection.memory.OnHeapMemory;
 import org.apache.baremaps.collection.type.LongDataType;
-import org.apache.baremaps.collection.utils.FileUtils;
 import org.openjdk.jmh.annotations.Benchmark;
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
@@ -45,9 +45,9 @@ public class LongDataMapBenchmark {
 
   private static final long N = 1 << 25;
 
-  private void benchmark(AlignedDataList<Long> store, long n) {
+  private void benchmark(LongMap<Long> store, long n) {
     for (long i = 0; i < n; i++) {
-      store.add(i);
+      store.put(i, i);
     }
     for (long i = 0; i < n; i++) {
       store.get(i);
@@ -59,7 +59,7 @@ public class LongDataMapBenchmark {
   @Warmup(iterations = 2)
   @Measurement(iterations = 5)
   public void onHeap() {
-    benchmark(new AlignedDataList<>(new LongDataType(), new OnHeapMemory()), N);
+    benchmark(new MemoryAlignedLongFixedSizeDataMap<>(new LongDataType(), new OnHeapMemory()), N);
   }
 
   @Benchmark
@@ -67,7 +67,7 @@ public class LongDataMapBenchmark {
   @Warmup(iterations = 2)
   @Measurement(iterations = 5)
   public void offHeap() {
-    benchmark(new AlignedDataList<>(new LongDataType(), new OffHeapMemory()), N);
+    benchmark(new MemoryAlignedLongFixedSizeDataMap<>(new LongDataType(), new OffHeapMemory()), N);
   }
 
   @Benchmark
@@ -75,9 +75,10 @@ public class LongDataMapBenchmark {
   @Warmup(iterations = 2)
   @Measurement(iterations = 5)
   public void onDisk() throws IOException {
-    Path directory = Files.createTempDirectory(Paths.get("."), "baremaps_");
-    benchmark(new AlignedDataList<>(new LongDataType(), new OnDiskDirectoryMemory(directory)), N);
-    FileUtils.deleteRecursively(directory);
+    Path file = Files.createTempFile(Paths.get("."), "baremaps_", ".tmp");
+    benchmark(new MemoryAlignedLongFixedSizeDataMap<>(new LongDataType(), new MappedMemory(file)),
+        N);
+    Files.delete(file);
   }
 
   public static void main(String[] args) throws RunnerException {
diff --git a/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/OpenStreetMapGeometriesBenchmark.java b/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/OpenStreetMapGeometriesBenchmark.java
index e7e38aff..b5f5ee32 100644
--- a/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/OpenStreetMapGeometriesBenchmark.java
+++ b/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/OpenStreetMapGeometriesBenchmark.java
@@ -25,14 +25,13 @@ import java.nio.file.StandardCopyOption;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
-import org.apache.baremaps.collection.DataStore;
-import org.apache.baremaps.collection.LongDataMap;
-import org.apache.baremaps.collection.LongDataOpenHashMap;
-import org.apache.baremaps.collection.memory.OnDiskDirectoryMemory;
+import org.apache.baremaps.collection.LongMap;
+import org.apache.baremaps.collection.LongOpenHashMap;
+import org.apache.baremaps.collection.memory.MappedMemory;
 import org.apache.baremaps.collection.memory.OnHeapMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
 import org.apache.baremaps.collection.type.CoordinateDataType;
 import org.apache.baremaps.collection.type.LongListDataType;
-import org.apache.baremaps.collection.utils.FileUtils;
 import org.apache.baremaps.openstreetmap.model.Node;
 import org.apache.baremaps.openstreetmap.model.Relation;
 import org.apache.baremaps.openstreetmap.model.Way;
@@ -76,11 +75,11 @@ public class OpenStreetMapGeometriesBenchmark {
   @Warmup(iterations = 2)
   @Measurement(iterations = 3)
   public void store() throws IOException {
-    Path directory = Files.createTempDirectory(Paths.get("."), "baremaps_");
-    LongDataMap<Coordinate> coordinateMap = new LongDataOpenHashMap<>(
-        new DataStore<>(new CoordinateDataType(), new OnDiskDirectoryMemory(directory)));
-    LongDataMap<List<Long>> referenceMap =
-        new LongDataOpenHashMap<>(new DataStore<>(new LongListDataType(), new OnHeapMemory()));
+    Path file = Files.createTempFile(Paths.get("."), "baremaps_", ".tmp");
+    LongMap<Coordinate> coordinateMap = new LongOpenHashMap<>(
+        new AppendOnlyStore<>(new CoordinateDataType(), new MappedMemory(file)));
+    LongMap<List<Long>> referenceMap =
+        new LongOpenHashMap<>(new AppendOnlyStore<>(new LongListDataType(), new OnHeapMemory()));
     AtomicLong nodes = new AtomicLong(0);
     AtomicLong ways = new AtomicLong(0);
     AtomicLong relations = new AtomicLong(0);
@@ -96,7 +95,7 @@ public class OpenStreetMapGeometriesBenchmark {
             }
           });
     }
-    FileUtils.deleteRecursively(directory);
+    Files.delete(file);
   }
 
   public static void main(String[] args) throws RunnerException {
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/DataList.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/DataList.java
deleted file mode 100644
index f017e8af..00000000
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/DataList.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.baremaps.collection;
-
-
-
-import java.io.Closeable;
-
-/**
- * A list of data.
- *
- * @param <T>
- */
-public interface DataList<T> extends Closeable, Cleanable {
-
-  /**
-   * Adds a value to the list and returns its index.
-   *
-   * @param value the value to be added
-   * @return the index of the value
-   */
-  long add(T value);
-
-  /**
-   * Inserts the specified value at the specified position in this list.
-   *
-   * @param index the index of the value to be added
-   * @param value the value
-   */
-  void add(long index, T value);
-
-  /**
-   * Returns a values by its index.
-   *
-   * @param index the index of the value to be removed
-   * @return the value
-   */
-  T get(long index);
-
-  /**
-   * Removes the value at the specified position in this list.
-   *
-   * @param index the index of the value to be removed
-   * @return the value that was removed from the list
-   */
-  T remove(long index);
-
-  /**
-   * Returns the size of the list.
-   *
-   * @return the size of the list.
-   */
-  long size();
-}
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/IntegerList.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/IndexedLongMap.java
similarity index 52%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/IntegerList.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/IndexedLongMap.java
index ea49bf1f..621d1ab7 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/IntegerList.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/IndexedLongMap.java
@@ -14,18 +14,28 @@ package org.apache.baremaps.collection;
 
 
 
-import org.apache.baremaps.collection.memory.Memory;
-import org.apache.baremaps.collection.type.IntegerDataType;
-
-/** A list of integers backed by a {@link Memory}. */
-public class IntegerList extends AlignedDataList<Integer> {
-
-  /**
-   * Constructs a list.
-   *
-   * @param memory the memory
-   */
-  public IntegerList(Memory memory) {
-    super(new IntegerDataType(), memory);
+import org.apache.baremaps.collection.store.AppendOnlyStore;
+
+public class IndexedLongMap<T> implements LongMap<T> {
+
+  private final LongLongMap index;
+
+  private final AppendOnlyStore<T> store;
+
+  public IndexedLongMap(LongLongMap index, AppendOnlyStore<T> store) {
+    this.index = index;
+    this.store = store;
+  }
+
+  @Override
+  public void put(long key, T value) {
+    var position = store.add(value);
+    index.put(key, position);
+  }
+
+  @Override
+  public T get(long idx) {
+    var position = index.get(idx);
+    return store.get(position);
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongDataOpenHashMap.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/LongDataOpenHashMap.java
deleted file mode 100644
index 880ff3d5..00000000
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongDataOpenHashMap.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.baremaps.collection;
-
-
-
-import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
-import java.util.Map;
-
-/**
- * A map of data backed by a {@link DataStore} and whose keys are stored in an
- * {@link Long2LongOpenHashMap}.
- *
- * <p>
- * This code has been adapted from Planetiler (Apache license).
- *
- * <p>
- * Copyright (c) Planetiler.
- */
-public class LongDataOpenHashMap<T> implements LongDataMap<T> {
-
-  private final Map<Long, Long> map;
-  private final DataStore<T> store;
-
-  public LongDataOpenHashMap(DataStore<T> values) {
-    this.map = new Long2LongOpenHashMap();
-    this.store = values;
-  }
-
-  @Override
-  public void put(long key, T value) {
-    map.put(key, store.add(value));
-  }
-
-  @Override
-  public T get(long key) {
-    return store.get(map.get(key));
-  }
-}
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongList.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/LongLongMap.java
similarity index 74%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/LongList.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/LongLongMap.java
index 81f1d5ec..63ea4102 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongList.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/LongLongMap.java
@@ -15,17 +15,24 @@ package org.apache.baremaps.collection;
 
 
 import org.apache.baremaps.collection.memory.Memory;
+import org.apache.baremaps.collection.memory.OffHeapMemory;
 import org.apache.baremaps.collection.type.LongDataType;
 
-/** A list of longs backed by a {@link Memory}. */
-public class LongList extends AlignedDataList<Long> {
+/**
+ * A list of longs backed by a {@link Memory}.
+ */
+public class LongLongMap extends MemoryAlignedLongFixedSizeDataMap<Long> {
+
+  public LongLongMap() {
+    this(new OffHeapMemory());
+  }
 
   /**
    * Constructs a list.
    *
    * @param memory the memory
    */
-  public LongList(Memory memory) {
+  public LongLongMap(Memory memory) {
     super(new LongDataType(), memory);
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongDataMap.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/LongMap.java
similarity index 97%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/LongDataMap.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/LongMap.java
index f8d4a6e2..6d75bc62 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongDataMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/LongMap.java
@@ -21,7 +21,7 @@ import java.util.List;
  *
  * @param <T>
  */
-public interface LongDataMap<T> {
+public interface LongMap<T> {
 
   /**
    * Associates the specified value with the specified key in this map.
@@ -51,4 +51,5 @@ public interface LongDataMap<T> {
   default List<T> get(List<Long> keys) {
     return keys.stream().map(this::get).toList();
   }
+
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongOpenHashMap.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/LongOpenHashMap.java
new file mode 100644
index 00000000..5c91d21f
--- /dev/null
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/LongOpenHashMap.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.baremaps.collection;
+
+
+
+import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
+
+/**
+ * A map of data backed by a {@link AppendOnlyStore} and whose keys are stored in an
+ * {@link Long2LongOpenHashMap}.
+ *
+ * <p>
+ * This code has been adapted from Planetiler (Apache license).
+ *
+ * <p>
+ * Copyright (c) Planetiler.
+ */
+public class LongOpenHashMap<T> implements LongMap<T>, Map<Long, T> {
+
+  private final Map<Long, Long> index;
+  private final AppendOnlyStore<T> store;
+
+  public LongOpenHashMap(AppendOnlyStore<T> values) {
+    this.index = new Long2LongOpenHashMap();
+    this.store = values;
+  }
+
+  public LongOpenHashMap(Map<Long, Long> index, AppendOnlyStore<T> store) {
+    this.index = index;
+    this.store = store;
+  }
+
+  @Override
+  public void put(long key, T value) {
+    index.put(key, store.add(value));
+  }
+
+  @Override
+  public T get(long key) {
+    return store.get(index.get(key));
+  }
+
+  @Override
+  public int size() {
+    return index.size();
+  }
+
+  @Override
+  public boolean isEmpty() {
+    return index.isEmpty();
+  }
+
+  @Override
+  public boolean containsKey(Object key) {
+    return index.containsKey(key);
+  }
+
+  @Override
+  public boolean containsValue(Object value) {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public T get(Object key) {
+    var position = index.get(key);
+    return store.get(position);
+  }
+
+  @Override
+  public T put(Long key, T value) {
+    var previous = get(key);
+    var position = store.add(value);
+    index.put(key, position);
+    return previous;
+  }
+
+  @Override
+  public T remove(Object key) {
+    var previous = get(key);
+    index.remove(key);
+    return previous;
+  }
+
+  @Override
+  public void putAll(Map<? extends Long, ? extends T> m) {
+    m.forEach(this::put);
+  }
+
+  @Override
+  public void clear() {
+    index.clear();
+  }
+
+  @Override
+  public Set<Long> keySet() {
+    return index.keySet();
+  }
+
+  @Override
+  public Collection<T> values() {
+    return index.values().stream().map(store::get).collect(Collectors.toList());
+  }
+
+  @Override
+  public Set<Entry<Long, T>> entrySet() {
+    return index.entrySet().stream().map(entry -> {
+      var key = entry.getKey();
+      var value = store.get(entry.getValue());
+      return Map.entry(key, value);
+    }).collect(Collectors.toSet());
+  }
+}
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongSizedDataDenseMap.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/MemoryAlignedLongFixedSizeDataMap.java
similarity index 78%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/LongSizedDataDenseMap.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/MemoryAlignedLongFixedSizeDataMap.java
index e3ba9882..2f93e328 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongSizedDataDenseMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/MemoryAlignedLongFixedSizeDataMap.java
@@ -16,10 +16,11 @@ package org.apache.baremaps.collection;
 
 import java.nio.ByteBuffer;
 import org.apache.baremaps.collection.memory.Memory;
-import org.apache.baremaps.collection.type.SizedDataType;
+import org.apache.baremaps.collection.store.DataStoreException;
+import org.apache.baremaps.collection.type.FixedSizeDataType;
 
 /**
- * A dense map of data backed by a {@link SizedDataType} and a {@link Memory}.
+ * A dense map of data backed by a {@link FixedSizeDataType} and a {@link Memory}.
  *
  * <p>
  * This code has been adapted from Planetiler (Apache license).
@@ -27,9 +28,9 @@ import org.apache.baremaps.collection.type.SizedDataType;
  * <p>
  * Copyright (c) Planetiler.
  */
-public class LongSizedDataDenseMap<T> implements LongDataMap<T> {
+public class MemoryAlignedLongFixedSizeDataMap<T> implements LongMap<T> {
 
-  private final SizedDataType<T> dataType;
+  private final FixedSizeDataType<T> dataType;
 
   private final Memory memory;
 
@@ -45,12 +46,12 @@ public class LongSizedDataDenseMap<T> implements LongDataMap<T> {
    * @param dataType the data type
    * @param memory the memory
    */
-  public LongSizedDataDenseMap(SizedDataType<T> dataType, Memory memory) {
+  public MemoryAlignedLongFixedSizeDataMap(FixedSizeDataType<T> dataType, Memory memory) {
     if (dataType.size() > memory.segmentSize()) {
-      throw new StoreException("The values are too big");
+      throw new DataStoreException("The values are too big");
     }
     if (memory.segmentSize() % dataType.size() != 0) {
-      throw new StoreException("The segment size and data type size must be aligned");
+      throw new DataStoreException("The segment size and data type size must be aligned");
     }
     this.dataType = dataType;
     this.memory = memory;
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongSizedDataSortedMap.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/SortedLongFixedSizeDataMap.java
similarity index 65%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/LongSizedDataSortedMap.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/SortedLongFixedSizeDataMap.java
index ac6a9803..1246b6de 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongSizedDataSortedMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/SortedLongFixedSizeDataMap.java
@@ -14,11 +14,12 @@ package org.apache.baremaps.collection;
 
 
 
-import org.apache.baremaps.collection.memory.OffHeapMemory;
+import org.apache.baremaps.collection.store.DataStore;
+import org.apache.baremaps.collection.store.MemoryAlignedDataStore;
 import org.apache.baremaps.collection.type.LongDataType;
 
 /**
- * A sorted map of data backed by {@link AlignedDataList}s for storing keys and values.
+ * A sorted map of data backed by {@link DataStore}s for storing keys and values.
  *
  * <p>
  * This code has been adapted from Planetiler (Apache license).
@@ -26,26 +27,34 @@ import org.apache.baremaps.collection.type.LongDataType;
  * <p>
  * Copyright (c) Planetiler.
  */
-public class LongSizedDataSortedMap<T> implements LongDataMap<T> {
+public class SortedLongFixedSizeDataMap<T> implements LongMap<T> {
 
-  private final AlignedDataList<Long> offsets;
-  private final AlignedDataList<Long> keys;
-  private final AlignedDataList<T> values;
+  private final DataStore<Long> offsets;
+  private final DataStore<Long> keys;
+  private final DataStore<T> values;
   private long lastChunk = -1;
 
+  public SortedLongFixedSizeDataMap(DataStore<T> values) {
+    this(new MemoryAlignedDataStore<>(new LongDataType()),
+        new MemoryAlignedDataStore<>(new LongDataType()), values);
+  }
+
   /**
    * Constructs a map.
    *
    * @param keys the list of keys
    * @param values the list of values
    */
-  public LongSizedDataSortedMap(AlignedDataList<Long> keys, AlignedDataList<T> values) {
-    this.offsets = new AlignedDataList<>(new LongDataType(), new OffHeapMemory());
+  public SortedLongFixedSizeDataMap(DataStore<Long> offsets, DataStore<Long> keys,
+      DataStore<T> values) {
+    this.offsets = offsets;
     this.keys = keys;
     this.values = values;
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public void put(long key, T value) {
     long index = keys.size();
@@ -60,7 +69,9 @@ public class LongSizedDataSortedMap<T> implements LongDataMap<T> {
     values.add(value);
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public T get(long key) {
     long chunk = key >>> 8;
@@ -68,9 +79,10 @@ public class LongSizedDataSortedMap<T> implements LongDataMap<T> {
       return null;
     }
     long lo = offsets.get(chunk);
-    long hi =
-        Math.min(keys.size(), chunk >= offsets.size() - 1 ? keys.size() : offsets.get(chunk + 1))
-            - 1;
+    long hi = Math.min(
+        keys.size(),
+        chunk >= offsets.size() - 1 ? keys.size() : offsets.get(chunk + 1))
+        - 1;
     while (lo <= hi) {
       long index = (lo + hi) >>> 1;
       long value = keys.get(index);
@@ -85,4 +97,5 @@ public class LongSizedDataSortedMap<T> implements LongDataMap<T> {
     }
     return null;
   }
+
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongDataSortedMap.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/SortedLongVariableSizeDataMap.java
similarity index 62%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/LongDataSortedMap.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/SortedLongVariableSizeDataMap.java
index b4f1c9c0..03b9194b 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongDataSortedMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/SortedLongVariableSizeDataMap.java
@@ -14,12 +14,15 @@ package org.apache.baremaps.collection;
 
 
 
-import org.apache.baremaps.collection.memory.OffHeapMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
+import org.apache.baremaps.collection.store.DataStore;
+import org.apache.baremaps.collection.store.MemoryAlignedDataStore;
 import org.apache.baremaps.collection.type.LongDataType;
+import org.apache.baremaps.collection.type.PairDataType;
 import org.apache.baremaps.collection.type.PairDataType.Pair;
 
 /**
- * A map of data backed by a {@link AlignedDataList} for storing keys and a {@link DataStore} for
+ * A map of data backed by a {@link DataStore} for storing keys and a {@link AppendOnlyStore} for
  * storing values.
  *
  * <p>
@@ -28,16 +31,33 @@ import org.apache.baremaps.collection.type.PairDataType.Pair;
  * <p>
  * Copyright (c) Planetiler.
  */
-public class LongDataSortedMap<T> implements LongDataMap<T> {
+public class SortedLongVariableSizeDataMap<T> implements LongMap<T> {
 
-  private final AlignedDataList<Long> offsets;
-  private final AlignedDataList<Pair<Long, Long>> keys;
-  private final DataStore<T> values;
+  private final DataStore<Long> offsets;
+  private final DataStore<Pair<Long, Long>> keys;
+  private final AppendOnlyStore<T> values;
 
   private long lastChunk = -1;
 
-  public LongDataSortedMap(AlignedDataList<Pair<Long, Long>> keys, DataStore<T> values) {
-    this.offsets = new AlignedDataList<>(new LongDataType(), new OffHeapMemory());
+  public SortedLongVariableSizeDataMap(AppendOnlyStore<T> values) {
+    this(
+        new MemoryAlignedDataStore<>(new LongDataType()),
+        new MemoryAlignedDataStore<>(new PairDataType<>(new LongDataType(), new LongDataType())),
+        values);
+  }
+
+  public SortedLongVariableSizeDataMap(DataStore<Pair<Long, Long>> keys,
+      AppendOnlyStore<T> values) {
+    this(
+        new MemoryAlignedDataStore<>(new LongDataType()),
+        keys,
+        values);
+  }
+
+
+  public SortedLongVariableSizeDataMap(DataStore<Long> offsets, DataStore<Pair<Long, Long>> keys,
+      AppendOnlyStore<T> values) {
+    this.offsets = offsets;
     this.keys = keys;
     this.values = values;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongSizedDataSparseMap.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/SparseLongFixedSizeDataMap.java
similarity index 87%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/LongSizedDataSparseMap.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/SparseLongFixedSizeDataMap.java
index 5161e5c9..6b7b09e2 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/LongSizedDataSparseMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/SparseLongFixedSizeDataMap.java
@@ -17,9 +17,11 @@ package org.apache.baremaps.collection;
 import it.unimi.dsi.fastutil.bytes.ByteArrayList;
 import it.unimi.dsi.fastutil.longs.LongArrayList;
 import java.util.List;
+import org.apache.baremaps.collection.store.DataStore;
+import org.apache.baremaps.collection.store.FixedSizeDataStore;
 
 /**
- * A sparse map of data backed by a {@link AlignedDataList} for storing values.
+ * A sparse map of data backed by a {@link FixedSizeDataStore} for storing values.
  *
  * <p>
  * This code has been adapted from Planetiler (Apache license).
@@ -27,7 +29,7 @@ import java.util.List;
  * <p>
  * Copyright (c) Planetiler.
  */
-public class LongSizedDataSparseMap<T> implements LongDataMap<T> {
+public class SparseLongFixedSizeDataMap<T> implements LongMap<T> {
 
   // The key space is broken into chunks of 256 and for each chunk, store:
   // 1) the index in the outputs array for the first key in the block
@@ -35,7 +37,7 @@ public class LongSizedDataSparseMap<T> implements LongDataMap<T> {
   // 2) the number of leading 0's at the start of each block
   private final ByteArrayList offsetStartPad;
 
-  private final AlignedDataList<T> values;
+  private final DataStore<T> values;
   private int lastChunk = -1;
   private int lastOffset = 0;
 
@@ -44,7 +46,7 @@ public class LongSizedDataSparseMap<T> implements LongDataMap<T> {
    *
    * @param values the list of values
    */
-  public LongSizedDataSparseMap(AlignedDataList<T> values) {
+  public SparseLongFixedSizeDataMap(DataStore<T> values) {
     this.offsets = new LongArrayList();
     this.offsetStartPad = new ByteArrayList();
     this.values = values;
@@ -55,7 +57,6 @@ public class LongSizedDataSparseMap<T> implements LongDataMap<T> {
     long index = values.size();
     int chunk = (int) (key >>> 8);
     int offset = (int) (key & 255);
-
     if (chunk != lastChunk) {
       // new chunk, store offset and leading zeros
       lastOffset = offset;
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/memory/OnDiskFileMemory.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/memory/MappedMemory.java
similarity index 81%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/memory/OnDiskFileMemory.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/memory/MappedMemory.java
index b1539635..d037d6d0 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/memory/OnDiskFileMemory.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/memory/MappedMemory.java
@@ -20,31 +20,31 @@ import java.nio.channels.FileChannel;
 import java.nio.channels.FileChannel.MapMode;
 import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
-import org.apache.baremaps.collection.StoreException;
+import org.apache.baremaps.collection.store.DataStoreException;
 import org.apache.baremaps.collection.utils.FileUtils;
 import org.apache.baremaps.collection.utils.MappedByteBufferUtils;
 
 /** A memory that stores segments on-disk using mapped byte buffers in a file. */
-public class OnDiskFileMemory extends Memory<MappedByteBuffer> {
+public class MappedMemory extends Memory<MappedByteBuffer> {
 
   private final Path file;
 
   /**
-   * Constructs an {@link OnDiskFileMemory} with a custom file and a default segment size of 1gb.
+   * Constructs an {@link MappedMemory} with a custom file and a default segment size of 1gb.
    *
    * @param file the file that stores the data
    */
-  public OnDiskFileMemory(Path file) {
+  public MappedMemory(Path file) {
     this(file, 1 << 30);
   }
 
   /**
-   * Constructs an {@link OnDiskFileMemory} with a custom file and a custom segment size.
+   * Constructs an {@link MappedMemory} with a custom file and a custom segment size.
    *
    * @param file the file that stores the data
    * @param segmentBytes the size of the segments in bytes
    */
-  public OnDiskFileMemory(Path file, int segmentBytes) {
+  public MappedMemory(Path file, int segmentBytes) {
     super(segmentBytes);
     this.file = file;
   }
@@ -58,7 +58,7 @@ public class OnDiskFileMemory extends Memory<MappedByteBuffer> {
         return channel.map(MapMode.READ_WRITE, (long) index * size, size);
       }
     } catch (IOException e) {
-      throw new StoreException(e);
+      throw new DataStoreException(e);
     }
   }
 
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/memory/OnDiskDirectoryMemory.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/memory/OnDiskDirectoryMemory.java
deleted file mode 100644
index 2ce5208a..00000000
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/memory/OnDiskDirectoryMemory.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.baremaps.collection.memory;
-
-
-
-import java.io.IOException;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileChannel.MapMode;
-import java.nio.file.Path;
-import java.nio.file.StandardOpenOption;
-import org.apache.baremaps.collection.StoreException;
-import org.apache.baremaps.collection.utils.FileUtils;
-import org.apache.baremaps.collection.utils.MappedByteBufferUtils;
-
-/** A memory that stores segments on-disk using mapped byte buffers. */
-public class OnDiskDirectoryMemory extends Memory<MappedByteBuffer> {
-
-  private final Path directory;
-
-  /**
-   * Constructs an {@link OnDiskDirectoryMemory} with a custom directory and a default segment size
-   * of 1gb.
-   *
-   * @param directory the directory that stores the data
-   */
-  public OnDiskDirectoryMemory(Path directory) {
-    this(directory, 1 << 30);
-  }
-
-  /**
-   * Constructs an {@link OnDiskDirectoryMemory} with a custom directory and a custom segment size.
-   *
-   * @param directory the directory that stores the data
-   * @param segmentBytes the size of the segments in bytes
-   */
-  public OnDiskDirectoryMemory(Path directory, int segmentBytes) {
-    super(segmentBytes);
-    this.directory = directory;
-  }
-
-  /** {@inheritDoc} */
-  @Override
-  protected MappedByteBuffer allocate(int index, int size) {
-    try {
-      Path file = directory.resolve(String.format("%s.part", index));
-      try (FileChannel channel = FileChannel.open(file, StandardOpenOption.CREATE,
-          StandardOpenOption.READ, StandardOpenOption.WRITE)) {
-        return channel.map(MapMode.READ_WRITE, 0, size);
-      }
-    } catch (IOException e) {
-      throw new StoreException(e);
-    }
-  }
-
-  /** {@inheritDoc} */
-  @Override
-  public void close() throws IOException {
-    MappedByteBufferUtils.unmap(segments);
-  }
-
-  /** {@inheritDoc} */
-  @Override
-  public void clean() throws IOException {
-    FileUtils.deleteRecursively(directory);
-  }
-}
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/sort/DataStack.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/sort/DataStack.java
index 2bd0684e..66c4aa62 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/sort/DataStack.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/sort/DataStack.java
@@ -15,22 +15,22 @@ package org.apache.baremaps.collection.sort;
 
 
 import java.io.IOException;
-import org.apache.baremaps.collection.DataList;
+import org.apache.baremaps.collection.store.DataStore;
 
 /**
- * A wrapper on top of a {@link DataList} which keeps the last data record in memory.
+ * A wrapper on top of a {@link DataStore} which keeps the last data record in memory.
  *
  * @param <T>
  */
 final class DataStack<T> implements AutoCloseable {
 
-  private DataList<T> list;
+  private DataStore<T> list;
 
   private Long index = 0l;
 
   private T cache;
 
-  public DataStack(DataList<T> list) {
+  public DataStack(DataStore<T> list) {
     this.list = list;
     reload();
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/sort/ExternalMergeSort.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/sort/ExternalMergeSort.java
index 536ae05d..cc7b3732 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/sort/ExternalMergeSort.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/sort/ExternalMergeSort.java
@@ -21,7 +21,7 @@ import java.util.List;
 import java.util.PriorityQueue;
 import java.util.function.Supplier;
 import java.util.stream.Stream;
-import org.apache.baremaps.collection.DataList;
+import org.apache.baremaps.collection.store.DataStore;
 
 /**
  * External merge sort algorithm adapted
@@ -46,8 +46,9 @@ public class ExternalMergeSort {
    * @param parallel The flag indicating if parallelism should be used
    * @throws IOException
    */
-  public static <T> void sort(DataList<T> input, DataList<T> output, final Comparator<T> comparator,
-      Supplier<DataList<T>> tempLists, long batchSize, boolean distinct, boolean parallel)
+  public static <T> void sort(DataStore<T> input, DataStore<T> output,
+      final Comparator<T> comparator,
+      Supplier<DataStore<T>> tempLists, long batchSize, boolean distinct, boolean parallel)
       throws IOException {
     mergeSortedBatches(sortInBatch(input, comparator, tempLists, batchSize, distinct, parallel),
         output, comparator, distinct);
@@ -64,11 +65,11 @@ public class ExternalMergeSort {
    * @return the number of data sorted
    * @throws IOException
    */
-  private static <T> long mergeSortedBatches(List<DataList<T>> batches, DataList<T> output,
+  private static <T> long mergeSortedBatches(List<DataStore<T>> batches, DataStore<T> output,
       Comparator<T> comparator, boolean distinct) throws IOException {
     PriorityQueue<DataStack<T>> queue =
         new PriorityQueue<>(batches.size(), (i, j) -> comparator.compare(i.peek(), j.peek()));
-    for (DataList<T> input : batches) {
+    for (DataStore<T> input : batches) {
       if (input.size() == 0) {
         continue;
       }
@@ -121,8 +122,8 @@ public class ExternalMergeSort {
       }
     }
 
-    for (DataList<T> dataList : batches) {
-      dataList.clean();
+    for (org.apache.baremaps.collection.store.DataStore<T> DataStore : batches) {
+      DataStore.clean();
     }
 
     return counter;
@@ -141,10 +142,10 @@ public class ExternalMergeSort {
    * @return the sorted batches
    * @throws IOException
    */
-  public static <T> List<DataList<T>> sortInBatch(final DataList<T> input,
-      final Comparator<T> comparator, Supplier<DataList<T>> supplier, long batchSize,
+  public static <T> List<DataStore<T>> sortInBatch(final DataStore<T> input,
+      final Comparator<T> comparator, Supplier<DataStore<T>> supplier, long batchSize,
       final boolean distinct, final boolean parallel) throws IOException {
-    List<DataList<T>> lists = new ArrayList<>();
+    List<DataStore<T>> lists = new ArrayList<>();
     List<T> batch = new ArrayList<>();
     long inputIndex = 0;
     while (inputIndex < input.size()) {
@@ -172,9 +173,9 @@ public class ExternalMergeSort {
    * @return the sorted batch
    * @throws IOException
    */
-  public static <T> DataList<T> sortBatch(List<T> batch, Comparator<T> comparator,
-      Supplier<DataList<T>> supplier, boolean distinct, boolean parallel) throws IOException {
-    DataList<T> output = supplier.get();
+  public static <T> DataStore<T> sortBatch(List<T> batch, Comparator<T> comparator,
+      Supplier<DataStore<T>> supplier, boolean distinct, boolean parallel) throws IOException {
+    DataStore<T> output = supplier.get();
     Stream<T> tmpStream = batch.stream().sorted(comparator);
     if (parallel) {
       tmpStream = tmpStream.parallel();
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/DataStore.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/AppendOnlyStore.java
similarity index 82%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/DataStore.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/store/AppendOnlyStore.java
index 8872776a..a4a53b7e 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/DataStore.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/AppendOnlyStore.java
@@ -10,23 +10,25 @@
  * the License.
  */
 
-package org.apache.baremaps.collection;
+package org.apache.baremaps.collection.store;
 
 
 
 import java.io.Closeable;
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.util.Iterator;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
+import org.apache.baremaps.collection.Cleanable;
 import org.apache.baremaps.collection.memory.Memory;
 import org.apache.baremaps.collection.type.DataType;
 
 /**
- * A data store backed by a {@link DataType} and a {@link Memory}. Data is appended to the store and
- * can be accessed by its position in the {@link Memory}.
+ * A data log backed by a {@link DataType} and a {@link Memory}. Elements are appended to the store
+ * and can be accessed by their position in the {@link Memory}.
  */
-public class DataStore<T> implements Closeable, Cleanable {
+public class AppendOnlyStore<T> implements Iterable<T>, Closeable, Cleanable {
 
   private final DataType<T> dataType;
   private final Memory memory;
@@ -42,7 +44,7 @@ public class DataStore<T> implements Closeable, Cleanable {
    * @param dataType the data type
    * @param memory the memory
    */
-  public DataStore(DataType<T> dataType, Memory memory) {
+  public AppendOnlyStore(DataType<T> dataType, Memory memory) {
     this.dataType = dataType;
     this.memory = memory;
     this.segmentSize = memory.segmentSize();
@@ -59,7 +61,7 @@ public class DataStore<T> implements Closeable, Cleanable {
   public long add(T value) {
     int valueSize = dataType.size(value);
     if (valueSize > segmentSize) {
-      throw new StoreException("The value is too big to fit in a segment");
+      throw new DataStoreException("The value is too big to fit in a segment");
     }
 
     lock.lock();
@@ -114,4 +116,12 @@ public class DataStore<T> implements Closeable, Cleanable {
   public void close() throws IOException {
     memory.close();
   }
+
+  @Override
+  public Iterator<T> iterator() {
+    long offset = 0;
+
+
+    return null;
+  }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataStore.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataStore.java
new file mode 100644
index 00000000..949b00ca
--- /dev/null
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataStore.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.baremaps.collection.store;
+
+
+
+import java.io.Closeable;
+import java.util.Iterator;
+import org.apache.baremaps.collection.Cleanable;
+
+public interface DataStore<T> extends Iterable<T>, Closeable, Cleanable {
+
+  long add(T value);
+
+  void set(long index, T value);
+
+  T get(long index);
+
+  long size();
+
+  @Override
+  default Iterator<T> iterator() {
+    final long size = size();
+    return new Iterator<T>() {
+
+      private long index = 0;
+
+      @Override
+      public boolean hasNext() {
+        return index < size;
+      }
+
+      @Override
+      public T next() {
+        return get(index++);
+      }
+    };
+  }
+
+}
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/StoreException.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataStoreException.java
similarity index 80%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/StoreException.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataStoreException.java
index 14108bd9..0b307bc1 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/StoreException.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataStoreException.java
@@ -10,19 +10,19 @@
  * the License.
  */
 
-package org.apache.baremaps.collection;
+package org.apache.baremaps.collection.store;
 
 /** Signals that an exception occurred in a store. */
-public class StoreException extends RuntimeException {
+public class DataStoreException extends RuntimeException {
   /** Constructs a {@code BlobStoreException} with {@code null} as its error detail message. */
-  public StoreException() {}
+  public DataStoreException() {}
 
   /**
    * Constructs an {@code StoreException} with the specified detail message.
    *
    * @param message the message
    */
-  public StoreException(String message) {
+  public DataStoreException(String message) {
     super(message);
   }
 
@@ -31,7 +31,7 @@ public class StoreException extends RuntimeException {
    *
    * @param cause the cause
    */
-  public StoreException(Throwable cause) {
+  public DataStoreException(Throwable cause) {
     super(cause);
   }
 
@@ -41,7 +41,7 @@ public class StoreException extends RuntimeException {
    * @param message the message
    * @param cause the cause
    */
-  public StoreException(String message, Throwable cause) {
+  public DataStoreException(String message, Throwable cause) {
     super(message, cause);
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/SizedDataList.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/FixedSizeDataStore.java
similarity index 72%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/SizedDataList.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/store/FixedSizeDataStore.java
index f0cdf6f9..e642f43a 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/SizedDataList.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/FixedSizeDataStore.java
@@ -10,30 +10,21 @@
  * the License.
  */
 
-package org.apache.baremaps.collection;
+package org.apache.baremaps.collection.store;
 
 
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.atomic.AtomicLong;
+import org.apache.baremaps.collection.Cleanable;
 import org.apache.baremaps.collection.memory.Memory;
-import org.apache.baremaps.collection.type.SizedDataType;
+import org.apache.baremaps.collection.type.FixedSizeDataType;
 
-/**
- * A list of data backed by a {@link SizedDataType} and a {@link Memory}.
- *
- * <p>
- * This code has been adapted from Planetiler (Apache license).
- *
- * <p>
- * Copyright (c) Planetiler.
- *
- * @param <T>
- */
-public class SizedDataList<T> implements DataList<T> {
+public class FixedSizeDataStore<T> implements DataStore<T>, Closeable, Cleanable {
 
-  private final SizedDataType<T> dataType;
+  private final FixedSizeDataType<T> dataType;
 
   private final Memory memory;
 
@@ -45,9 +36,9 @@ public class SizedDataList<T> implements DataList<T> {
    * @param dataType the data type
    * @param memory the memory
    */
-  public SizedDataList(SizedDataType<T> dataType, Memory memory) {
+  public FixedSizeDataStore(FixedSizeDataType<T> dataType, Memory memory) {
     if (dataType.size() > memory.segmentSize()) {
-      throw new StoreException("The segment size is too small for the data type");
+      throw new DataStoreException("The segment size is too small for the data type");
     }
     this.dataType = dataType;
     this.memory = memory;
@@ -62,7 +53,10 @@ public class SizedDataList<T> implements DataList<T> {
     dataType.write(segment, segmentOffset, value);
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
+  @Override
   public long add(T value) {
     long index = size.getAndIncrement();
     write(index, value);
@@ -70,14 +64,17 @@ public class SizedDataList<T> implements DataList<T> {
   }
 
   @Override
-  public void add(long index, T value) {
+  public void set(long index, T value) {
     if (index >= size.get()) {
       throw new IndexOutOfBoundsException();
     }
     write(index, value);
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
+  @Override
   public T get(long index) {
     long position = index * dataType.size();
     int segmentIndex = (int) (position / dataType.size());
@@ -86,25 +83,25 @@ public class SizedDataList<T> implements DataList<T> {
     return dataType.read(segment, segmentOffset);
   }
 
+  /**
+   * {@inheritDoc}
+   */
   @Override
-  public T remove(long index) {
-    T value = get(index);
-    add(index, null);
-    return value;
-  }
-
-  /** {@inheritDoc} */
   public long size() {
     return size.get();
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public void close() throws IOException {
     memory.close();
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public void clean() throws IOException {
     memory.clean();
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/IndexedDataList.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/IndexedDataStore.java
similarity index 58%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/IndexedDataList.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/store/IndexedDataStore.java
index d7c838f1..f570d51c 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/IndexedDataList.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/IndexedDataStore.java
@@ -10,43 +10,39 @@
  * the License.
  */
 
-package org.apache.baremaps.collection;
+package org.apache.baremaps.collection.store;
 
 
 
 import java.io.IOException;
 
-public class IndexedDataList<T> implements DataList<T> {
+public class IndexedDataStore<T> implements DataStore<T> {
 
-  private final LongList index;
+  private final MemoryAlignedDataStore<Long> index;
 
-  private final DataStore<T> store;
+  private final AppendOnlyStore<T> values;
 
-  public IndexedDataList(LongList index, DataStore<T> store) {
+  public IndexedDataStore(MemoryAlignedDataStore<Long> index, AppendOnlyStore<T> values) {
     this.index = index;
-    this.store = store;
+    this.values = values;
   }
 
   @Override
   public long add(T value) {
-    return index.add(store.add(value));
+    long position = values.add(value);
+    return index.add(position);
   }
 
   @Override
-  public void add(long idx, T value) {
-    index.add(idx, store.add(value));
+  public void set(long index, T value) {
+    long position = values.add(value);
+    this.index.set(index, position);
   }
 
   @Override
-  public T get(long idx) {
-    return store.get(index.get(idx));
-  }
-
-  @Override
-  public T remove(long idx) {
-    T value = get(idx);
-    index.remove(idx);
-    return value;
+  public T get(long index) {
+    long position = this.index.get(index);
+    return values.get(position);
   }
 
   @Override
@@ -57,12 +53,11 @@ public class IndexedDataList<T> implements DataList<T> {
   @Override
   public void close() throws IOException {
     index.close();
-    store.close();
+    values.close();
   }
 
   @Override
   public void clean() throws IOException {
-    index.clean();
-    store.clean();
+
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/AlignedDataList.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/MemoryAlignedDataStore.java
similarity index 70%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/AlignedDataList.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/store/MemoryAlignedDataStore.java
index aba40eb0..3b8ec67e 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/AlignedDataList.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/MemoryAlignedDataStore.java
@@ -10,31 +10,22 @@
  * the License.
  */
 
-package org.apache.baremaps.collection;
+package org.apache.baremaps.collection.store;
 
 
 
-import it.unimi.dsi.fastutil.longs.LongArrayList;
+import java.io.Closeable;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.atomic.AtomicLong;
+import org.apache.baremaps.collection.Cleanable;
 import org.apache.baremaps.collection.memory.Memory;
-import org.apache.baremaps.collection.type.SizedDataType;
+import org.apache.baremaps.collection.memory.OffHeapMemory;
+import org.apache.baremaps.collection.type.FixedSizeDataType;
 
-/**
- * A list of data backed by a {@link SizedDataType} and a {@link Memory}.
- *
- * <p>
- * This code has been adapted from Planetiler (Apache license).
- *
- * <p>
- * Copyright (c) Planetiler.
- *
- * @param <T>
- */
-public class AlignedDataList<T> implements DataList<T> {
+public class MemoryAlignedDataStore<T> implements DataStore<T>, Closeable, Cleanable {
 
-  private final SizedDataType<T> dataType;
+  private final FixedSizeDataType<T> dataType;
 
   private final Memory memory;
 
@@ -46,19 +37,33 @@ public class AlignedDataList<T> implements DataList<T> {
 
   private AtomicLong size;
 
+
   /**
    * Constructs a list.
    *
    * @param dataType the data type
    * @param memory the memory
    */
-  public AlignedDataList(SizedDataType<T> dataType, Memory memory) {
-    new LongArrayList();
+  public MemoryAlignedDataStore(FixedSizeDataType<T> dataType) {
+    this(dataType, new OffHeapMemory());
+  }
+
+
+  /**
+   * Constructs a list.
+   *
+   * @param dataType the data type
+   * @param memory the memory
+   */
+  public MemoryAlignedDataStore(FixedSizeDataType<T> dataType, Memory memory) {
     if (dataType.size() > memory.segmentSize()) {
-      throw new StoreException("The segment size is too small for the data type");
+      throw new DataStoreException("The segment size is too small for the data type");
+    }
+    if ((dataType.size() & -dataType.size()) != dataType.size()) {
+      throw new IllegalArgumentException("The data type size must be a fixed power of 2");
     }
     if (memory.segmentSize() % dataType.size() != 0) {
-      throw new StoreException("The segment size and data type size must be aligned");
+      throw new DataStoreException("The segment size and data type size must be aligned");
     }
     this.dataType = dataType;
     this.memory = memory;
@@ -83,8 +88,7 @@ public class AlignedDataList<T> implements DataList<T> {
     return index;
   }
 
-  @Override
-  public void add(long index, T value) {
+  public void set(long index, T value) {
     if (index >= size.get()) {
       throw new IndexOutOfBoundsException();
     }
@@ -100,13 +104,6 @@ public class AlignedDataList<T> implements DataList<T> {
     return dataType.read(segment, segmentOffset);
   }
 
-  @Override
-  public T remove(long index) {
-    T value = get(index);
-    write(index, null);
-    return value;
-  }
-
   /** {@inheritDoc} */
   public long size() {
     return size.get();
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ByteDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ByteDataType.java
index 6aa9b995..868d6cda 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ByteDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ByteDataType.java
@@ -17,12 +17,10 @@ package org.apache.baremaps.collection.type;
 import java.nio.ByteBuffer;
 
 /** A {@link DataType} for reading and writing bytes in {@link ByteBuffer}s. */
-public class ByteDataType implements SizedDataType<Byte> {
+public class ByteDataType extends MemoryAlignedDataType<Byte> {
 
-  /** {@inheritDoc} */
-  @Override
-  public int size(Byte value) {
-    return 1;
+  public ByteDataType() {
+    super(Byte.BYTES);
   }
 
   /** {@inheritDoc} */
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ByteListDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ByteListDataType.java
index d2f0077a..d1acb496 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ByteListDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ByteListDataType.java
@@ -18,35 +18,46 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
 
-/** A {@link DataType} for reading and writing lists of bytes in {@link ByteBuffer}s. */
+/**
+ * A {@link DataType} for reading and writing lists of bytes in {@link ByteBuffer}s.
+ */
 public class ByteListDataType implements DataType<List<Byte>> {
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public int size(List<Byte> values) {
-    return 4 + values.size();
+    return Integer.BYTES + values.size() * Byte.BYTES;
+  }
+
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return buffer.getInt(position);
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public void write(ByteBuffer buffer, int position, List<Byte> values) {
-    buffer.putInt(position, values.size());
-    position += 4;
+    buffer.putInt(position, size(values));
+    position += Integer.BYTES;
     for (Byte value : values) {
       buffer.put(position, value);
-      position++;
+      position += Byte.BYTES;
     }
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public List<Byte> read(ByteBuffer buffer, int position) {
     int size = buffer.getInt(position);
-    position += 4;
-    List<Byte> list = new ArrayList<>(size);
-    for (int i = 0; i < size; i++) {
-      list.add(buffer.get(position));
-      position++;
+    var list = new ArrayList<Byte>(size);
+    for (var p = position + Integer.BYTES; p < position + size; p += Byte.BYTES) {
+      list.add(buffer.get(p));
     }
     return list;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/CoordinateDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/CoordinateDataType.java
index 277df60b..bd33894e 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/CoordinateDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/CoordinateDataType.java
@@ -18,26 +18,24 @@ import java.nio.ByteBuffer;
 import org.locationtech.jts.geom.Coordinate;
 
 /** A {@link DataType} for reading and writing {@link Coordinate}s in {@link ByteBuffer}s. */
-public class CoordinateDataType implements SizedDataType<Coordinate> {
+public class CoordinateDataType extends MemoryAlignedDataType<Coordinate> {
 
-  /** {@inheritDoc} */
-  @Override
-  public int size(Coordinate value) {
-    return 16;
+  public CoordinateDataType() {
+    super(Double.BYTES * 2);
   }
 
   /** {@inheritDoc} */
   @Override
   public void write(ByteBuffer buffer, int position, Coordinate value) {
     buffer.putDouble(position, value.x);
-    buffer.putDouble(position + 8, value.y);
+    buffer.putDouble(position + Double.BYTES, value.y);
   }
 
   /** {@inheritDoc} */
   @Override
   public Coordinate read(ByteBuffer buffer, int position) {
     double x = buffer.getDouble(position);
-    double y = buffer.getDouble(position + 8);
+    double y = buffer.getDouble(position + Double.BYTES);
     return new Coordinate(x, y);
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DataType.java
index 58c32883..f672181d 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DataType.java
@@ -25,13 +25,15 @@ import java.nio.ByteBuffer;
 public interface DataType<T> {
 
   /**
-   * Returns the size of the value in memory.
+   * Returns the size of the value.
    *
    * @param value the value
-   * @return the size of the value in memory.
+   * @return the size of the value
    */
   int size(T value);
 
+  int size(ByteBuffer buffer, int position);
+
   /**
    * Write a value.
    *
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleDataType.java
index f21210bb..a0319fe3 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleDataType.java
@@ -17,12 +17,10 @@ package org.apache.baremaps.collection.type;
 import java.nio.ByteBuffer;
 
 /** A {@link DataType} for reading and writing doubles in {@link ByteBuffer}s. */
-public class DoubleDataType implements SizedDataType<Double> {
+public class DoubleDataType extends MemoryAlignedDataType<Double> {
 
-  /** {@inheritDoc} */
-  @Override
-  public int size(Double value) {
-    return 8;
+  public DoubleDataType() {
+    super(Double.BYTES);
   }
 
   /** {@inheritDoc} */
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleListDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleListDataType.java
index 1bcdf618..7dbf1fb4 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleListDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/DoubleListDataType.java
@@ -24,29 +24,32 @@ public class DoubleListDataType implements DataType<List<Double>> {
   /** {@inheritDoc} */
   @Override
   public int size(List<Double> values) {
-    return 4 + values.size() * 8;
+    return Integer.BYTES + values.size() * Double.BYTES;
+  }
+
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return buffer.getInt(position);
   }
 
   /** {@inheritDoc} */
   @Override
   public void write(ByteBuffer buffer, int position, List<Double> values) {
-    buffer.putInt(position, values.size());
-    position += 4;
+    buffer.putInt(position, size(values));
+    position += Integer.BYTES;
     for (Double value : values) {
       buffer.putDouble(position, value);
-      position += 8;
+      position += Double.BYTES;
     }
   }
 
   /** {@inheritDoc} */
   @Override
   public List<Double> read(ByteBuffer buffer, int position) {
-    int size = buffer.getInt(position);
-    position += 4;
-    List<Double> list = new ArrayList<>(size);
-    for (int i = 0; i < size; i++) {
-      list.add(buffer.getDouble(position));
-      position += 8;
+    var size = buffer.getInt(position);
+    var list = new ArrayList<Double>(size);
+    for (var p = position + Integer.BYTES; p < position + size; p += Double.BYTES) {
+      list.add(buffer.getDouble(p));
     }
     return list;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SizedDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FixedSizeDataType.java
similarity index 54%
copy from baremaps-core/src/main/java/org/apache/baremaps/collection/type/SizedDataType.java
copy to baremaps-core/src/main/java/org/apache/baremaps/collection/type/FixedSizeDataType.java
index 360b8024..0daf0fc1 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SizedDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FixedSizeDataType.java
@@ -21,14 +21,43 @@ import java.nio.ByteBuffer;
  *
  * @param <T>
  */
-public interface SizedDataType<T> extends DataType<T> {
+public abstract class FixedSizeDataType<T> implements DataType<T> {
+
+  private final int size;
+
+  public FixedSizeDataType(int size) {
+    this.size = size;
+  }
+
+  /**
+   * Returns the size of the value.
+   *
+   * @param value the value
+   * @return the size of the value
+   */
+  @Override
+  public int size(T value) {
+    return size;
+  }
+
+  /**
+   * Returns the size of the value at the given position in the buffer.
+   *
+   * @param buffer the buffer
+   * @param position the position
+   * @return the size of the value
+   */
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return size;
+  }
 
   /**
    * Returns the size of the data type.
    *
-   * @return the size of the data type.
+   * @return the size of the data type
    */
-  default int size() {
-    return size(null);
+  public int size() {
+    return size;
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FloatDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FloatDataType.java
index 6644035c..64f8a2db 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FloatDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FloatDataType.java
@@ -16,22 +16,26 @@ package org.apache.baremaps.collection.type;
 
 import java.nio.ByteBuffer;
 
-/** A {@link DataType} for reading and writing floats in {@link ByteBuffer}s. */
-public class FloatDataType implements SizedDataType<Float> {
+/**
+ * A {@link DataType} for reading and writing floats in {@link ByteBuffer}s.
+ */
+public class FloatDataType extends MemoryAlignedDataType<Float> {
 
-  /** {@inheritDoc} */
-  @Override
-  public int size(Float value) {
-    return 4;
+  public FloatDataType() {
+    super(Float.BYTES);
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public void write(ByteBuffer buffer, int position, Float value) {
     buffer.putFloat(position, value);
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public Float read(ByteBuffer buffer, int position) {
     return buffer.getFloat(position);
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FloatListDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FloatListDataType.java
index feffd643..af079eb8 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FloatListDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/FloatListDataType.java
@@ -24,17 +24,22 @@ public class FloatListDataType implements DataType<List<Float>> {
   /** {@inheritDoc} */
   @Override
   public int size(List<Float> values) {
-    return 4 + values.size() * 4;
+    return Integer.BYTES + values.size() * Float.BYTES;
+  }
+
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return buffer.getInt(position);
   }
 
   /** {@inheritDoc} */
   @Override
   public void write(ByteBuffer buffer, int position, List<Float> values) {
-    buffer.putInt(position, values.size());
-    position += 4;
+    buffer.putInt(position, size(values));
+    position += Integer.BYTES;
     for (Float value : values) {
       buffer.putFloat(position, value);
-      position += 4;
+      position += Float.BYTES;
     }
   }
 
@@ -42,11 +47,9 @@ public class FloatListDataType implements DataType<List<Float>> {
   @Override
   public List<Float> read(ByteBuffer buffer, int position) {
     int size = buffer.getInt(position);
-    position += 4;
     List<Float> list = new ArrayList<>(size);
-    for (int i = 0; i < size; i++) {
-      list.add(buffer.getFloat(position));
-      position += 4;
+    for (var p = position + Integer.BYTES; p < position + size; p += Float.BYTES) {
+      list.add(buffer.getFloat(p));
     }
     return list;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/GeometryDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/GeometryDataType.java
index 4227eb37..81002f20 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/GeometryDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/GeometryDataType.java
@@ -22,21 +22,26 @@ public class GeometryDataType implements DataType<Geometry> {
 
   @Override
   public int size(Geometry value) {
-    return 4 + GeometryUtils.serialize(value).length;
+    return Integer.BYTES + GeometryUtils.serialize(value).length;
+  }
+
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return buffer.getInt(position);
   }
 
   @Override
   public void write(ByteBuffer buffer, int position, Geometry value) {
     byte[] bytes = GeometryUtils.serialize(value);
-    buffer.putInt(position, bytes.length);
-    buffer.put(position + 4, bytes);
+    buffer.putInt(position, Integer.BYTES + bytes.length);
+    buffer.put(position + Integer.BYTES, bytes);
   }
 
   @Override
   public Geometry read(ByteBuffer buffer, int position) {
-    int length = buffer.getInt(position);
-    byte[] bytes = new byte[length];
-    buffer.get(position + 4, bytes);
+    int size = size(buffer, position);
+    byte[] bytes = new byte[size - Integer.BYTES];
+    buffer.get(position + Integer.BYTES, bytes);
     return GeometryUtils.deserialize(bytes);
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/IntegerDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/IntegerDataType.java
index 4bbb9574..0b183ec1 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/IntegerDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/IntegerDataType.java
@@ -16,22 +16,26 @@ package org.apache.baremaps.collection.type;
 
 import java.nio.ByteBuffer;
 
-/** A {@link DataType} for reading and writing integers in {@link ByteBuffer}s. */
-public class IntegerDataType implements SizedDataType<Integer> {
+/**
+ * A {@link DataType} for reading and writing integers in {@link ByteBuffer}s.
+ */
+public class IntegerDataType extends MemoryAlignedDataType<Integer> {
 
-  /** {@inheritDoc} */
-  @Override
-  public int size(Integer value) {
-    return 4;
+  public IntegerDataType() {
+    super(Integer.BYTES);
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public void write(ByteBuffer buffer, int position, Integer value) {
     buffer.putInt(position, value);
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public Integer read(ByteBuffer buffer, int position) {
     return buffer.getInt(position);
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/IntegerListDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/IntegerListDataType.java
index c887b8d8..19aa1cf9 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/IntegerListDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/IntegerListDataType.java
@@ -24,29 +24,32 @@ public class IntegerListDataType implements DataType<List<Integer>> {
   /** {@inheritDoc} */
   @Override
   public int size(List<Integer> values) {
-    return 4 + values.size() * 4;
+    return Integer.BYTES + values.size() * Integer.BYTES;
+  }
+
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return buffer.getInt(position);
   }
 
   /** {@inheritDoc} */
   @Override
   public void write(ByteBuffer buffer, int position, List<Integer> values) {
-    buffer.putInt(position, values.size());
-    position += 4;
+    buffer.putInt(position, size(values));
+    position += Integer.BYTES;
     for (Integer value : values) {
       buffer.putInt(position, value);
-      position += 4;
+      position += Integer.BYTES;
     }
   }
 
   /** {@inheritDoc} */
   @Override
   public List<Integer> read(ByteBuffer buffer, int position) {
-    int size = buffer.getInt(position);
-    position += 4;
-    List<Integer> list = new ArrayList<>(size);
-    for (int i = 0; i < size; i++) {
-      list.add(buffer.getInt(position));
-      position += 4;
+    var size = size(buffer, position);
+    var list = new ArrayList<Integer>();
+    for (var p = position + Integer.BYTES; p < position + size; p += Integer.BYTES) {
+      list.add(buffer.getInt(p));
     }
     return list;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ListDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ListDataType.java
index 29527c15..ee0cf929 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ListDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ListDataType.java
@@ -18,7 +18,9 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
 
-/** A {@link DataType} for reading and writing lists of objects in {@link ByteBuffer}s. */
+/**
+ * A {@link DataType} for reading and writing lists of objects in {@link ByteBuffer}s.
+ */
 public class ListDataType<T> implements DataType<List<T>> {
 
   public final DataType<T> dataType;
@@ -27,36 +29,44 @@ public class ListDataType<T> implements DataType<List<T>> {
     this.dataType = dataType;
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public int size(List<T> values) {
-    int size = 4;
+    int size = Integer.BYTES;
     for (T value : values) {
       size += dataType.size(value);
     }
     return size;
   }
 
-  /** {@inheritDoc} */
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return buffer.getInt(position);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public void write(ByteBuffer buffer, int position, List<T> values) {
-    buffer.putInt(position, values.size());
+    buffer.putInt(position, size(values));
     for (T value : values) {
       position += dataType.size(value);
       dataType.write(buffer, position, value);
     }
   }
 
-  /** {@inheritDoc} */
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public List<T> read(ByteBuffer buffer, int position) {
-    int size = buffer.getInt(position);
-    position += 4;
-    List<T> list = new ArrayList<>(size);
-    for (int i = 0; i < size; i++) {
-      T value = dataType.read(buffer, position);
-      position += dataType.size(value);
-      list.add(value);
+    var size = buffer.getInt(position);
+    var list = new ArrayList<T>(size);
+    for (var p = position + Integer.BYTES; p < position + size; p += dataType.size(buffer, p)) {
+      list.add(dataType.read(buffer, p));
     }
     return list;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LonLatDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LonLatDataType.java
index 0e2d4597..19401c12 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LonLatDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LonLatDataType.java
@@ -21,12 +21,16 @@ import org.locationtech.jts.geom.Coordinate;
  * A {@link DataType} for reading and writing longitude/latitude coordinates in {@link ByteBuffer}s.
  * An integer is used to compress the coordinates to the detriment of precision (centimeters).
  */
-public class LonLatDataType implements SizedDataType<Coordinate> {
+public class LonLatDataType extends MemoryAlignedDataType<Coordinate> {
 
   private static final double BITS = Math.pow(2, 31);
   private static final long SHIFT = 32;
   private static final long MASK = (1L << 32) - 1L;
 
+  public LonLatDataType() {
+    super(Long.BYTES);
+  }
+
   public static long encodeLonLat(double lon, double lat) {
     long x = (long) (((lon + 180) / 360) * BITS);
     long y = (long) (((lat + 90) / 180) * BITS);
@@ -45,12 +49,6 @@ public class LonLatDataType implements SizedDataType<Coordinate> {
     return (r / BITS) * 180 - 90;
   }
 
-  /** {@inheritDoc} */
-  @Override
-  public int size(Coordinate value) {
-    return 8;
-  }
-
   /** {@inheritDoc} */
   @Override
   public void write(ByteBuffer buffer, int position, Coordinate value) {
@@ -60,7 +58,7 @@ public class LonLatDataType implements SizedDataType<Coordinate> {
   /** {@inheritDoc} */
   @Override
   public Coordinate read(ByteBuffer buffer, int position) {
-    long value = buffer.getLong(position);
+    var value = buffer.getLong(position);
     return new Coordinate(decodeLon(value), decodeLat(value));
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LongDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LongDataType.java
index 011829a1..80b2c480 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LongDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LongDataType.java
@@ -17,12 +17,10 @@ package org.apache.baremaps.collection.type;
 import java.nio.ByteBuffer;
 
 /** A {@link DataType} for reading and writing longs in {@link ByteBuffer}s. */
-public class LongDataType implements SizedDataType<Long> {
+public class LongDataType extends MemoryAlignedDataType<Long> {
 
-  /** {@inheritDoc} */
-  @Override
-  public int size(Long value) {
-    return 8;
+  public LongDataType() {
+    super(Long.BYTES);
   }
 
   /** {@inheritDoc} */
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LongListDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LongListDataType.java
index aac8cf39..a46400a8 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LongListDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/LongListDataType.java
@@ -27,10 +27,15 @@ public class LongListDataType implements DataType<List<Long>> {
     return Integer.BYTES + values.size() * Long.BYTES;
   }
 
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return buffer.getInt(position);
+  }
+
   /** {@inheritDoc} */
   @Override
   public void write(ByteBuffer buffer, int position, List<Long> values) {
-    buffer.putInt(position, values.size());
+    buffer.putInt(position, size(values));
     position += Integer.BYTES;
     for (Long value : values) {
       buffer.putLong(position, value);
@@ -41,12 +46,10 @@ public class LongListDataType implements DataType<List<Long>> {
   /** {@inheritDoc} */
   @Override
   public List<Long> read(ByteBuffer buffer, int position) {
-    int size = buffer.getInt(position);
-    position += Integer.BYTES;
-    List<Long> list = new ArrayList<>(size);
-    for (int i = 0; i < size; i++) {
-      list.add(buffer.getLong(position));
-      position += Long.BYTES;
+    var size = buffer.getInt(position);
+    var list = new ArrayList<Long>(size);
+    for (var p = position + Integer.BYTES; p < position + size; p += Long.BYTES) {
+      list.add(buffer.getLong(p));
     }
     return list;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SizedDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/MemoryAlignedDataType.java
similarity index 70%
rename from baremaps-core/src/main/java/org/apache/baremaps/collection/type/SizedDataType.java
rename to baremaps-core/src/main/java/org/apache/baremaps/collection/type/MemoryAlignedDataType.java
index 360b8024..fbcb907a 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SizedDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/MemoryAlignedDataType.java
@@ -17,18 +17,17 @@ package org.apache.baremaps.collection.type;
 import java.nio.ByteBuffer;
 
 /**
- * A {@link DataType} for reading and writing values in {@link ByteBuffer}s whose size is fixed.
+ * A {@link DataType} for reading and writing values in {@link ByteBuffer}s whose size is memory
+ * aligned.
  *
  * @param <T>
  */
-public interface SizedDataType<T> extends DataType<T> {
+public abstract class MemoryAlignedDataType<T> extends FixedSizeDataType<T> {
 
-  /**
-   * Returns the size of the data type.
-   *
-   * @return the size of the data type.
-   */
-  default int size() {
-    return size(null);
+  public MemoryAlignedDataType(int size) {
+    super(size);
+    if ((size & -size) != size) {
+      throw new IllegalArgumentException("The size must be a power of 2");
+    }
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/NullableDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/NullableDataType.java
index 343dcfda..2df6fee1 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/NullableDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/NullableDataType.java
@@ -26,7 +26,12 @@ public class NullableDataType<T> implements DataType<T> {
 
   @Override
   public int size(T value) {
-    return 1 + dataType.size(value);
+    return Byte.BYTES + dataType.size(value);
+  }
+
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return Byte.BYTES + dataType.size(buffer, position + 1);
   }
 
   @Override
@@ -35,7 +40,7 @@ public class NullableDataType<T> implements DataType<T> {
       buffer.put(position, (byte) 0);
     } else {
       buffer.put(position, (byte) 1);
-      dataType.write(buffer, position + 1, value);
+      dataType.write(buffer, position + Byte.BYTES, value);
     }
   }
 
@@ -44,7 +49,7 @@ public class NullableDataType<T> implements DataType<T> {
     if (buffer.get(position) == 0) {
       return null;
     } else {
-      return dataType.read(buffer, position + 1);
+      return dataType.read(buffer, position + Byte.BYTES);
     }
   }
 }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/PairDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/PairDataType.java
index 019a61d1..56c83a54 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/PairDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/PairDataType.java
@@ -19,12 +19,13 @@ import java.util.Objects;
 import org.apache.baremaps.collection.type.PairDataType.Pair;
 
 /** A {@link DataType} for reading and writing pairs of values in {@link ByteBuffer}s. */
-public class PairDataType<L, R> implements SizedDataType<Pair<L, R>> {
+public class PairDataType<L, R> extends FixedSizeDataType<Pair<L, R>> {
 
-  private final SizedDataType<L> left;
-  private final SizedDataType<R> right;
+  private final FixedSizeDataType<L> left;
+  private final FixedSizeDataType<R> right;
 
-  public PairDataType(SizedDataType<L> left, SizedDataType<R> right) {
+  public PairDataType(FixedSizeDataType<L> left, FixedSizeDataType<R> right) {
+    super(left.size() + right.size());
     this.left = left;
     this.right = right;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ShortDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ShortDataType.java
index f3346d7f..5fb34e67 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ShortDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ShortDataType.java
@@ -17,12 +17,10 @@ package org.apache.baremaps.collection.type;
 import java.nio.ByteBuffer;
 
 /** A {@link DataType} for reading and writing shorts in {@link ByteBuffer}s. */
-public class ShortDataType implements SizedDataType<Short> {
+public class ShortDataType extends FixedSizeDataType<Short> {
 
-  /** {@inheritDoc} */
-  @Override
-  public int size(Short value) {
-    return 2;
+  public ShortDataType() {
+    super(Short.BYTES);
   }
 
   /** {@inheritDoc} */
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ShortListDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ShortListDataType.java
index 33b4bfa4..4c559b94 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ShortListDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/ShortListDataType.java
@@ -24,29 +24,32 @@ public class ShortListDataType implements DataType<List<Short>> {
   /** {@inheritDoc} */
   @Override
   public int size(List<Short> values) {
-    return 4 + values.size() * 2;
+    return Integer.BYTES + values.size() * Short.BYTES;
+  }
+
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return buffer.getInt(position);
   }
 
   /** {@inheritDoc} */
   @Override
   public void write(ByteBuffer buffer, int position, List<Short> values) {
-    buffer.putInt(position, values.size());
-    position += 4;
+    buffer.putInt(position, size(values));
+    position += Integer.BYTES;
     for (Short value : values) {
       buffer.putShort(position, value);
-      position += 2;
+      position += Short.BYTES;
     }
   }
 
   /** {@inheritDoc} */
   @Override
   public List<Short> read(ByteBuffer buffer, int position) {
-    int size = buffer.getInt(position);
-    position += 4;
-    List<Short> list = new ArrayList<>(size);
-    for (int i = 0; i < size; i++) {
-      list.add(buffer.getShort(position));
-      position += 2;
+    var size = buffer.getInt(position);
+    var list = new ArrayList<Short>(size);
+    for (var p = position + Integer.BYTES; p < position + size; p += Short.BYTES) {
+      list.add(buffer.getShort(p));
     }
     return list;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SmallIntegerDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SmallIntegerDataType.java
index d5a2ce1d..e65c64e9 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SmallIntegerDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SmallIntegerDataType.java
@@ -17,7 +17,7 @@ package org.apache.baremaps.collection.type;
 import java.nio.ByteBuffer;
 
 /** A {@link DataType} for reading and writing small integers in {@link ByteBuffer}s. */
-public class SmallIntegerDataType implements SizedDataType<Integer> {
+public class SmallIntegerDataType extends FixedSizeDataType<Integer> {
 
   private final int n;
 
@@ -27,6 +27,7 @@ public class SmallIntegerDataType implements SizedDataType<Integer> {
    * @param n the number of bytes used to store the integer
    */
   public SmallIntegerDataType(int n) {
+    super(n);
     if (n < 1 || n > 4) {
       throw new IllegalArgumentException(
           "The number of bytes used to store small integers must be comprised between 1 and 4");
@@ -34,12 +35,6 @@ public class SmallIntegerDataType implements SizedDataType<Integer> {
     this.n = n;
   }
 
-  /** {@inheritDoc} */
-  @Override
-  public int size(Integer value) {
-    return n;
-  }
-
   /** {@inheritDoc} */
   @Override
   public void write(ByteBuffer buffer, int position, Integer value) {
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SmallLongDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SmallLongDataType.java
index 10c80a4d..a78602ab 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SmallLongDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/SmallLongDataType.java
@@ -17,7 +17,7 @@ package org.apache.baremaps.collection.type;
 import java.nio.ByteBuffer;
 
 /** A {@link DataType} for reading and writing small longs in {@link ByteBuffer}s. */
-public class SmallLongDataType implements SizedDataType<Long> {
+public class SmallLongDataType extends FixedSizeDataType<Long> {
 
   private final int n;
 
@@ -27,6 +27,7 @@ public class SmallLongDataType implements SizedDataType<Long> {
    * @param n the number of bytes used to store the integer
    */
   public SmallLongDataType(int n) {
+    super(n);
     if (n < 1 || n > 8) {
       throw new IllegalArgumentException(
           "The number of bytes used to store small longs must be comprised between 1 and 8");
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/StringDataType.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/StringDataType.java
index daa355a8..b8c7310f 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/StringDataType.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/StringDataType.java
@@ -21,24 +21,29 @@ public class StringDataType implements DataType<String> {
 
   @Override
   public int size(String value) {
-    return 8 + value.getBytes(StandardCharsets.UTF_8).length;
+    return Integer.BYTES + value.getBytes(StandardCharsets.UTF_8).length;
+  }
+
+  @Override
+  public int size(ByteBuffer buffer, int position) {
+    return buffer.getInt(position);
   }
 
   @Override
   public void write(ByteBuffer buffer, int position, String value) {
     var bytes = value.getBytes(StandardCharsets.UTF_8);
-    buffer.putInt(position, bytes.length);
+    buffer.putInt(position, size(value));
     for (int i = 0; i < bytes.length; i++) {
-      buffer.put(position + 8 + i, bytes[i]);
+      buffer.put(position + Integer.BYTES + i, bytes[i]);
     }
   }
 
   @Override
   public String read(ByteBuffer buffer, int position) {
-    var length = buffer.getInt(position);
-    var bytes = new byte[length];
+    var size = size(buffer, position);
+    var bytes = new byte[size - Integer.BYTES];
     for (int i = 0; i < bytes.length; i++) {
-      bytes[i] = buffer.get(position + 8 + i);
+      bytes[i] = buffer.get(position + Integer.BYTES + i);
     }
     return new String(bytes, StandardCharsets.UTF_8);
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/collection/utils/CollectionAdapter.java b/baremaps-core/src/main/java/org/apache/baremaps/collection/utils/CollectionAdapter.java
index 6c691059..444d12b7 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/utils/CollectionAdapter.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/collection/utils/CollectionAdapter.java
@@ -16,13 +16,13 @@ package org.apache.baremaps.collection.utils;
 
 import java.util.Collection;
 import java.util.Iterator;
-import org.apache.baremaps.collection.DataList;
+import org.apache.baremaps.collection.store.DataStore;
 
 public class CollectionAdapter<T> implements Collection<T> {
 
-  private final DataList<T> dataList;
+  private final DataStore<T> dataList;
 
-  public CollectionAdapter(DataList<T> dataList) {
+  public CollectionAdapter(DataStore<T> dataList) {
     this.dataList = dataList;
   }
 
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/database/DiffService.java b/baremaps-core/src/main/java/org/apache/baremaps/database/DiffService.java
index 14fba498..67fcc0c4 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/database/DiffService.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/database/DiffService.java
@@ -26,7 +26,7 @@ import java.util.concurrent.Callable;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 import java.util.zip.GZIPInputStream;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.database.repository.HeaderRepository;
 import org.apache.baremaps.database.repository.Repository;
 import org.apache.baremaps.database.tile.Tile;
@@ -45,8 +45,8 @@ public class DiffService implements Callable<List<Tile>> {
 
   private static final Logger logger = LoggerFactory.getLogger(DiffService.class);
 
-  private final LongDataMap<Coordinate> coordinateMap;
-  private final LongDataMap<List<Long>> referenceMap;
+  private final LongMap<Coordinate> coordinateMap;
+  private final LongMap<List<Long>> referenceMap;
   private final HeaderRepository headerRepository;
   private final Repository<Long, Node> nodeRepository;
   private final Repository<Long, Way> wayRepository;
@@ -54,7 +54,7 @@ public class DiffService implements Callable<List<Tile>> {
   private final int srid;
   private final int zoom;
 
-  public DiffService(LongDataMap<Coordinate> coordinateMap, LongDataMap<List<Long>> referenceMap,
+  public DiffService(LongMap<Coordinate> coordinateMap, LongMap<List<Long>> referenceMap,
       HeaderRepository headerRepository, Repository<Long, Node> nodeRepository,
       Repository<Long, Way> wayRepository, Repository<Long, Relation> relationRepository, int srid,
       int zoom) {
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/database/ImportService.java b/baremaps-core/src/main/java/org/apache/baremaps/database/ImportService.java
index e3af0a56..296be254 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/database/ImportService.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/database/ImportService.java
@@ -20,7 +20,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.List;
 import java.util.concurrent.Callable;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.database.repository.HeaderRepository;
 import org.apache.baremaps.database.repository.Repository;
 import org.apache.baremaps.openstreetmap.function.*;
@@ -33,16 +33,16 @@ import org.locationtech.jts.geom.Coordinate;
 public class ImportService implements Callable<Void> {
 
   private final Path path;
-  private final LongDataMap<Coordinate> coordinateMap;
-  private final LongDataMap<List<Long>> referenceMap;
+  private final LongMap<Coordinate> coordinateMap;
+  private final LongMap<List<Long>> referenceMap;
   private final HeaderRepository headerRepository;
   private final Repository<Long, Node> nodeRepository;
   private final Repository<Long, Way> wayRepository;
   private final Repository<Long, Relation> relationRepository;
   private final int databaseSrid;
 
-  public ImportService(Path path, LongDataMap<Coordinate> coordinateMap,
-      LongDataMap<List<Long>> referenceMap, HeaderRepository headerRepository,
+  public ImportService(Path path, LongMap<Coordinate> coordinateMap,
+      LongMap<List<Long>> referenceMap, HeaderRepository headerRepository,
       Repository<Long, Node> nodeRepository, Repository<Long, Way> wayRepository,
       Repository<Long, Relation> relationRepository, Integer databaseSrid) {
     this.path = path;
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/database/UpdateService.java b/baremaps-core/src/main/java/org/apache/baremaps/database/UpdateService.java
index 39fe14cb..e3466b89 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/database/UpdateService.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/database/UpdateService.java
@@ -21,7 +21,7 @@ import java.net.URL;
 import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.zip.GZIPInputStream;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.database.repository.HeaderRepository;
 import org.apache.baremaps.database.repository.Repository;
 import org.apache.baremaps.openstreetmap.function.ChangeEntitiesHandler;
@@ -37,15 +37,15 @@ import org.locationtech.jts.geom.Coordinate;
 
 public class UpdateService implements Callable<Void> {
 
-  private final LongDataMap<Coordinate> coordinateMap;
-  private final LongDataMap<List<Long>> referenceMap;
+  private final LongMap<Coordinate> coordinateMap;
+  private final LongMap<List<Long>> referenceMap;
   private final HeaderRepository headerRepository;
   private final Repository<Long, Node> nodeRepository;
   private final Repository<Long, Way> wayRepository;
   private final Repository<Long, Relation> relationRepository;
   private final int srid;
 
-  public UpdateService(LongDataMap<Coordinate> coordinateMap, LongDataMap<List<Long>> referenceMap,
+  public UpdateService(LongMap<Coordinate> coordinateMap, LongMap<List<Long>> referenceMap,
       HeaderRepository headerRepository, Repository<Long, Node> nodeRepository,
       Repository<Long, Way> wayRepository, Repository<Long, Relation> relationRepository,
       int srid) {
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/PostgresCoordinateMap.java b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/PostgresCoordinateMap.java
index c5f2858c..d3034190 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/PostgresCoordinateMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/PostgresCoordinateMap.java
@@ -22,15 +22,14 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.sql.DataSource;
-import org.apache.baremaps.collection.LongDataMap;
-import org.apache.baremaps.collection.StoreException;
+import org.apache.baremaps.collection.LongMap;
+import org.apache.baremaps.collection.store.DataStoreException;
 import org.locationtech.jts.geom.Coordinate;
 
 /**
- * A read-only {@link LongDataMap} for coordinates baked by OpenStreetMap nodes stored in
- * PostgreSQL.
+ * A read-only {@link LongMap} for coordinates baked by OpenStreetMap nodes stored in PostgreSQL.
  */
-public class PostgresCoordinateMap implements LongDataMap<Coordinate> {
+public class PostgresCoordinateMap implements LongMap<Coordinate> {
 
   private static final String SELECT = "SELECT lon, lat FROM osm_nodes WHERE id = ?";
 
@@ -59,7 +58,7 @@ public class PostgresCoordinateMap implements LongDataMap<Coordinate> {
         }
       }
     } catch (SQLException e) {
-      throw new StoreException(e);
+      throw new DataStoreException(e);
     }
   }
 
@@ -80,7 +79,7 @@ public class PostgresCoordinateMap implements LongDataMap<Coordinate> {
         return keys.stream().map(nodes::get).toList();
       }
     } catch (SQLException e) {
-      throw new StoreException(e);
+      throw new DataStoreException(e);
     }
   }
 
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/PostgresReferenceMap.java b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/PostgresReferenceMap.java
index a9a4844a..980794c2 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/PostgresReferenceMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/PostgresReferenceMap.java
@@ -25,13 +25,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.sql.DataSource;
-import org.apache.baremaps.collection.LongDataMap;
-import org.apache.baremaps.collection.StoreException;
+import org.apache.baremaps.collection.LongMap;
+import org.apache.baremaps.collection.store.DataStoreException;
 
 /**
  * A read-only {@code LongDataMap} for references baked by OpenStreetMap ways stored in Postgres.
  */
-public class PostgresReferenceMap implements LongDataMap<List<Long>> {
+public class PostgresReferenceMap implements LongMap<List<Long>> {
 
   private static final String SELECT = "SELECT nodes FROM osm_ways WHERE id = ?";
 
@@ -64,7 +64,7 @@ public class PostgresReferenceMap implements LongDataMap<List<Long>> {
         }
       }
     } catch (SQLException e) {
-      throw new StoreException(e);
+      throw new DataStoreException(e);
     }
   }
 
@@ -88,7 +88,7 @@ public class PostgresReferenceMap implements LongDataMap<List<Long>> {
         return keys.stream().map(referenceMap::get).toList();
       }
     } catch (SQLException e) {
-      throw new StoreException(e);
+      throw new DataStoreException(e);
     }
   }
 
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/CoordinateMapBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/CoordinateMapBuilder.java
index 9f0d6983..ce3f791d 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/CoordinateMapBuilder.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/CoordinateMapBuilder.java
@@ -15,7 +15,7 @@ package org.apache.baremaps.openstreetmap.function;
 
 
 import java.util.function.Consumer;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.openstreetmap.model.Entity;
 import org.apache.baremaps.openstreetmap.model.Node;
 import org.locationtech.jts.geom.Coordinate;
@@ -23,14 +23,14 @@ import org.locationtech.jts.geom.Coordinate;
 /** A consumer that stores openstreetmap coordinates in a map. */
 public class CoordinateMapBuilder implements Consumer<Entity> {
 
-  private final LongDataMap<Coordinate> coordinateMap;
+  private final LongMap<Coordinate> coordinateMap;
 
   /**
    * Constructs a {@code CacheBlockConsumer} with the provided map.
    *
    * @param coordinateMap the map of coordinates
    */
-  public CoordinateMapBuilder(LongDataMap<Coordinate> coordinateMap) {
+  public CoordinateMapBuilder(LongMap<Coordinate> coordinateMap) {
     this.coordinateMap = coordinateMap;
   }
 
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/EntityGeometryBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/EntityGeometryBuilder.java
index d1f0188b..d32a86e2 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/EntityGeometryBuilder.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/EntityGeometryBuilder.java
@@ -16,7 +16,7 @@ package org.apache.baremaps.openstreetmap.function;
 
 import java.util.List;
 import java.util.function.Consumer;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.openstreetmap.model.Entity;
 import org.apache.baremaps.openstreetmap.model.Node;
 import org.apache.baremaps.openstreetmap.model.Relation;
@@ -36,8 +36,8 @@ public class EntityGeometryBuilder implements Consumer<Entity> {
    * @param coordinateMap the coordinate cache
    * @param referenceMap the reference cache
    */
-  public EntityGeometryBuilder(LongDataMap<Coordinate> coordinateMap,
-      LongDataMap<List<Long>> referenceMap) {
+  public EntityGeometryBuilder(LongMap<Coordinate> coordinateMap,
+      LongMap<List<Long>> referenceMap) {
     this.nodeGeometryBuilder = new NodeGeometryBuilder();
     this.wayGeometryBuilder = new WayGeometryBuilder(coordinateMap);
     this.relationGeometryBuilder = new RelationGeometryBuilder(coordinateMap, referenceMap);
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/GeometryMapBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/GeometryMapBuilder.java
index 3ee34bcf..c64f06bd 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/GeometryMapBuilder.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/GeometryMapBuilder.java
@@ -16,7 +16,7 @@ package org.apache.baremaps.openstreetmap.function;
 
 import java.util.function.Consumer;
 import java.util.function.Predicate;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.openstreetmap.model.Element;
 import org.apache.baremaps.openstreetmap.model.Entity;
 import org.locationtech.jts.geom.Geometry;
@@ -26,7 +26,7 @@ import org.locationtech.jts.geom.Geometry;
  */
 public class GeometryMapBuilder implements Consumer<Entity> {
 
-  private final LongDataMap<Geometry> geometryMap;
+  private final LongMap<Geometry> geometryMap;
 
   private final Predicate<Entity> filter;
 
@@ -36,7 +36,7 @@ public class GeometryMapBuilder implements Consumer<Entity> {
    * @param geometryMap the geometry map
    * @param filter the entity filter
    */
-  public GeometryMapBuilder(LongDataMap<Geometry> geometryMap, Predicate<Entity> filter) {
+  public GeometryMapBuilder(LongMap<Geometry> geometryMap, Predicate<Entity> filter) {
     this.geometryMap = geometryMap;
     this.filter = filter;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/ReferenceMapBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/ReferenceMapBuilder.java
index b389662d..7c6248a5 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/ReferenceMapBuilder.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/ReferenceMapBuilder.java
@@ -16,21 +16,21 @@ package org.apache.baremaps.openstreetmap.function;
 
 import java.util.List;
 import java.util.function.Consumer;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.openstreetmap.model.Entity;
 import org.apache.baremaps.openstreetmap.model.Way;
 
 /** A consumer that stores openstreetmap references in a map. */
 public class ReferenceMapBuilder implements Consumer<Entity> {
 
-  private final LongDataMap<List<Long>> referenceMap;
+  private final LongMap<List<Long>> referenceMap;
 
   /**
    * Constructs a {@code CacheBlockConsumer} with the provided map.
    *
    * @param referenceMap the map of references
    */
-  public ReferenceMapBuilder(LongDataMap<List<Long>> referenceMap) {
+  public ReferenceMapBuilder(LongMap<List<Long>> referenceMap) {
     this.referenceMap = referenceMap;
   }
 
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/RelationGeometryBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/RelationGeometryBuilder.java
index d84d48ae..38ce9f70 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/RelationGeometryBuilder.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/RelationGeometryBuilder.java
@@ -16,7 +16,7 @@ import static org.apache.baremaps.openstreetmap.utils.GeometryUtils.GEOMETRY_FAC
 
 import java.util.*;
 import java.util.function.Consumer;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.openstreetmap.model.Member;
 import org.apache.baremaps.openstreetmap.model.Relation;
 import org.apache.baremaps.stream.StreamException;
@@ -36,8 +36,8 @@ public class RelationGeometryBuilder implements Consumer<Relation> {
 
   private static final Logger logger = LoggerFactory.getLogger(RelationGeometryBuilder.class);
 
-  private final LongDataMap<Coordinate> coordinateMap;
-  private final LongDataMap<List<Long>> referenceMap;
+  private final LongMap<Coordinate> coordinateMap;
+  private final LongMap<List<Long>> referenceMap;
 
   /**
    * Constructs a relation geometry builder.
@@ -45,8 +45,8 @@ public class RelationGeometryBuilder implements Consumer<Relation> {
    * @param coordinateMap the coordinates map
    * @param referenceMap the references map
    */
-  public RelationGeometryBuilder(LongDataMap<Coordinate> coordinateMap,
-      LongDataMap<List<Long>> referenceMap) {
+  public RelationGeometryBuilder(LongMap<Coordinate> coordinateMap,
+      LongMap<List<Long>> referenceMap) {
     this.coordinateMap = coordinateMap;
     this.referenceMap = referenceMap;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/WayGeometryBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/WayGeometryBuilder.java
index 32c76eb3..ec3a7ae7 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/WayGeometryBuilder.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/WayGeometryBuilder.java
@@ -16,7 +16,7 @@ import static org.apache.baremaps.openstreetmap.utils.GeometryUtils.GEOMETRY_FAC
 
 import java.util.List;
 import java.util.function.Consumer;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.openstreetmap.model.Way;
 import org.locationtech.jts.geom.Coordinate;
 import org.locationtech.jts.geom.LineString;
@@ -31,14 +31,14 @@ public class WayGeometryBuilder implements Consumer<Way> {
 
   private static final Logger logger = LoggerFactory.getLogger(WayGeometryBuilder.class);
 
-  private final LongDataMap<Coordinate> coordinateMap;
+  private final LongMap<Coordinate> coordinateMap;
 
   /**
    * Constructs a way geometry builder.
    *
    * @param coordinateMap the coordinates map
    */
-  public WayGeometryBuilder(LongDataMap<Coordinate> coordinateMap) {
+  public WayGeometryBuilder(LongMap<Coordinate> coordinateMap) {
     this.coordinateMap = coordinateMap;
   }
 
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfBlockReader.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfBlockReader.java
index 42c442ca..3ce0d824 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfBlockReader.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfBlockReader.java
@@ -17,7 +17,7 @@ import static org.apache.baremaps.stream.ConsumerUtils.consumeThenReturn;
 import java.io.InputStream;
 import java.util.List;
 import java.util.stream.Stream;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.openstreetmap.OsmReader;
 import org.apache.baremaps.openstreetmap.function.*;
 import org.apache.baremaps.openstreetmap.model.Block;
@@ -33,9 +33,9 @@ public class PbfBlockReader implements OsmReader<Block> {
 
   private int srid = 4326;
 
-  private LongDataMap<Coordinate> coordinateMap;
+  private LongMap<Coordinate> coordinateMap;
 
-  private LongDataMap<List<Long>> referenceMap;
+  private LongMap<List<Long>> referenceMap;
 
   /**
    * Gets the number of blobs buffered by the parser to parallelize deserialization.
@@ -102,7 +102,7 @@ public class PbfBlockReader implements OsmReader<Block> {
    *
    * @return the map of coordinates
    */
-  public LongDataMap<Coordinate> coordinateMap() {
+  public LongMap<Coordinate> coordinateMap() {
     return coordinateMap;
   }
 
@@ -112,7 +112,7 @@ public class PbfBlockReader implements OsmReader<Block> {
    * @param coordinateMap the map of coordinates
    * @return the parser
    */
-  public PbfBlockReader coordinateMap(LongDataMap<Coordinate> coordinateMap) {
+  public PbfBlockReader coordinateMap(LongMap<Coordinate> coordinateMap) {
     this.coordinateMap = coordinateMap;
     return this;
   }
@@ -122,7 +122,7 @@ public class PbfBlockReader implements OsmReader<Block> {
    *
    * @return the map of references
    */
-  public LongDataMap<List<Long>> referenceMap() {
+  public LongMap<List<Long>> referenceMap() {
     return referenceMap;
   }
 
@@ -132,7 +132,7 @@ public class PbfBlockReader implements OsmReader<Block> {
    * @param referenceMap the map of references
    * @return the parser
    */
-  public PbfBlockReader referenceMap(LongDataMap<List<Long>> referenceMap) {
+  public PbfBlockReader referenceMap(LongMap<List<Long>> referenceMap) {
     this.referenceMap = referenceMap;
     return this;
   }
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageTable.java b/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageTable.java
index 148adde0..cb15df41 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageTable.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageTable.java
@@ -54,7 +54,7 @@ public class GeoPackageTable implements ReadableFeatureSet {
     for (FeatureColumn column : featureDao.getColumns()) {
       var propertyName = column.getName();
       var propertyType = classType(column);
-      properties.put(propertyName, new PropertyType(name, propertyType));
+      properties.put(propertyName, new PropertyType(propertyName, propertyType));
     }
     featureType = new FeatureType(name, properties);
     geometryFactory = new GeometryFactory(new PrecisionModel(), (int) featureDao.getSrs().getId());
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDatabase.java b/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDatabase.java
index 4c6ae4ce..5a9b9083 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDatabase.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDatabase.java
@@ -23,7 +23,6 @@ import java.time.LocalTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 import javax.sql.DataSource;
 import org.apache.baremaps.database.copy.CopyWriter;
@@ -92,8 +91,8 @@ public class PostgresDatabase implements WritableAggregate {
   private FeatureType createFeatureType(FeatureType featureType) {
     var name = featureType.getName().replaceAll("[^a-zA-Z0-9]", "_");
     var properties = featureType.getProperties().values().stream()
-        .filter(typeToName::containsKey)
-        .collect(Collectors.toMap(PropertyType::getName, Function.identity()));
+        .filter(type -> typeToName.containsKey(type.getType()))
+        .collect(Collectors.toMap(k -> k.getName(), v -> v));
     return new FeatureType(name, properties);
   }
 
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOpenStreetMap.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOpenStreetMap.java
index 064def24..6abc8d5c 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOpenStreetMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOpenStreetMap.java
@@ -13,7 +13,9 @@
 package org.apache.baremaps.workflow.tasks;
 
 import org.apache.baremaps.collection.*;
-import org.apache.baremaps.collection.memory.OnDiskDirectoryMemory;
+import org.apache.baremaps.collection.memory.MappedMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
+import org.apache.baremaps.collection.store.MemoryAlignedDataStore;
 import org.apache.baremaps.collection.type.LonLatDataType;
 import org.apache.baremaps.collection.type.LongDataType;
 import org.apache.baremaps.collection.type.LongListDataType;
@@ -61,37 +63,37 @@ public record ImportOpenStreetMap(Path file, String database, Integer databaseSr
 
     var cacheDir = Files.createTempDirectory(Paths.get("."), "cache_");
 
-    LongDataMap<Coordinate> coordinateMap;
+    LongMap<Coordinate> coordinateMap;
     if (Files.size(path) > 1 << 30) {
-      var coordinatesDir = Files.createDirectories(cacheDir.resolve("coordinates"));
-      coordinateMap = new LongSizedDataDenseMap<>(
+      var coordinatesFile = Files.createFile(cacheDir.resolve("coordinates"));
+      coordinateMap = new MemoryAlignedLongFixedSizeDataMap<>(
         new LonLatDataType(),
-        new OnDiskDirectoryMemory(coordinatesDir));
+        new MappedMemory(coordinatesFile));
     } else {
-      var coordinatesKeysDir = Files.createDirectories(cacheDir.resolve("coordinates_keys"));
-      var coordinatesValsDir = Files.createDirectories(cacheDir.resolve("coordinates_vals"));
+      var coordinatesKeysFile = Files.createFile(cacheDir.resolve("coordinates_keys"));
+      var coordinatesValsFile = Files.createFile(cacheDir.resolve("coordinates_vals"));
       coordinateMap =
-        new LongDataSortedMap<>(
-          new AlignedDataList<>(
+        new SortedLongVariableSizeDataMap<>(
+          new MemoryAlignedDataStore<>(
             new PairDataType<>(new LongDataType(), new LongDataType()),
-            new OnDiskDirectoryMemory(coordinatesKeysDir)
+            new MappedMemory(coordinatesKeysFile)
           ),
-          new DataStore<>(
+          new AppendOnlyStore<>(
             new LonLatDataType(),
-            new OnDiskDirectoryMemory(coordinatesValsDir)));
+            new MappedMemory(coordinatesValsFile)));
     }
 
-    var referencesKeysDir = Files.createDirectories(cacheDir.resolve("references_keys"));
-    var referencesValuesDir = Files.createDirectories(cacheDir.resolve("references_vals"));
+    var referencesKeysDir = Files.createFile(cacheDir.resolve("references_keys"));
+    var referencesValuesDir = Files.createFile(cacheDir.resolve("references_vals"));
     var referenceMap =
-      new LongDataSortedMap<>(
-        new AlignedDataList<>(
+      new SortedLongVariableSizeDataMap<>(
+        new MemoryAlignedDataStore<>(
           new PairDataType<>(new LongDataType(), new LongDataType()),
-          new OnDiskDirectoryMemory(referencesKeysDir)
+          new MappedMemory(referencesKeysDir)
         ),
-        new DataStore<>(
+        new AppendOnlyStore<>(
           new LongListDataType(),
-          new OnDiskDirectoryMemory(referencesValuesDir)));
+          new MappedMemory(referencesValuesDir)));
 
     new ImportService(
       path,
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/SimplifyOpenStreetMap.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/SimplifyOpenStreetMap.java
index ffc5f809..71245a3a 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/SimplifyOpenStreetMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/SimplifyOpenStreetMap.java
@@ -14,7 +14,6 @@ package org.apache.baremaps.workflow.tasks;
 
 
 
-import com.google.common.base.Predicates;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -30,14 +29,12 @@ import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
 import org.apache.baremaps.collection.*;
+import org.apache.baremaps.collection.memory.MappedMemory;
 import org.apache.baremaps.collection.memory.OffHeapMemory;
-import org.apache.baremaps.collection.memory.OnDiskDirectoryMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
+import org.apache.baremaps.collection.store.MemoryAlignedDataStore;
 import org.apache.baremaps.collection.type.*;
-import org.apache.baremaps.collection.utils.CollectionAdapter;
-import org.apache.baremaps.collection.utils.FileUtils;
 import org.apache.baremaps.openstreetmap.model.Element;
-import org.apache.baremaps.openstreetmap.pbf.PbfBlockReader;
-import org.apache.baremaps.openstreetmap.pbf.PbfEntityReader;
 import org.apache.baremaps.workflow.Task;
 import org.apache.baremaps.workflow.WorkflowContext;
 import org.locationtech.jts.geom.Geometry;
@@ -57,59 +54,61 @@ public record SimplifyOpenStreetMap(Path file, String database, Integer database
 
         var cacheDir = Files.createTempDirectory(Paths.get("."), "cache_");
 
-        var coordinatesKeysDir = Files.createDirectories(cacheDir.resolve("coordinates_keys"));
-        var coordinatesValsDir = Files.createDirectories(cacheDir.resolve("coordinates_vals"));
+        var coordinatesKeysFile = Files.createFile(cacheDir.resolve("coordinates_keys"));
+        var coordinatesValsFile = Files.createFile(cacheDir.resolve("coordinates_vals"));
         var coordinateMap =
-                new LongDataSortedMap<>(
-                        new AlignedDataList<>(
-                                new PairDataType<>(new LongDataType(), new LongDataType()),
-                                new OnDiskDirectoryMemory(coordinatesKeysDir)
-                        ),
-                        new DataStore<>(
+                new SortedLongVariableSizeDataMap<>(
+                        new MemoryAlignedDataStore<>(
+                                new PairDataType<>(
+                                        new LongDataType(),
+                                        new LongDataType()
+                                ), new MappedMemory(coordinatesKeysFile)),
+                        new AppendOnlyStore<>(
                                 new LonLatDataType(),
-                                new OnDiskDirectoryMemory(coordinatesValsDir)));
+                                new MappedMemory(coordinatesValsFile)));
 
-        var referencesKeysDir = Files.createDirectories(cacheDir.resolve("references_keys"));
-        var referencesValuesDir = Files.createDirectories(cacheDir.resolve("references_vals"));
+        var referencesKeysFile = Files.createFile(cacheDir.resolve("references_keys"));
+        var referencesValuesFile = Files.createFile(cacheDir.resolve("references_vals"));
         var referenceMap =
-                new LongDataSortedMap<>(
-                        new AlignedDataList<>(
-                                new PairDataType<>(new LongDataType(), new LongDataType()),
-                                new OnDiskDirectoryMemory(referencesKeysDir)
-                        ),
-                        new DataStore<>(
+                new SortedLongVariableSizeDataMap<>(
+                        new MemoryAlignedDataStore<>(
+                                new PairDataType<>(
+                                        new LongDataType(),
+                                        new LongDataType()
+                                ), new MappedMemory(referencesKeysFile)),
+                        new AppendOnlyStore<>(
                                 new LongListDataType(),
-                                new OnDiskDirectoryMemory(referencesValuesDir)));
-
-        var collection = new IndexedDataList<>(
-                new LongList(new OffHeapMemory()),
-                new DataStore<>(new GeometryDataType(), new OffHeapMemory()));
-
-
-        new PbfEntityReader(
-                new PbfBlockReader()
-                        .geometries(true)
-                        .coordinateMap(coordinateMap)
-                        .referenceMap(referenceMap))
-                .stream(Files.newInputStream(path))
-                .filter(Element.class::isInstance)
-                .map(Element.class::cast)
-                .filter(element -> element.getTags().containsKey("building"))
-                .map(Element::getGeometry)
-                .filter(Predicates.notNull())
-                .forEach(collection::add);
-
-        var unionedGeometry = new CascadedPolygonUnion(new CollectionAdapter(collection)).union();
-
-        var unionGeometries = IntStream.range(0, unionedGeometry.getNumGeometries())
-                .mapToObj(unionedGeometry::getGeometryN)
-                .toList();
-
-        System.out.println(unionGeometries.size());
-
-        FileUtils.deleteRecursively(cacheDir);
-
-        logger.info("Finished importing {} into {}", file, database);
+                                new MappedMemory(referencesValuesFile)));
+
+        var collection = new IndexedLongMap<>(
+                new LongLongMap(new OffHeapMemory()),
+                new AppendOnlyStore<>(new GeometryDataType(), new OffHeapMemory()));
+
+
+//        new PbfEntityReader(
+//                new PbfBlockReader()
+//                        .geometries(true)
+//                        .coordinateMap(coordinateMap)
+//                        .referenceMap(referenceMap))
+//                .stream(Files.newInputStream(path))
+//                .filter(Element.class::isInstance)
+//                .map(Element.class::cast)
+//                .filter(element -> element.getTags().containsKey("building"))
+//                .map(Element::getGeometry)
+//                .filter(Predicates.notNull())
+//                .forEach(collection::put);
+//
+//        var unionedGeometry = new CascadedPolygonUnion(new CollectionAdapter(collection)).union();
+//
+//        var unionGeometries = IntStream.range(0, unionedGeometry.getNumGeometries())
+//                .mapToObj(unionedGeometry::getGeometryN)
+//                .toList();
+//
+//        System.out.println(unionGeometries.size());
+//
+//        FileUtils.deleteRecursively(cacheDir);
+//
+//        logger.info("Finished importing {} into {}", file, database);
     }
 
     public static class PolygonUnionConsumer implements Consumer<Element> {
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOpenStreetMap.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOpenStreetMap.java
index 558ecbdb..d8e6a6df 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOpenStreetMap.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOpenStreetMap.java
@@ -12,7 +12,7 @@
 
 package org.apache.baremaps.workflow.tasks;
 
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.database.UpdateService;
 import org.apache.baremaps.database.collection.PostgresCoordinateMap;
 import org.apache.baremaps.database.collection.PostgresReferenceMap;
@@ -39,8 +39,8 @@ public record UpdateOpenStreetMap(String database, Integer databaseSrid) impleme
   public void execute(WorkflowContext context) throws Exception {
     logger.info("Updating {}", database);
     var datasource = context.getDataSource(database);
-    LongDataMap<Coordinate> coordinateMap = new PostgresCoordinateMap(datasource);
-    LongDataMap<List<Long>> referenceMap = new PostgresReferenceMap(datasource);
+    LongMap<Coordinate> coordinateMap = new PostgresCoordinateMap(datasource);
+    LongMap<List<Long>> referenceMap = new PostgresReferenceMap(datasource);
     HeaderRepository headerRepository = new PostgresHeaderRepository(datasource);
     Repository<Long, Node> nodeRepository = new PostgresNodeRepository(datasource);
     Repository<Long, Way> wayRepository = new PostgresWayRepository(datasource);
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/collection/DataStoreTest.java b/baremaps-core/src/test/java/org/apache/baremaps/collection/AppendStoreTest.java
similarity index 86%
rename from baremaps-core/src/test/java/org/apache/baremaps/collection/DataStoreTest.java
rename to baremaps-core/src/test/java/org/apache/baremaps/collection/AppendStoreTest.java
index 08d6e9fa..8fc0956b 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/collection/DataStoreTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/collection/AppendStoreTest.java
@@ -17,15 +17,16 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import java.util.ArrayList;
 import java.util.Random;
 import org.apache.baremaps.collection.memory.OffHeapMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
 import org.apache.baremaps.collection.type.IntegerDataType;
 import org.apache.baremaps.collection.type.IntegerListDataType;
 import org.junit.jupiter.api.Test;
 
-class DataStoreTest {
+class AppendStoreTest {
 
   @Test
   void addFixedSizeData() {
-    var store = new DataStore<>(new IntegerDataType(), new OffHeapMemory(1 << 10));
+    var store = new AppendOnlyStore<>(new IntegerDataType(), new OffHeapMemory(1 << 10));
     for (int i = 0; i < 1 << 20; i++) {
       assertEquals(i << 2, store.add(i));
     }
@@ -36,7 +37,7 @@ class DataStoreTest {
 
   @Test
   void addVariableSizeValues() {
-    var store = new DataStore<>(new IntegerListDataType(), new OffHeapMemory(1 << 10));
+    var store = new AppendOnlyStore<>(new IntegerListDataType(), new OffHeapMemory(1 << 10));
     var random = new Random(0);
     var positions = new ArrayList<Long>();
     var values = new ArrayList<ArrayList<Integer>>();
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/collection/LongDataMapTest.java b/baremaps-core/src/test/java/org/apache/baremaps/collection/LongMapTest.java
similarity index 59%
rename from baremaps-core/src/test/java/org/apache/baremaps/collection/LongDataMapTest.java
rename to baremaps-core/src/test/java/org/apache/baremaps/collection/LongMapTest.java
index 5536374f..a4843335 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/collection/LongDataMapTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/collection/LongMapTest.java
@@ -16,17 +16,19 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.stream.Stream;
 import org.apache.baremaps.collection.memory.OffHeapMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
+import org.apache.baremaps.collection.store.MemoryAlignedDataStore;
 import org.apache.baremaps.collection.type.LongDataType;
 import org.apache.baremaps.collection.type.PairDataType;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.MethodSource;
 
-class LongDataMapTest {
+class LongMapTest {
 
   @ParameterizedTest
   @MethodSource("mapProvider")
-  void test(LongDataMap<Long> map) {
+  void test(LongMap<Long> map) {
     for (long i = 0; i < 1 << 20; i++) {
       map.put(i, i);
     }
@@ -38,16 +40,17 @@ class LongDataMapTest {
   static Stream<Arguments> mapProvider() {
     return Stream
         .of(Arguments.of(
-            new LongDataOpenHashMap<>(new DataStore<>(new LongDataType(), new OffHeapMemory()))),
-            Arguments.of(new LongSizedDataSortedMap<>(
-                new AlignedDataList<>(new LongDataType(), new OffHeapMemory()),
-                new AlignedDataList<>(new LongDataType(), new OffHeapMemory()))),
-            Arguments.of(new LongDataSortedMap<>(
-                new AlignedDataList<>(new PairDataType<>(new LongDataType(), new LongDataType()),
+            new LongOpenHashMap<>(new AppendOnlyStore<>(new LongDataType(), new OffHeapMemory()))),
+            Arguments.of(new SortedLongFixedSizeDataMap<>(
+                new MemoryAlignedDataStore<>(new LongDataType(), new OffHeapMemory()))),
+            Arguments.of(new SortedLongVariableSizeDataMap<>(
+                new MemoryAlignedDataStore<>(
+                    new PairDataType<>(new LongDataType(), new LongDataType()),
                     new OffHeapMemory()),
-                new DataStore<>(new LongDataType(), new OffHeapMemory()))),
-            Arguments.of(new LongSizedDataSparseMap<>(
-                new AlignedDataList<>(new LongDataType(), new OffHeapMemory()))),
-            Arguments.of(new LongSizedDataDenseMap<>(new LongDataType(), new OffHeapMemory())));
+                new AppendOnlyStore<>(new LongDataType(), new OffHeapMemory()))),
+            Arguments.of(new SparseLongFixedSizeDataMap<>(
+                new MemoryAlignedDataStore<>(new LongDataType(), new OffHeapMemory()))),
+            Arguments.of(
+                new MemoryAlignedLongFixedSizeDataMap<>(new LongDataType(), new OffHeapMemory())));
   }
 }
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/collection/SizedDataListTest.java b/baremaps-core/src/test/java/org/apache/baremaps/collection/SizedDataListTest.java
index 395668f1..8805704b 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/collection/SizedDataListTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/collection/SizedDataListTest.java
@@ -18,6 +18,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 import java.io.IOException;
 import org.apache.baremaps.collection.memory.Memory;
 import org.apache.baremaps.collection.memory.OffHeapMemory;
+import org.apache.baremaps.collection.store.DataStoreException;
+import org.apache.baremaps.collection.store.FixedSizeDataStore;
 import org.apache.baremaps.collection.type.LongDataType;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
@@ -29,13 +31,13 @@ class SizedDataListTest {
   void segmentsTooSmall() {
     var dataType = new LongDataType();
     var memory = new OffHeapMemory(4);
-    assertThrows(StoreException.class, () -> new AlignedDataList<>(dataType, memory));
+    assertThrows(DataStoreException.class, () -> new FixedSizeDataStore<>(dataType, memory));
   }
 
   @ParameterizedTest
   @MethodSource("org.apache.baremaps.collection.memory.MemoryProvider#memories")
   void appendFixedSizeValues(Memory memory) throws IOException {
-    var list = new AlignedDataList<>(new LongDataType(), memory);
+    var list = new FixedSizeDataStore<>(new LongDataType(), memory);
     for (int i = 0; i < 1 << 10; i++) {
       assertEquals(i, list.add((long) i));
     }
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/collection/memory/MemoryProvider.java b/baremaps-core/src/test/java/org/apache/baremaps/collection/memory/MemoryProvider.java
index 44c946e6..afb795c1 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/collection/memory/MemoryProvider.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/collection/memory/MemoryProvider.java
@@ -27,9 +27,9 @@ public class MemoryProvider {
   public static Stream<Arguments> memories() throws IOException {
     return Stream.of(Arguments.of(new OnHeapMemory(SEGMENT_BYTES)),
         Arguments.of(new OffHeapMemory(SEGMENT_BYTES)),
-        Arguments.of(new OnDiskFileMemory(Files.createTempFile(Paths.get("."), "baremaps_", ".tmp"),
-            SEGMENT_BYTES)),
-        Arguments.of(new OnDiskDirectoryMemory(
-            Files.createTempDirectory(Paths.get("."), "baremaps_"), SEGMENT_BYTES)));
+        Arguments.of(new MappedMemory(
+            Files.createTempFile(Paths.get("."), "baremaps_", ".tmp"), SEGMENT_BYTES)),
+        Arguments.of(new MappedMemory(
+            Files.createTempFile(Paths.get("."), "baremaps_", ".tmp"), SEGMENT_BYTES)));
   }
 }
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/collection/sort/ExternalMergeSortTest.java b/baremaps-core/src/test/java/org/apache/baremaps/collection/sort/ExternalMergeSortTest.java
index 718e3b37..fe18bb1e 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/collection/sort/ExternalMergeSortTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/collection/sort/ExternalMergeSortTest.java
@@ -21,11 +21,12 @@ import java.util.Comparator;
 import java.util.List;
 import java.util.Random;
 import java.util.function.Supplier;
-import org.apache.baremaps.collection.DataList;
-import org.apache.baremaps.collection.DataStore;
-import org.apache.baremaps.collection.IndexedDataList;
-import org.apache.baremaps.collection.LongList;
 import org.apache.baremaps.collection.memory.OnHeapMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
+import org.apache.baremaps.collection.store.DataStore;
+import org.apache.baremaps.collection.store.IndexedDataStore;
+import org.apache.baremaps.collection.store.MemoryAlignedDataStore;
+import org.apache.baremaps.collection.type.LongDataType;
 import org.apache.baremaps.collection.type.StringDataType;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -36,24 +37,23 @@ class ExternalMergeSortTest {
   List<String> stringsAsc = strings.stream().sorted(Comparator.naturalOrder()).toList();
   List<String> stringsDsc = strings.stream().sorted(Comparator.reverseOrder()).toList();;
   List<String> stringsDistinct = stringsAsc.stream().distinct().toList();
-  DataList<String> input;
-  DataList<String> output;
-  Supplier<DataList<String>> supplier;
+  Supplier<DataStore<String>> supplier;
+  DataStore<String> input;
+  DataStore<String> output;
 
   @BeforeEach
   void before() {
-    input = new IndexedDataList<>(new LongList(new OnHeapMemory()),
-        new DataStore<>(new StringDataType(), new OnHeapMemory()));
-    output = new IndexedDataList<>(new LongList(new OnHeapMemory()),
-        new DataStore<>(new StringDataType(), new OnHeapMemory()));
-    supplier = () -> new IndexedDataList<>(new LongList(new OnHeapMemory()),
-        new DataStore<>(new StringDataType(), new OnHeapMemory()));
+    supplier = () -> new IndexedDataStore<>(
+        new MemoryAlignedDataStore<>(new LongDataType(), new OnHeapMemory()),
+        new AppendOnlyStore<>(new StringDataType(), new OnHeapMemory()));
+    input = supplier.get();
+    output = supplier.get();
     for (var string : strings) {
       input.add(string);
     }
   }
 
-  public List<String> stringList(DataList<String> list) {
+  public List<String> stringList(DataStore<String> list) {
     var l = new ArrayList<String>();
     for (long i = 0; i < list.size(); i++) {
       l.add(list.get(i));
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/collection/type/DataTypeTest.java b/baremaps-core/src/test/java/org/apache/baremaps/collection/type/DataTypeTest.java
index c2734c66..67afada8 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/collection/type/DataTypeTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/collection/type/DataTypeTest.java
@@ -27,5 +27,6 @@ class DataTypeTest {
     var buffer = ByteBuffer.allocate(size);
     dataType.write(buffer, 0, value);
     assertEquals(value, dataType.read(buffer, 0));
+    assertEquals(size, dataType.size(buffer, 0));
   }
 }
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateDataTest.java b/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateDataTest.java
index 7e274c7d..b4cb85a0 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateDataTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateDataTest.java
@@ -19,10 +19,10 @@ import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.time.LocalDateTime;
 import java.util.List;
-import org.apache.baremaps.collection.DataStore;
-import org.apache.baremaps.collection.LongDataMap;
-import org.apache.baremaps.collection.LongDataOpenHashMap;
+import org.apache.baremaps.collection.LongMap;
+import org.apache.baremaps.collection.LongOpenHashMap;
 import org.apache.baremaps.collection.memory.OnHeapMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
 import org.apache.baremaps.collection.type.CoordinateDataType;
 import org.apache.baremaps.collection.type.LongListDataType;
 import org.apache.baremaps.database.ImportService;
@@ -51,10 +51,10 @@ class ImportUpdateDataTest extends DatabaseContainerTest {
     PostgresWayRepository wayRepository = new PostgresWayRepository(dataSource());
     PostgresRelationRepository relationRepository = new PostgresRelationRepository(dataSource());
 
-    LongDataMap<Coordinate> coordinateMap =
-        new LongDataOpenHashMap<>(new DataStore<>(new CoordinateDataType(), new OnHeapMemory()));
-    LongDataMap<List<Long>> referenceMap =
-        new LongDataOpenHashMap<>(new DataStore<>(new LongListDataType(), new OnHeapMemory()));
+    LongMap<Coordinate> coordinateMap =
+        new LongOpenHashMap<>(new AppendOnlyStore<>(new CoordinateDataType(), new OnHeapMemory()));
+    LongMap<List<Long>> referenceMap =
+        new LongOpenHashMap<>(new AppendOnlyStore<>(new LongListDataType(), new OnHeapMemory()));
 
     // Import data
     new ImportService(SIMPLE_DATA_OSM_PBF, coordinateMap, referenceMap, headerRepository,
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateLiechtensteinTest.java b/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateLiechtensteinTest.java
index 80ae6916..5c7e6f63 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateLiechtensteinTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateLiechtensteinTest.java
@@ -18,10 +18,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.time.LocalDateTime;
 import java.util.List;
-import org.apache.baremaps.collection.DataStore;
-import org.apache.baremaps.collection.LongDataMap;
-import org.apache.baremaps.collection.LongDataOpenHashMap;
+import org.apache.baremaps.collection.LongMap;
+import org.apache.baremaps.collection.LongOpenHashMap;
 import org.apache.baremaps.collection.memory.OnHeapMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
 import org.apache.baremaps.collection.type.CoordinateDataType;
 import org.apache.baremaps.collection.type.LongListDataType;
 import org.apache.baremaps.database.DiffService;
@@ -48,10 +48,10 @@ class ImportUpdateLiechtensteinTest extends DatabaseContainerTest {
     PostgresWayRepository wayRepository = new PostgresWayRepository(dataSource());
     PostgresRelationRepository relationRepository = new PostgresRelationRepository(dataSource());
 
-    LongDataMap<Coordinate> coordinateMap =
-        new LongDataOpenHashMap<>(new DataStore<>(new CoordinateDataType(), new OnHeapMemory()));
-    LongDataMap<List<Long>> referenceMap =
-        new LongDataOpenHashMap<>(new DataStore<>(new LongListDataType(), new OnHeapMemory()));
+    LongMap<Coordinate> coordinateMap =
+        new LongOpenHashMap<>(new AppendOnlyStore<>(new CoordinateDataType(), new OnHeapMemory()));
+    LongMap<List<Long>> referenceMap =
+        new LongOpenHashMap<>(new AppendOnlyStore<>(new LongListDataType(), new OnHeapMemory()));
 
     // Import data
     new ImportService(LIECHTENSTEIN_OSM_PBF, coordinateMap, referenceMap, headerRepository,
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateMonacoTest.java b/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateMonacoTest.java
index 6b2f2154..e2879b08 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateMonacoTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/database/database/ImportUpdateMonacoTest.java
@@ -16,10 +16,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.time.LocalDateTime;
 import java.util.List;
-import org.apache.baremaps.collection.DataStore;
-import org.apache.baremaps.collection.LongDataMap;
-import org.apache.baremaps.collection.LongDataOpenHashMap;
+import org.apache.baremaps.collection.LongMap;
+import org.apache.baremaps.collection.LongOpenHashMap;
 import org.apache.baremaps.collection.memory.OnHeapMemory;
+import org.apache.baremaps.collection.store.AppendOnlyStore;
 import org.apache.baremaps.collection.type.CoordinateDataType;
 import org.apache.baremaps.collection.type.LongListDataType;
 import org.apache.baremaps.database.DiffService;
@@ -47,10 +47,10 @@ class ImportUpdateMonacoTest extends DatabaseContainerTest {
     PostgresWayRepository wayRepository = new PostgresWayRepository(dataSource());
     PostgresRelationRepository relationRepository = new PostgresRelationRepository(dataSource());
 
-    LongDataMap<Coordinate> coordinateMap =
-        new LongDataOpenHashMap<>(new DataStore<>(new CoordinateDataType(), new OnHeapMemory()));
-    LongDataMap<List<Long>> referenceMap =
-        new LongDataOpenHashMap<>(new DataStore<>(new LongListDataType(), new OnHeapMemory()));
+    LongMap<Coordinate> coordinateMap =
+        new LongOpenHashMap<>(new AppendOnlyStore<>(new CoordinateDataType(), new OnHeapMemory()));
+    LongMap<List<Long>> referenceMap =
+        new LongOpenHashMap<>(new AppendOnlyStore<>(new LongListDataType(), new OnHeapMemory()));
 
     // Import data
     new ImportService(TestFiles.resolve("monaco/monaco-210801.osm.pbf"), coordinateMap,
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/geometry/EntityGeometryBuilderTest.java b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/geometry/EntityGeometryBuilderTest.java
index 2b85dc1e..1c105e2d 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/geometry/EntityGeometryBuilderTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/geometry/EntityGeometryBuilderTest.java
@@ -23,7 +23,7 @@ import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.openstreetmap.function.EntityGeometryBuilder;
 import org.apache.baremaps.openstreetmap.model.Info;
 import org.apache.baremaps.openstreetmap.model.Member;
@@ -31,7 +31,7 @@ import org.apache.baremaps.openstreetmap.model.Member.MemberType;
 import org.apache.baremaps.openstreetmap.model.Node;
 import org.apache.baremaps.openstreetmap.model.Relation;
 import org.apache.baremaps.openstreetmap.model.Way;
-import org.apache.baremaps.openstreetmap.store.MockLongDataMap;
+import org.apache.baremaps.openstreetmap.store.MockLongMap;
 import org.junit.jupiter.api.Test;
 import org.locationtech.jts.geom.Coordinate;
 import org.locationtech.jts.geom.GeometryFactory;
@@ -107,7 +107,7 @@ class EntityGeometryBuilderTest {
 
   static final Node NODE_15 = new Node(15, INFO, ImmutableMap.of(), 3, 1);
 
-  static final LongDataMap<Coordinate> COORDINATE_CACHE = new MockLongDataMap(Arrays
+  static final LongMap<Coordinate> COORDINATE_CACHE = new MockLongMap(Arrays
       .asList(NODE_0, NODE_1, NODE_2, NODE_3, NODE_4, NODE_5, NODE_6, NODE_7, NODE_8, NODE_9,
           NODE_10, NODE_11, NODE_12, NODE_13, NODE_14, NODE_15)
       .stream()
@@ -129,8 +129,8 @@ class EntityGeometryBuilderTest {
   static final Way WAY_5 =
       new Way(5, INFO, ImmutableMap.of(), ImmutableList.of(12l, 13l, 14l, 15l, 12l));
 
-  static final LongDataMap<List<Long>> REFERENCE_CACHE =
-      new MockLongDataMap(Arrays.asList(WAY_0, WAY_1, WAY_2, WAY_3, WAY_4, WAY_5).stream()
+  static final LongMap<List<Long>> REFERENCE_CACHE =
+      new MockLongMap(Arrays.asList(WAY_0, WAY_1, WAY_2, WAY_3, WAY_4, WAY_5).stream()
           .collect(Collectors.toMap(w -> w.id(), w -> w.getNodes())));
 
   static final Relation RELATION_0 = new Relation(0, INFO, ImmutableMap.of(), Arrays.asList());
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/geometry/RelationGeometryBuilderTest.java b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/geometry/RelationGeometryBuilderTest.java
index fe798c59..1e7b5f70 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/geometry/RelationGeometryBuilderTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/geometry/RelationGeometryBuilderTest.java
@@ -19,13 +19,13 @@ import java.io.InputStream;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.zip.GZIPInputStream;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 import org.apache.baremaps.openstreetmap.function.RelationGeometryBuilder;
 import org.apache.baremaps.openstreetmap.model.Entity;
 import org.apache.baremaps.openstreetmap.model.Node;
 import org.apache.baremaps.openstreetmap.model.Relation;
 import org.apache.baremaps.openstreetmap.model.Way;
-import org.apache.baremaps.openstreetmap.store.MockLongDataMap;
+import org.apache.baremaps.openstreetmap.store.MockLongMap;
 import org.apache.baremaps.openstreetmap.xml.XmlEntityReader;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
@@ -37,11 +37,11 @@ class RelationGeometryBuilderTest {
   Geometry handleRelation(String file) throws IOException {
     InputStream input = new GZIPInputStream(this.getClass().getResourceAsStream(file));
     List<Entity> entities = new XmlEntityReader().stream(input).toList();
-    LongDataMap<Coordinate> coordinateMap = new MockLongDataMap<>(
+    LongMap<Coordinate> coordinateMap = new MockLongMap<>(
         entities.stream().filter(e -> e instanceof Node).map(e -> (Node) e).collect(
             Collectors.toMap(n -> n.id(), n -> new Coordinate(n.getLon(), n.getLat()))));
-    LongDataMap<List<Long>> referenceMap =
-        new MockLongDataMap<>(entities.stream().filter(e -> e instanceof Way).map(e -> (Way) e)
+    LongMap<List<Long>> referenceMap =
+        new MockLongMap<>(entities.stream().filter(e -> e instanceof Way).map(e -> (Way) e)
             .collect(Collectors.toMap(w -> w.id(), w -> w.getNodes())));
     Relation relation = entities.stream().filter(e -> e instanceof Relation).map(e -> (Relation) e)
         .findFirst().get();
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/store/MockLongDataMap.java b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/store/MockLongMap.java
similarity index 87%
rename from baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/store/MockLongDataMap.java
rename to baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/store/MockLongMap.java
index 1500ac01..dc4a2916 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/store/MockLongDataMap.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/store/MockLongMap.java
@@ -17,13 +17,13 @@ package org.apache.baremaps.openstreetmap.store;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import org.apache.baremaps.collection.LongDataMap;
+import org.apache.baremaps.collection.LongMap;
 
-public class MockLongDataMap<T> implements LongDataMap<T> {
+public class MockLongMap<T> implements LongMap<T> {
 
   private final Map<Long, T> values;
 
-  public MockLongDataMap(Map<Long, T> values) {
+  public MockLongMap(Map<Long, T> values) {
     this.values = values;
   }
 
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/testing/PostgresContainerTest.java b/baremaps-core/src/test/java/org/apache/baremaps/testing/PostgresContainerTest.java
index 14f8ced7..e9837e50 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/testing/PostgresContainerTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/testing/PostgresContainerTest.java
@@ -32,7 +32,8 @@ public abstract class PostgresContainerTest {
   public void startContainer() {
     // start the container
     var postgis =
-        DockerImageName.parse("postgis/postgis:14-3.3").asCompatibleSubstituteFor("postgres");
+        DockerImageName.parse("ghcr.io/baosystems/postgis:14-3.3")
+            .asCompatibleSubstituteFor("postgres");
     container = new PostgreSQLContainer(postgis);
     container.start();