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

leerho pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/datasketches-characterization.git

commit ed31fdc282853c6740a5fa716010ec066764ec6b
Author: Lee Rhodes <[email protected]>
AuthorDate: Mon Jan 27 10:21:11 2025 -0800

    Most of these changes remove references to the "Handle" hierarchy, which
    was removed in Memory 3.X.
    
    Also the UTF8 classes were also removed in preparation for FMM which has
    that functionality built in.
---
 pom.xml                                            |   4 +-
 .../org/apache/datasketches/DirectoryWalker.java   |   8 +-
 .../characterization/hll/HllAccuracyProfile.java   |   1 +
 .../hll/HllUpdateSpeedProfile.java                 |  15 +-
 .../memory/BaseUtf8SpeedProfile.java               | 230 ---------------------
 .../memory/HeapUtf8SpeedProfile.java               |  95 ---------
 .../memory/MemoryDirectSpeedProfile.java           |  15 +-
 .../theta/ThetaUpdateSpeedProfile.java             |   7 +-
 .../concurrent/ConcurrentThetaAccuracyProfile.java |   9 +-
 .../ConcurrentThetaMultithreadedSpeedProfile.java  |   5 +-
 .../ConcurrentThetaUpdateSpeedProfile.java         |   5 +-
 .../tuple/AodSketchUpdateSpeedProfile.java         |   7 +-
 12 files changed, 29 insertions(+), 372 deletions(-)

diff --git a/pom.xml b/pom.xml
index 552da6c..55a40dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,8 +85,8 @@ under the License.
 
   <properties>
     <!-- UNIQUE FOR THIS JAVA COMPONENT -->
-    <datasketches-memory.version>2.2.0</datasketches-memory.version>
-    <datasketches-java.version>6.0.0</datasketches-java.version>
+    <datasketches-memory.version>3.0.2</datasketches-memory.version>
+    <datasketches-java.version>6.2.0</datasketches-java.version>
     <!-- END:UNIQUE FOR THIS JAVA COMPONENT -->
 
     <!-- Test -->
diff --git a/src/main/java/org/apache/datasketches/DirectoryWalker.java 
b/src/main/java/org/apache/datasketches/DirectoryWalker.java
index fb7ecc0..8c551e1 100644
--- a/src/main/java/org/apache/datasketches/DirectoryWalker.java
+++ b/src/main/java/org/apache/datasketches/DirectoryWalker.java
@@ -24,7 +24,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Pattern;
 
-//import org.testng.annotations.Test;
+import org.testng.annotations.Test;
 
 /**
  * Recursive directory search.
@@ -131,10 +131,10 @@ public class DirectoryWalker {
     return fileList;
   }
 
-  //@Test //example
+  @Test //example
   public static void printFiles() {
-    final String rootPath = 
"/Users/lrhodes/dev/git/Apache/datasketches-memory/src/";
-    final String fileSelector = ".+[.]java";
+    final String rootPath = 
"/Users/lrhodes/dev/git/Apache/datasketches-bigquery/";
+    final String fileSelector = ".+[.]sqlx";
     final boolean recursive = true;
 
     final List<String> fileList = appendFileList(rootPath, fileSelector, 
recursive);
diff --git 
a/src/main/java/org/apache/datasketches/characterization/hll/HllAccuracyProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/hll/HllAccuracyProfile.java
index c93abb2..9b16246 100644
--- 
a/src/main/java/org/apache/datasketches/characterization/hll/HllAccuracyProfile.java
+++ 
b/src/main/java/org/apache/datasketches/characterization/hll/HllAccuracyProfile.java
@@ -25,6 +25,7 @@ import org.apache.datasketches.hll.HllSketch;
 import org.apache.datasketches.hll.TgtHllType;
 import org.apache.datasketches.memory.WritableMemory;
 
+@SuppressWarnings("resource")
 public class HllAccuracyProfile extends BaseAccuracyProfile {
   private HllSketch sketch;
   private boolean useComposite; //accuracy, HLL
diff --git 
a/src/main/java/org/apache/datasketches/characterization/hll/HllUpdateSpeedProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/hll/HllUpdateSpeedProfile.java
index 2468424..2cef9fe 100644
--- 
a/src/main/java/org/apache/datasketches/characterization/hll/HllUpdateSpeedProfile.java
+++ 
b/src/main/java/org/apache/datasketches/characterization/hll/HllUpdateSpeedProfile.java
@@ -22,7 +22,6 @@ package org.apache.datasketches.characterization.hll;
 import 
org.apache.datasketches.characterization.uniquecount.BaseUpdateSpeedProfile;
 import org.apache.datasketches.hll.HllSketch;
 import org.apache.datasketches.hll.TgtHllType;
-import org.apache.datasketches.memory.WritableHandle;
 import org.apache.datasketches.memory.WritableMemory;
 
 /**
@@ -30,7 +29,6 @@ import org.apache.datasketches.memory.WritableMemory;
  */
 public class HllUpdateSpeedProfile extends BaseUpdateSpeedProfile {
   private HllSketch sketch;
-  private WritableHandle handle;
   private WritableMemory wmem;
 
   @Override
@@ -46,8 +44,7 @@ public class HllUpdateSpeedProfile extends 
BaseUpdateSpeedProfile {
 
     if (offheap) {
       final int bytes = HllSketch.getMaxUpdatableSerializationBytes(lgK, 
tgtHllType);
-      handle = WritableMemory.allocateDirect(bytes);
-      wmem = handle.getWritable();
+      wmem = WritableMemory.allocateDirect(bytes);
       sketch = new HllSketch(lgK, tgtHllType, wmem);
     } else {
       sketch = new HllSketch(lgK, tgtHllType);
@@ -56,12 +53,12 @@ public class HllUpdateSpeedProfile extends 
BaseUpdateSpeedProfile {
 
   @Override
   public void cleanup() {
-    try {
-      if (handle != null) {
-        handle.close();
+    if (wmem.isAlive()) {
+      try {
+          wmem.close();
+      } catch (final Exception e) {
+        // do nothing
       }
-    } catch (final Exception e) {
-      // do nothing
     }
   }
 
diff --git 
a/src/main/java/org/apache/datasketches/characterization/memory/BaseUtf8SpeedProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/memory/BaseUtf8SpeedProfile.java
deleted file mode 100644
index b31b398..0000000
--- 
a/src/main/java/org/apache/datasketches/characterization/memory/BaseUtf8SpeedProfile.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * 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.characterization.memory;
-
-import static java.lang.Math.log;
-import static java.lang.Math.pow;
-import static org.apache.datasketches.common.Util.pwr2SeriesNext;
-//import static org.testng.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.datasketches.Job;
-import org.apache.datasketches.JobProfile;
-import org.apache.datasketches.Properties;
-import org.apache.datasketches.memory.Memory;
-
-/**
- * @author Lee Rhodes
- */
-public abstract class BaseUtf8SpeedProfile implements JobProfile {
-  Job job;
-  Properties prop;
-  int lgMinT;
-  int lgMaxT;
-  int lgMinX;
-  int lgMaxX;
-  int xPPO;
-  int lgMinBpX; //for reducing Trials as X increases
-  int lgMaxBpX;
-  double slope;
-  TrialStats stats;
-  Point point;
-
-  static final class TrialStats { //Data for one Trial, created once
-    int[] cpArr; //created once per trial set
-    double javaEncodeTime_nS; //updated every trial
-    double javaDecodeTime_nS;
-    double memEncodeTime_nS;
-    double memDecodeTime_nS;
-  }
-
-  static class Point { //Data for a Trial Set, created only once.
-    static String fmt =
-          "%.2f " + TAB //LgCP/T float
-        + "%d "   + TAB //CP/T int
-        + "%d "   + TAB //Trials int
-        + "%d "   + TAB //totCP long
-        + "%.1f " + TAB //java en
-        + "%.1f " + TAB //java de
-        + "%.1f " + TAB //mem en
-        + "%.1f";       //mem de
-    int numCPPerTrial = 0;
-    int trials = 0;
-    double sumJavaEncodeTrials_nS = 0;
-    double sumJavaDecodeTrials_nS = 0;
-    double sumMemEncodeTrials_nS = 0;
-    double sumMemDecodeTrials_nS = 0;
-
-    void update(final TrialStats stats) {
-      sumJavaEncodeTrials_nS += stats.javaEncodeTime_nS;
-      sumJavaDecodeTrials_nS += stats.javaDecodeTime_nS;
-      sumMemEncodeTrials_nS += stats.memEncodeTime_nS;
-      sumMemDecodeTrials_nS += stats.memDecodeTime_nS;
-    }
-
-    void clear() {
-      sumJavaEncodeTrials_nS = 0;
-      sumJavaDecodeTrials_nS = 0;
-      sumMemEncodeTrials_nS = 0;
-      sumMemDecodeTrials_nS = 0;
-    }
-
-    static String getHeader() {
-      final String s =
-            "LgCP/T" + TAB
-          + "CP/T" + TAB
-          + "Trials" + TAB
-          + "TotCP" + TAB
-          + "JEnc" + TAB
-          + "JDec" + TAB
-          + "MEnc" + TAB
-          + "MDec";
-      return s;
-    }
-
-    String getRow() {
-      final double lgCP = Math.log(numCPPerTrial) / LN2;
-      final long totCP = (long)trials * numCPPerTrial;
-      final double meanJavaEncodePerCP_nS = sumJavaEncodeTrials_nS / totCP;
-      final double meanJavaDecodePerCP_nS = sumJavaDecodeTrials_nS / totCP;
-      final double meanMemEncodePerCP_nS = sumMemEncodeTrials_nS / totCP;
-      final double meanMemDecodePerCP_nS = sumMemDecodeTrials_nS / totCP;
-
-      final String out = String.format(fmt, lgCP, numCPPerTrial, trials, totCP,
-          meanJavaEncodePerCP_nS, meanJavaDecodePerCP_nS,
-          meanMemEncodePerCP_nS, meanMemDecodePerCP_nS);
-      return out;
-    }
-  }
-
-  //JobProfile
-  @Override
-  public void start(final Job job) {
-    this.job = job;
-    prop = job.getProperties();
-    lgMinT = Integer.parseInt(prop.mustGet("Trials_lgMinT"));
-    lgMaxT = Integer.parseInt(prop.mustGet("Trials_lgMaxT"));
-    lgMinX = Integer.parseInt(prop.mustGet("Trials_lgMinX"));
-    lgMaxX = Integer.parseInt(prop.mustGet("Trials_lgMaxX"));
-    xPPO = Integer.parseInt(prop.mustGet("Trials_XPPO"));
-    lgMinBpX = Integer.parseInt(prop.mustGet("Trials_lgMinBpX"));
-    lgMaxBpX = Integer.parseInt(prop.mustGet("Trials_lgMaxBpX"));
-    slope = (double) (lgMaxT - lgMinT) / (lgMinBpX - lgMaxBpX);
-    stats = new TrialStats();
-    point = new Point();
-    doTrials();
-    close();
-  }
-
-  @Override
-  public void shutdown() {}
-
-  @Override
-  public void cleanup() {}
-  //end JobProfile
-
-  abstract void configure();
-
-  abstract void doTrial(TrialStats stats);
-
-  abstract void close();
-
-  private void doTrials() {
-    job.println(Point.getHeader()); //GG
-    final int maxX = 1 << lgMaxX;
-    final int minX = 1 << lgMinX;
-    int lastX = 0;
-    while (lastX < maxX) { //do each plot point on the X-axis
-      final int nextX = lastX == 0 ? minX : (int)pwr2SeriesNext(xPPO, lastX);
-      lastX = nextX;
-      final int trials = getNumTrials(nextX);
-      //configure();
-      point.clear();
-      point.numCPPerTrial = nextX;
-      point.trials = trials;
-      stats.cpArr = new int[nextX];  //GG
-      // Do all trials
-      System.gc();
-      for (int t = 0; t < trials; t++) { // do # trials
-        doTrial(stats); // a single trial encode
-        point.update(stats);
-      }
-      job.println(point.getRow()); //output summary of trail set at this X 
point //GG
-    }
-  }
-
-  /**
-   * Computes the number of trials for a given current number of uniques for a
-   * trial set. This is used in speed trials and decreases the number of trials
-   * as the number of uniques increase.
-   *
-   * @param curX the given current number of uniques for a trial set.
-   * @return the number of trials for a given current number of uniques for a
-   * trial set.
-   */
-  private int getNumTrials(final int curX) {
-    final int minBpX = 1 << lgMinBpX;
-    final int maxBpX = 1 << lgMaxBpX;
-    final int maxT = 1 << lgMaxT;
-    final int minT = 1 << lgMinT;
-    if (lgMinT == lgMaxT || curX <= minBpX) {
-      return maxT;
-    }
-    if (curX >= maxBpX) {
-      return minT;
-    }
-    final double lgCurX = log(curX) / LN2;
-    final double lgTrials = slope * (lgCurX - lgMinBpX) + lgMaxT;
-    return (int) pow(2.0, lgTrials);
-  }
-
-  /**
-   * Checks that expected String == actual String, and if there is an error,
-   * prints out the different codepoints.
-   * @param actual given
-   * @param expected given
-   */
-  static void checkStrings(final String actual, final String expected) {
-    if (!expected.equals(actual)) {
-      throw new IllegalStateException(
-      "Failure: Expected (" + codepoints(expected) + ") Actual (" + 
codepoints(actual) + ")");
-    }
-  }
-
-  static void checkMemBytes(final Memory actual, final Memory expected) {
-    final long ecap = expected.getCapacity();
-    final long acap = actual.getCapacity();
-    final int comp = expected.compareTo(0, ecap, actual, 0, acap);
-    if (comp != 0) {
-      throw new IllegalArgumentException("Memory actual != Memory expected");
-    }
-  }
-
-  private static List<String> codepoints(final String str) {
-    final List<String> codepoints = new ArrayList<>();
-    for (int i = 0; i < str.length(); i++) {
-      codepoints.add(Long.toHexString(str.charAt(i)));
-    }
-    return codepoints;
-  }
-
-}
diff --git 
a/src/main/java/org/apache/datasketches/characterization/memory/HeapUtf8SpeedProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/memory/HeapUtf8SpeedProfile.java
deleted file mode 100644
index c4f798a..0000000
--- 
a/src/main/java/org/apache/datasketches/characterization/memory/HeapUtf8SpeedProfile.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.characterization.memory;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-import org.apache.datasketches.memory.Memory;
-import org.apache.datasketches.memory.WritableMemory;
-import org.apache.datasketches.memory.internal.Util.RandomCodePoints;
-
-/**
- * @author Lee Rhodes
- */
-public class HeapUtf8SpeedProfile extends BaseUtf8SpeedProfile {
-  RandomCodePoints randCP = new RandomCodePoints(false); //only with Memory 
0.10.4 and later
-
-  @Override
-  void configure() {
-
-  }
-
-  @Override
-  void doTrial(final TrialStats stats) {
-    final int[] cpArr = stats.cpArr;
-    final int cpArrLen = cpArr.length;
-
-    randCP.fillCodePointArray(cpArr);
-    final String javaStr = new String(cpArr, 0, cpArrLen); //Java String 
reference //GG-U
-    final int javaStrLen = javaStr.length();
-    final byte[] javaByteArr;
-    final int javaByteArrLen;
-    final WritableMemory wMem;
-    long startTime;
-    long stopTime;
-
-    //measure Java encode time
-    startTime = System.nanoTime();
-    javaByteArr = javaStr.getBytes(UTF_8); //Java byteArr reference //GG-U
-    stopTime = System.nanoTime();
-    stats.javaEncodeTime_nS = stopTime - startTime;
-
-    javaByteArrLen = javaByteArr.length;
-
-    //measure Java decode time
-    startTime = System.nanoTime();
-    final String javaStr2 = new String(javaByteArr, UTF_8);
-    stopTime = System.nanoTime();
-    stats.javaDecodeTime_nS = stopTime - startTime;
-
-    checkStrings(javaStr2, javaStr);
-
-    //prepare Memory measurements
-    wMem = WritableMemory.allocate(javaByteArrLen); //GG
-    final StringBuilder sb = new StringBuilder(javaStrLen); //GG
-
-    //measure Memory encode time
-    startTime = System.nanoTime();
-    wMem.putCharsToUtf8(0, javaStr);
-    stopTime = System.nanoTime();
-    stats.memEncodeTime_nS = stopTime - startTime;
-
-    checkMemBytes(Memory.wrap(javaByteArr), wMem); //GG
-
-    //measure Memory decode time
-    startTime = System.nanoTime();
-    wMem.getCharsFromUtf8(0, javaByteArrLen, sb);
-    stopTime = System.nanoTime();
-    stats.memDecodeTime_nS = stopTime - startTime;
-
-    checkStrings(sb.toString(), javaStr); //GG-U
-
-  }
-
-  @Override
-  void close() {
-  }
-
-}
diff --git 
a/src/main/java/org/apache/datasketches/characterization/memory/MemoryDirectSpeedProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/memory/MemoryDirectSpeedProfile.java
index 1a3cd35..ae20d7d 100644
--- 
a/src/main/java/org/apache/datasketches/characterization/memory/MemoryDirectSpeedProfile.java
+++ 
b/src/main/java/org/apache/datasketches/characterization/memory/MemoryDirectSpeedProfile.java
@@ -19,7 +19,6 @@
 
 package org.apache.datasketches.characterization.memory;
 
-import org.apache.datasketches.memory.WritableHandle;
 import org.apache.datasketches.memory.WritableMemory;
 
 /**
@@ -27,22 +26,22 @@ import org.apache.datasketches.memory.WritableMemory;
  */
 public class MemoryDirectSpeedProfile extends BaseSpeedProfile {
   int arrLongs;
-  WritableHandle wh;
   WritableMemory wmem;
 
   @Override
   void configure(final int arrLongs) {
     this.arrLongs = arrLongs;
-    wh = WritableMemory.allocateDirect(arrLongs << 3);
-    wmem = wh.getWritable();
+    wmem = WritableMemory.allocateDirect(arrLongs << 3);
   }
 
   @Override
   void close() {
-    try {
-      wh.close();
-    } catch (final Exception e) {
-      // do nothing
+    if (wmem.isAlive()) {
+      try {
+        wmem.close();
+      } catch (final Exception e) {
+        // do nothing
+      }
     }
   }
 
diff --git 
a/src/main/java/org/apache/datasketches/characterization/theta/ThetaUpdateSpeedProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/theta/ThetaUpdateSpeedProfile.java
index 287da2c..449cde3 100644
--- 
a/src/main/java/org/apache/datasketches/characterization/theta/ThetaUpdateSpeedProfile.java
+++ 
b/src/main/java/org/apache/datasketches/characterization/theta/ThetaUpdateSpeedProfile.java
@@ -22,7 +22,6 @@ package org.apache.datasketches.characterization.theta;
 import 
org.apache.datasketches.characterization.uniquecount.BaseUpdateSpeedProfile;
 import org.apache.datasketches.common.Family;
 import org.apache.datasketches.common.ResizeFactor;
-import org.apache.datasketches.memory.WritableHandle;
 import org.apache.datasketches.memory.WritableMemory;
 import org.apache.datasketches.theta.Sketch;
 import org.apache.datasketches.theta.UpdateSketch;
@@ -33,7 +32,6 @@ import org.apache.datasketches.theta.UpdateSketchBuilder;
  */
 public class ThetaUpdateSpeedProfile extends BaseUpdateSpeedProfile {
   protected UpdateSketch sketch;
-  private WritableHandle handle;
   private WritableMemory wmem;
 
   @Override
@@ -53,8 +51,7 @@ public class ThetaUpdateSpeedProfile extends 
BaseUpdateSpeedProfile {
         .setResizeFactor(rf);
     if (offheap) {
       final int bytes = Sketch.getMaxUpdateSketchBytes(k);
-      handle = WritableMemory.allocateDirect(bytes);
-      wmem = handle.getWritable();
+      wmem = WritableMemory.allocateDirect(bytes);
       sketch = udBldr.build(wmem);
     } else {
       sketch = udBldr.build();
@@ -64,7 +61,7 @@ public class ThetaUpdateSpeedProfile extends 
BaseUpdateSpeedProfile {
   @Override
   public void cleanup() {
     try {
-      if (handle != null) { handle.close(); }
+      if (wmem.isAlive()) { wmem.close(); }
     } catch (final Exception e) {
       // do nothing
     }
diff --git 
a/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaAccuracyProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaAccuracyProfile.java
index c1f8e77..fd510f4 100644
--- 
a/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaAccuracyProfile.java
+++ 
b/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaAccuracyProfile.java
@@ -23,7 +23,6 @@ import static 
org.apache.datasketches.thetacommon.ThetaUtil.DEFAULT_UPDATE_SEED;
 
 import org.apache.datasketches.characterization.AccuracyStats;
 import 
org.apache.datasketches.characterization.uniquecount.BaseAccuracyProfile;
-import org.apache.datasketches.memory.WritableHandle;
 import org.apache.datasketches.memory.WritableMemory;
 import org.apache.datasketches.theta.Sketch;
 import org.apache.datasketches.theta.UpdateSketch;
@@ -42,7 +41,6 @@ public class ConcurrentThetaAccuracyProfile extends 
BaseAccuracyProfile {
   private boolean ordered;
   private boolean offHeap;
   private boolean rebuild; //Theta QS Sketch Accuracy
-  private WritableHandle wdh;
   private WritableMemory wmem;
 
   @Override
@@ -59,8 +57,7 @@ public class ConcurrentThetaAccuracyProfile extends 
BaseAccuracyProfile {
     final int maxSharedUpdateBytes = Sketch.getMaxUpdateSketchBytes(1 << 
sharedLgK);
 
     if (offHeap) {
-      wdh = WritableMemory.allocateDirect(maxSharedUpdateBytes);
-      wmem = wdh.getWritable();
+      wmem = WritableMemory.allocateDirect(maxSharedUpdateBytes);
     } else {
       wmem = WritableMemory.allocate(maxSharedUpdateBytes);
     }
@@ -95,8 +92,8 @@ public class ConcurrentThetaAccuracyProfile extends 
BaseAccuracyProfile {
   @Override
   public void cleanup() {
     try {
-      if (wdh != null) {
-        wdh.close();
+      if (wmem.isAlive()) {
+        wmem.close();
       }
     } catch (final Exception e) {
       // do nothing
diff --git 
a/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaMultithreadedSpeedProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaMultithreadedSpeedProfile.java
index 4218edc..73a14f3 100644
--- 
a/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaMultithreadedSpeedProfile.java
+++ 
b/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaMultithreadedSpeedProfile.java
@@ -26,7 +26,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 import 
org.apache.datasketches.characterization.concurrent.ConcurrentTestContext;
 import 
org.apache.datasketches.characterization.concurrent.ConcurrentTestThread;
 import 
org.apache.datasketches.characterization.uniquecount.BaseUpdateSpeedProfile;
-import org.apache.datasketches.memory.WritableHandle;
 import org.apache.datasketches.memory.WritableMemory;
 import org.apache.datasketches.theta.Sketch;
 import org.apache.datasketches.theta.UpdateSketch;
@@ -47,7 +46,6 @@ public class ConcurrentThetaMultithreadedSpeedProfile extends 
BaseUpdateSpeedPro
   private boolean offHeap;
   private int poolThreads;
   private double maxConcurrencyError;
-  private WritableHandle wdh;
   private WritableMemory wmem;
 
   private int numWriterThreads;
@@ -76,8 +74,7 @@ public class ConcurrentThetaMultithreadedSpeedProfile extends 
BaseUpdateSpeedPro
     final int maxSharedUpdateBytes = Sketch.getMaxUpdateSketchBytes(1 << 
sharedLgK);
 
     if (offHeap) {
-      wdh = WritableMemory.allocateDirect(maxSharedUpdateBytes);
-      wmem = wdh.getWritable();
+      wmem = WritableMemory.allocateDirect(maxSharedUpdateBytes);
     } else {
       wmem = null; //WritableMemory.allocate(maxSharedUpdateBytes);
     }
diff --git 
a/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaUpdateSpeedProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaUpdateSpeedProfile.java
index b341f5f..856446d 100644
--- 
a/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaUpdateSpeedProfile.java
+++ 
b/src/main/java/org/apache/datasketches/characterization/theta/concurrent/ConcurrentThetaUpdateSpeedProfile.java
@@ -22,7 +22,6 @@ package 
org.apache.datasketches.characterization.theta.concurrent;
 import static 
org.apache.datasketches.thetacommon.ThetaUtil.DEFAULT_UPDATE_SEED;
 
 import 
org.apache.datasketches.characterization.uniquecount.BaseUpdateSpeedProfile;
-import org.apache.datasketches.memory.WritableHandle;
 import org.apache.datasketches.memory.WritableMemory;
 import org.apache.datasketches.theta.Sketch;
 import org.apache.datasketches.theta.UpdateSketch;
@@ -40,7 +39,6 @@ public class ConcurrentThetaUpdateSpeedProfile extends 
BaseUpdateSpeedProfile {
   private boolean offHeap;
   private int poolThreads;
   private double maxConcurrencyError;
-  private WritableHandle wdh;
   private WritableMemory wmem;
 
   /**
@@ -59,8 +57,7 @@ public class ConcurrentThetaUpdateSpeedProfile extends 
BaseUpdateSpeedProfile {
     final int maxSharedUpdateBytes = Sketch.getMaxUpdateSketchBytes(1 << 
sharedLgK);
 
     if (offHeap) {
-      wdh = WritableMemory.allocateDirect(maxSharedUpdateBytes);
-      wmem = wdh.getWritable();
+      wmem = WritableMemory.allocateDirect(maxSharedUpdateBytes);
     } else {
       wmem = WritableMemory.allocate(maxSharedUpdateBytes);
     }
diff --git 
a/src/main/java/org/apache/datasketches/characterization/tuple/AodSketchUpdateSpeedProfile.java
 
b/src/main/java/org/apache/datasketches/characterization/tuple/AodSketchUpdateSpeedProfile.java
index 4794d89..b747fae 100644
--- 
a/src/main/java/org/apache/datasketches/characterization/tuple/AodSketchUpdateSpeedProfile.java
+++ 
b/src/main/java/org/apache/datasketches/characterization/tuple/AodSketchUpdateSpeedProfile.java
@@ -21,7 +21,6 @@ package org.apache.datasketches.characterization.tuple;
 
 import 
org.apache.datasketches.characterization.uniquecount.BaseUpdateSpeedProfile;
 import org.apache.datasketches.common.ResizeFactor;
-import org.apache.datasketches.memory.WritableHandle;
 import org.apache.datasketches.memory.WritableMemory;
 import org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesUnion;
 import 
org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesUpdatableSketch;
@@ -29,7 +28,6 @@ import 
org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesUpdatableSketc
 
 public class AodSketchUpdateSpeedProfile extends BaseUpdateSpeedProfile {
   protected ArrayOfDoublesUpdatableSketch sketch;
-  private WritableHandle handle;
   private WritableMemory wmem;
 
   @Override
@@ -46,8 +44,7 @@ public class AodSketchUpdateSpeedProfile extends 
BaseUpdateSpeedProfile {
       
.setNominalEntries(k).setNumberOfValues(numValues).setSamplingProbability(p).setResizeFactor(rf);
     if (offheap) {
       final int bytes = ArrayOfDoublesUnion.getMaxBytes(k, numValues);
-      handle = WritableMemory.allocateDirect(bytes);
-      wmem = handle.getWritable();
+      wmem = WritableMemory.allocateDirect(bytes);
       sketch = udBldr.build(wmem);
     } else {
       sketch = udBldr.build();
@@ -57,7 +54,7 @@ public class AodSketchUpdateSpeedProfile extends 
BaseUpdateSpeedProfile {
   @Override
   public void cleanup() {
     try {
-      if (handle != null) { handle.close(); }
+      if (wmem.isAlive()) { wmem.close(); }
     } catch (final Exception e) {
       // do nothing
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to