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

bchapuis pushed a commit to branch 681-handle-the-out-of-memory-errors
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git


The following commit(s) were added to 
refs/heads/681-handle-the-out-of-memory-errors by this push:
     new fdde6d74 Add some javadoc and fix code smells
fdde6d74 is described below

commit fdde6d744e9a3fa0e065f4164aa292ab9bf7dde3
Author: Bertil Chapuis <[email protected]>
AuthorDate: Thu Jul 13 01:36:31 2023 +0200

    Add some javadoc and fix code smells
---
 .../collection/Long2LongOpenHashDataMap.java       | 38 +++++++++++++---------
 .../collection/Long2LongPackedOpenHashDataMap.java | 31 ++++++++++--------
 .../collection/Long2ObjectOpenHashDataMap.java     | 38 +++++++++++++---------
 3 files changed, 61 insertions(+), 46 deletions(-)

diff --git 
a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2LongOpenHashDataMap.java
 
b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2LongOpenHashDataMap.java
index 2b80a156..117fea28 100644
--- 
a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2LongOpenHashDataMap.java
+++ 
b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2LongOpenHashDataMap.java
@@ -33,59 +33,65 @@ import java.util.function.Supplier;
 public class Long2LongOpenHashDataMap extends AbstractLong2LongMap
     implements DataMap<Long>, Hash {
 
-  protected Supplier<AbstractDataList<Long>> keySupplier;
+  /**
+   * The array of keys supplier.
+   */
+  private transient final Supplier<AbstractDataList<Long>> keySupplier;
 
-  protected Supplier<AbstractDataList<Long>> valueSupplier;
+  /**
+   * The array of values supplier.
+   */
+  private transient final Supplier<AbstractDataList<Long>> valueSupplier;
 
   /**
    * The array of keys.
    */
-  protected AbstractDataList<Long> key;
+  private transient AbstractDataList<Long> key;
   /**
    * The array of values.
    */
-  protected AbstractDataList<Long> value;
+  private transient AbstractDataList<Long> value;
   /**
    * The mask for wrapping a position counter.
    */
-  protected long mask;
+  private transient long mask;
   /**
    * Whether this map contains the key zero.
    */
-  protected boolean containsNullKey;
+  private transient boolean containsNullKey;
   /**
    * The current table size.
    */
-  protected long n;
+  private transient long n;
   /**
    * Threshold after which we rehash. It must be the table size times {@link 
#f}.
    */
-  protected long maxFill;
+  private transient long maxFill;
   /**
    * We never resize below this threshold, which is the construction-time {#n}.
    */
-  protected final long minN;
+  private transient final long minN;
   /**
    * Number of entries in the set (including the key zero, if present).
    */
-  protected AtomicLong size = new AtomicLong();
+  private transient AtomicLong size = new AtomicLong();
   /**
    * The acceptable load factor.
    */
-  protected final float f;
+  private transient final float f;
   /**
    * Cached set of entries.
    */
-  protected FastEntrySet entries;
+  private transient FastEntrySet entries;
 
   /**
    * Cached set of keys.
    */
-  protected LongSet keys;
+  private transient LongSet keys;
   /**
    * Cached collection of values.
    */
-  protected LongCollection values;
+  private transient LongCollection values;
 
   /**
    * Creates a new hash map.
@@ -267,7 +273,7 @@ public class Long2LongOpenHashDataMap extends 
AbstractLong2LongMap
    *
    * @param pos a starting position.
    */
-  protected final void shiftKeys(long pos) {
+  private final void shiftKeys(long pos) {
     // Shift entries with the same hash.
     long last, slot;
     long curr;
@@ -1530,7 +1536,7 @@ public class Long2LongOpenHashDataMap extends 
AbstractLong2LongMap
    *
    * @param newN the new size
    */
-  protected void rehash(final long newN) {
+  private void rehash(final long newN) {
     final long mask = newN - 1; // Note that this is used by the hashing macro
     final AbstractDataList<Long> newKey = keySupplier.get();
     final AbstractDataList<Long> newValue = valueSupplier.get();
diff --git 
a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2LongPackedOpenHashDataMap.java
 
b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2LongPackedOpenHashDataMap.java
index 2b655863..679f1a0f 100644
--- 
a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2LongPackedOpenHashDataMap.java
+++ 
b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2LongPackedOpenHashDataMap.java
@@ -35,52 +35,55 @@ import org.apache.baremaps.database.type.PairDataType.Pair;
 public class Long2LongPackedOpenHashDataMap extends AbstractLong2LongMap
     implements DataMap<Long>, Hash {
 
-  private final Supplier<DataMap<Pair<Long, Long>>> indexSupplier;
+  /**
+   * The index supplier.
+   */
+  private transient final Supplier<DataMap<Pair<Long, Long>>> indexSupplier;
 
   /**
    * The hash index.
    */
-  protected DataMap<Pair<Long, Long>> index;
+  private transient DataMap<Pair<Long, Long>> index;
   /**
    * The mask for wrapping a position counter.
    */
-  protected long mask;
+  private transient long mask;
   /**
    * Whether this map contains the key zero.
    */
-  protected boolean containsNullKey;
+  private transient boolean containsNullKey;
   /**
    * The current table size.
    */
-  protected long n;
+  private transient long n;
   /**
    * Threshold after which we rehash. It must be the table size times {@link 
#f}.
    */
-  protected long maxFill;
+  private transient long maxFill;
   /**
    * We never resize below this threshold, which is the construction-time {#n}.
    */
-  protected final long minN;
+  private transient final long minN;
   /**
    * Number of entries in the set (including the key zero, if present).
    */
-  protected AtomicLong size = new AtomicLong();
+  private transient AtomicLong size = new AtomicLong();
   /**
    * The acceptable load factor.
    */
-  protected final float f;
+  private transient final float f;
   /**
    * Cached set of entries.
    */
-  protected FastEntrySet entries;
+  private transient FastEntrySet entries;
   /**
    * Cached set of keys.
    */
-  protected LongSet keys;
+  private transient LongSet keys;
   /**
    * Cached collection of values.
    */
-  protected LongCollection values;
+  private transient LongCollection values;
 
   /**
    * Creates a new hash map.
@@ -254,7 +257,7 @@ public class Long2LongPackedOpenHashDataMap extends 
AbstractLong2LongMap
    *
    * @param pos a starting position.
    */
-  protected final void shiftKeys(long pos) {
+  private final void shiftKeys(long pos) {
     // Shift entries with the same hash.
     long last, slot;
     long curr;
@@ -1533,7 +1536,7 @@ public class Long2LongPackedOpenHashDataMap extends 
AbstractLong2LongMap
    *
    * @param newN the new size
    */
-  protected void rehash(final long newN) {
+  private void rehash(final long newN) {
     final long mask = newN - 1; // Note that this is used by the hashing macro
     final DataMap<Pair<Long, Long>> newIndex = indexSupplier.get();
     long i = n, pos;
diff --git 
a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2ObjectOpenHashDataMap.java
 
b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2ObjectOpenHashDataMap.java
index 9330f18e..48426625 100644
--- 
a/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2ObjectOpenHashDataMap.java
+++ 
b/baremaps-core/src/main/java/org/apache/baremaps/database/collection/Long2ObjectOpenHashDataMap.java
@@ -37,58 +37,64 @@ import java.util.function.Supplier;
 public class Long2ObjectOpenHashDataMap<V> extends AbstractLong2ObjectMap<V>
     implements DataMap<V>, Hash {
 
-  private final Supplier<DataMap<Long>> keySupplier;
+  /**
+   * The array of keys supplier.
+   */
+  private transient final Supplier<DataMap<Long>> keySupplier;
 
-  private final Supplier<DataMap<V>> valueSupplier;
+  /**
+   * The array of values supplier.
+   */
+  private transient final Supplier<DataMap<V>> valueSupplier;
 
   /**
    * The array of keys.
    */
-  protected DataMap<Long> key;
+  private transient DataMap<Long> key;
   /**
    * The array of values.
    */
-  protected DataMap<V> value;
+  private transient DataMap<V> value;
   /**
    * The mask for wrapping a position counter.
    */
-  protected long mask;
+  private transient long mask;
   /**
    * Whether this map contains the key zero.
    */
-  protected boolean containsNullKey;
+  private transient boolean containsNullKey;
   /**
    * The current table size.
    */
-  protected long n;
+  private transient long n;
   /**
    * Threshold after which we rehash. It must be the table size times {@link 
#f}.
    */
-  protected long maxFill;
+  private transient long maxFill;
   /**
    * We never resize below this threshold, which is the construction-time {#n}.
    */
-  protected final long minN;
+  private transient final long minN;
   /**
    * Number of entries in the set (including the key zero, if present).
    */
-  protected AtomicLong size = new AtomicLong();;
+  private transient AtomicLong size = new AtomicLong();;
   /**
    * The acceptable load factor.
    */
-  protected final float f;
+  private transient final float f;
   /**
    * Cached set of entries.
    */
-  protected FastEntrySet<V> entries;
+  private transient FastEntrySet<V> entries;
   /**
    * Cached set of keys.
    */
-  protected LongSet keys;
+  private transient LongSet keys;
   /**
    * Cached collection of values.
    */
-  protected ObjectCollection<V> values;
+  private transient ObjectCollection<V> values;
 
   /**
    * Creates a new hash map.
@@ -226,7 +232,7 @@ public class Long2ObjectOpenHashDataMap<V> extends 
AbstractLong2ObjectMap<V>
    *
    * @param pos a starting position.
    */
-  protected final void shiftKeys(long pos) {
+  private void shiftKeys(long pos) {
     // Shift entries with the same hash.
     long last, slot;
     long curr;
@@ -1445,7 +1451,7 @@ public class Long2ObjectOpenHashDataMap<V> extends 
AbstractLong2ObjectMap<V>
    *
    * @param newN the new size
    */
-  protected void rehash(final long newN) {
+  private void rehash(final long newN) {
     final long mask = newN - 1; // Note that this is used by the hashing macro
     final DataMap<Long> newKey = keySupplier.get();
     final DataMap<V> newValue = valueSupplier.get();

Reply via email to