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/07/12 13:34:06 UTC

[incubator-baremaps] branch 681-handle-the-out-of-memory-errors updated (682b70bc -> 5492e0c0)

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

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


    omit 682b70bc Improve documentation
     new 5492e0c0 Improve documentation

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (682b70bc)
            \
             N -- N -- N   refs/heads/681-handle-the-out-of-memory-errors (5492e0c0)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../baremaps/database/collection/Long2LongOpenHashDataMap.java       | 2 --
 .../baremaps/database/collection/Long2LongPackedOpenHashDataMap.java | 2 --
 .../baremaps/database/collection/Long2ObjectOpenHashDataMap.java     | 5 -----
 3 files changed, 9 deletions(-)


[incubator-baremaps] 01/01: Improve documentation

Posted by bc...@apache.org.
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

commit 5492e0c06c8415bc55ad259d487a15a9a33e093c
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Wed Jul 12 15:31:41 2023 +0200

    Improve documentation
---
 .../collection/Long2LongOpenHashDataMap.java       | 35 ++-----------
 .../collection/Long2LongPackedOpenHashDataMap.java | 36 ++-----------
 .../collection/Long2ObjectOpenHashDataMap.java     | 61 ++--------------------
 3 files changed, 13 insertions(+), 119 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 00e374be..cba05892 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
@@ -25,6 +25,11 @@ import java.util.function.Consumer;
 import java.util.function.LongConsumer;
 import java.util.function.Supplier;
 
+/**
+ * An open addressed hash map of long keys and long values derived from fastutil's
+ * {@link Long2LongOpenHashMap}. This implementation allows for the use of on-heap, off-heap, or
+ * memory mapped memory.
+ */
 public class Long2LongOpenHashDataMap extends AbstractLong2LongMap
     implements DataMap<Long>, Hash {
 
@@ -728,7 +733,6 @@ public class Long2LongOpenHashDataMap extends AbstractLong2LongMap
       return setValue((v).longValue());
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public boolean equals(final Object o) {
       if (!(o instanceof Map.Entry)) {
@@ -780,7 +784,6 @@ public class Long2LongOpenHashDataMap extends AbstractLong2LongMap
      */
     LongArrayList wrapped;
 
-    @SuppressWarnings("unused")
     abstract void acceptOnIndex(final ConsumerType action, final long index);
 
     public boolean hasNext() {
@@ -1547,32 +1550,4 @@ public class Long2LongOpenHashDataMap extends AbstractLong2LongMap
     this.key = newKey;
     this.value = newValue;
   }
-
-  /**
-   * Returns a hash code for this map.
-   * <p>
-   * This method overrides the generic method provided by the superclass. Since {@code equals()} is
-   * not overriden, it is important that the value returned by this method is the same value as the
-   * one returned by the overriden method.
-   *
-   * @return a hash code for this map.
-   */
-  @Override
-  public int hashCode() {
-    int h = 0;
-    for (long j = realSize(), i = 0, t = 0; j-- != 0;) {
-      while (((key.get(i)) == 0)) {
-        i++;
-      }
-      t = HashCommon.long2int(key.get(i));
-      t ^= HashCommon.long2int(value.get(i));
-      h += t;
-      i++;
-    }
-    // Zero / null keys have hash zero.
-    if (containsNullKey) {
-      h += HashCommon.long2int(value.get(n));
-    }
-    return h;
-  }
 }
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 7979e2c4..419234ae 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
@@ -27,6 +27,11 @@ import java.util.function.LongConsumer;
 import java.util.function.Supplier;
 import org.apache.baremaps.database.type.PairDataType.Pair;
 
+/**
+ * An open addressed hash map of long keys and long values derived from fastutil's
+ * {@link Long2LongOpenHashMap}. This implementation allows for the use of on-heap, off-heap, or
+ * memory mapped memory. The keys and values are packed in the same memory.
+ */
 public class Long2LongPackedOpenHashDataMap extends AbstractLong2LongMap
     implements DataMap<Long>, Hash {
 
@@ -717,7 +722,6 @@ public class Long2LongPackedOpenHashDataMap extends AbstractLong2LongMap
       return setValue(v);
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public boolean equals(final Object o) {
       if (!(o instanceof Map.Entry)) {
@@ -772,7 +776,6 @@ public class Long2LongPackedOpenHashDataMap extends AbstractLong2LongMap
      */
     LongArrayList wrapped;
 
-    @SuppressWarnings("unused")
     abstract void acceptOnIndex(final ConsumerType action, final long index);
 
     public boolean hasNext() {
@@ -1549,33 +1552,4 @@ public class Long2LongPackedOpenHashDataMap extends AbstractLong2LongMap
     this.maxFill = maxFill(n, f);
     this.index = newIndex;
   }
-
-  /**
-   * Returns a hash code for this map.
-   * <p>
-   * This method overrides the generic method provided by the superclass. Since {@code equals()} is
-   * not overriden, it is important that the value returned by this method is the same value as the
-   * one returned by the overriden method.
-   *
-   * @return a hash code for this map.
-   */
-  @Override
-  public int hashCode() {
-    int h = 0;
-    for (long j = realSize(), i = 0, t = 0; j-- != 0;) {
-      Pair<Long, Long> pair;
-      while (((pair = index.get(i)).left() == 0)) {
-        i++;
-      }
-      t = HashCommon.long2int(pair.left());
-      t ^= HashCommon.long2int(pair.right());
-      h += t;
-      i++;
-    }
-    // Zero / null keys have hash zero.
-    if (containsNullKey) {
-      h += HashCommon.long2int(index.get(n).right());
-    }
-    return h;
-  }
 }
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 7922fcbd..a4fc0cd4 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
@@ -30,28 +30,9 @@ import java.util.function.Consumer;
 import java.util.function.Supplier;
 
 /**
- * A type-specific hash map with a fast, small-footprint implementation.
- *
- * <p>
- * Instances of this class use a hash table to represent a map. The table is filled up to a
- * specified <em>load factor</em>, and then doubled in size to accommodate new entries. If the table
- * is emptied below <em>one fourth</em> of the load factor, it is halved in size; however, the table
- * is never reduced to a size smaller than that at creation time: this approach makes it possible to
- * create maps with a large capacity in which insertions and deletions do not cause immediately
- * rehashing. Moreover, halving is not performed when deleting entries from an iterator, as it would
- * interfere with the iteration process.
- *
- * <p>
- * Note that {@link #clear()} does not modify the hash table size. Rather, a family of
- * {@linkplain #trim() trimming methods} lets you control the size of the table; this is
- * particularly useful if you reuse instances of this class.
- *
- * <p>
- * Entries returned by the type-specific {@link #entrySet()} method implement the suitable
- * type-specific {@link it.unimi.dsi.fastutil.Pair Pair} interface; only values are mutable.
- *
- * @see Hash
- * @see HashCommon
+ * An open addressed hash map of long keys and long values derived from fastutil's
+ * {@link Long2ObjectOpenHashMap}. This implementation allows for the use of on-heap, off-heap, or
+ * memory mapped memory.
  */
 public class Long2ObjectOpenHashDataMap<V> extends AbstractLong2ObjectMap<V>
     implements DataMap<V>, Hash {
@@ -118,7 +99,6 @@ public class Long2ObjectOpenHashDataMap<V> extends AbstractLong2ObjectMap<V>
    * @param expected the expected number of elements in the hash map.
    * @param f the load factor.
    */
-  @SuppressWarnings("unchecked")
   public Long2ObjectOpenHashDataMap(
       final long expected,
       final float f,
@@ -675,7 +655,6 @@ public class Long2ObjectOpenHashDataMap<V> extends AbstractLong2ObjectMap<V>
       return Long.valueOf(key.get(index));
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public boolean equals(final Object o) {
       if (!(o instanceof Map.Entry)) {
@@ -728,7 +707,6 @@ public class Long2ObjectOpenHashDataMap<V> extends AbstractLong2ObjectMap<V>
      */
     LongArrayList wrapped;
 
-    @SuppressWarnings("unused")
     abstract void acceptOnIndex(final ConsumerType action, final long index);
 
     public boolean hasNext() {
@@ -1065,7 +1043,6 @@ public class Long2ObjectOpenHashDataMap<V> extends AbstractLong2ObjectMap<V>
 
     //
     @Override
-    @SuppressWarnings("unchecked")
     public boolean contains(final Object o) {
       if (!(o instanceof Map.Entry)) {
         return false;
@@ -1101,7 +1078,6 @@ public class Long2ObjectOpenHashDataMap<V> extends AbstractLong2ObjectMap<V>
     }
 
     @Override
-    @SuppressWarnings("unchecked")
     public boolean remove(final Object o) {
       if (!(o instanceof Map.Entry)) {
         return false;
@@ -1469,7 +1445,6 @@ public class Long2ObjectOpenHashDataMap<V> extends AbstractLong2ObjectMap<V>
    *
    * @param newN the new size
    */
-  @SuppressWarnings("unchecked")
   protected 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();
@@ -1490,34 +1465,4 @@ public class Long2ObjectOpenHashDataMap<V> extends AbstractLong2ObjectMap<V>
     this.key = newKey;
     this.value = newValue;
   }
-
-  /**
-   * Returns a hash code for this map.
-   * <p>
-   * This method overrides the generic method provided by the superclass. Since {@code equals()} is
-   * not overriden, it is important that the value returned by this method is the same value as the
-   * one returned by the overriden method.
-   *
-   * @return a hash code for this map.
-   */
-  @Override
-  public int hashCode() {
-    int h = 0;
-    for (long j = realSize(), i = 0, t = 0; j-- != 0;) {
-      while (((key.get(i)) == 0)) {
-        i++;
-      }
-      t = HashCommon.long2int(key.get(i));
-      if (this != value.get(i)) {
-        t ^= ((value.get(i)) == null ? 0 : (value.get(i)).hashCode());
-      }
-      h += t;
-      i++;
-    }
-    // Zero / null keys have hash zero.
-    if (containsNullKey) {
-      h += ((value.get(n)) == null ? 0 : (value.get(n)).hashCode());
-    }
-    return h;
-  }
 }