You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2023/02/08 22:32:55 UTC

[datasketches-java] branch theta_compact_iterator created (now 2d075a66)

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

alsay pushed a change to branch theta_compact_iterator
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git


      at 2d075a66 faster iterator

This branch includes the following new commits:

     new 2d075a66 faster iterator

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.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[datasketches-java] 01/01: faster iterator

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch theta_compact_iterator
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git

commit 2d075a66e42cf0c35eb31059b51e9b145a03cd09
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Wed Feb 8 14:32:47 2023 -0800

    faster iterator
---
 .../theta/HeapCompactHashIterator.java             | 41 ++++++++++++++++++++++
 .../datasketches/theta/HeapCompactSketch.java      |  2 +-
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/datasketches/theta/HeapCompactHashIterator.java b/src/main/java/org/apache/datasketches/theta/HeapCompactHashIterator.java
new file mode 100644
index 00000000..d5a6289c
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/theta/HeapCompactHashIterator.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.datasketches.theta;
+
+class HeapCompactHashIterator implements HashIterator {
+  private long[] cache;
+  private int index;
+
+  HeapCompactHashIterator(final long[] cache) {
+    this.cache = cache;
+    index = -1;
+  }
+
+  @Override
+  public long get() {
+    return cache[index];
+  }
+
+  @Override
+  public boolean next() {
+    return ++index < cache.length;
+  }
+
+}
diff --git a/src/main/java/org/apache/datasketches/theta/HeapCompactSketch.java b/src/main/java/org/apache/datasketches/theta/HeapCompactSketch.java
index 5b9bcaf9..f1606884 100644
--- a/src/main/java/org/apache/datasketches/theta/HeapCompactSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/HeapCompactSketch.java
@@ -123,7 +123,7 @@ class HeapCompactSketch extends CompactSketch {
 
   @Override
   public HashIterator iterator() {
-    return new HeapHashIterator(cache_, cache_.length, thetaLong_);
+    return new HeapCompactHashIterator(cache_);
   }
 
   //restricted methods


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org