Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b193b70
Set pom to min java version of 22.
leerho Aug 24, 2025
3388762
Add tests, minor fixes to improve testing.
leerho Aug 25, 2025
5e2e17a
Removed deprecated JVM arguments.
leerho Aug 30, 2025
ecff86a
update pom
leerho Aug 30, 2025
26d0523
update pom
leerho Aug 30, 2025
6c9b690
update pom
leerho Aug 30, 2025
999aaee
more pom updates.
leerho Sep 2, 2025
9f85d8c
Mostly corrected javadocs
leerho Sep 9, 2025
88d6037
Speed and code comment suggestions from GPT review. Fix typo.
leerho Sep 13, 2025
10e8273
More corrections/improvements due to ChatGPT review.
leerho Sep 23, 2025
fa97b7c
Update GHA workflows from Java 24 to Java 25.
leerho Sep 23, 2025
8ab3c35
Disable GHA Workflows until they support Java 25.
leerho Sep 23, 2025
1401350
Updated MemorySegmentRequestExample to use ConcurrentHashMap.
leerho Sep 23, 2025
eba1d8c
Refactor MemorySegmentRequest to make concurrent.
leerho Sep 25, 2025
6612200
Take advantage of Java 25 Flexible Constructor Bodies JEP 513.
leerho Sep 26, 2025
77da42d
This set of changes removed the largely redundant theta Sketches class.
leerho Sep 30, 2025
54132a4
Update GH action workflows for Java 25
leerho Sep 30, 2025
2139854
Improve probabilistic test to make it extremely unlikely that it will
leerho Oct 1, 2025
b5639e8
Slight correction in test loop.
leerho Oct 1, 2025
193cfdf
Completely remove SerVer 1 and 2 from the code.
leerho Oct 1, 2025
5d531c2
More cleanup after removing SerVer 1 and 2
leerho Oct 1, 2025
5c3b845
Fix Javadoc warning.
leerho Oct 1, 2025
8c66f20
Lots of cleanup after Sketches class was removed.
leerho Oct 2, 2025
72c7a24
In response to the incorrect Pilot objection, I am adding a few sanity
leerho Oct 3, 2025
f9e37ec
Correct spelling of "HLL" in Javadoc
leerho Oct 4, 2025
2a8c591
Spelling error
leerho Oct 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/auto-jdk-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
strategy:
fail-fast: false
matrix:
jdk: [ 24 ]
jdk: [ 25 ]

env:
JDK_VERSION: ${{ matrix.jdk }}

steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
persist-credentials: false

Expand All @@ -43,7 +43,7 @@ jobs:
restore-keys: build-${{ runner.os }}-maven-

- name: Install Matrix JDK
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
Expand All @@ -67,7 +67,7 @@ jobs:
-Dgpg.skip=true

# Architecture options: x86, x64, armv7, aarch64, ppc64le
# setup-java@v4 has a "with cache" option
# setup-java@v5 has a "with cache" option
# Lifecycle: validate, compile, test, package, verify, install, deploy
# -B batch mode, never stops for user input
# -V show Version without stopping
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/auto-os-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false

matrix:
jdk: [ 24 ]
jdk: [ 25 ]
os: [ windows-latest, ubuntu-latest, macos-latest ]
include:
- os: windows-latest
Expand All @@ -41,7 +41,7 @@ jobs:

steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
persist-credentials: false

Expand All @@ -53,7 +53,7 @@ jobs:
restore-keys: build-${{ runner.os }}-maven-

- name: Install Matrix JDK
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/check_cpp_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Checkout C++
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
repository: apache/datasketches-cpp
path: cpp

- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: '24'
java-version: '25'
distribution: 'temurin'

- name: Configure C++ build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: 'temurin'
cache: 'maven'
java-version: '24'
java-version: '25'

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: '24'
java-version: '25'
distribution: 'temurin'

- name: Echo Java Version
Expand Down
74 changes: 40 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ under the License.
</scm>

<issueManagement>
<!-- <system>jira</system>
<url>https://issues.apache.org/jira/browse/DATASKETCHES</url> -->
<system>GitHub</system>
<url>https://github.com/apache/${project.artifactId}/issues</url>
</issueManagement>
Expand All @@ -83,8 +81,6 @@ under the License.
</developers>

<properties>
<datasketches-memory.version>6.1.0-SNAPSHOT</datasketches-memory.version>

<!-- Test -->
<testng.version>7.11.0</testng.version>
<!-- these are TestNG groups used for excluding / including groups of tests. See profiles section. -->
Expand All @@ -94,11 +90,10 @@ under the License.
<testng.check-cpp-historical-files>check_cpp_historical_files</testng.check-cpp-historical-files>

<!-- System-wide properties -->
<maven.version>3.9.10</maven.version>
<java.version>24</java.version>
<jvm-arguments>-Xmx4g -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8</jvm-arguments>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.version>3.9.11</maven.version>
<java.version>25</java.version>
<!-- removed: g -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 -->
<jvm.options>-Xmx4g</jvm.options> <!-- use space to separate args -->
<charset.encoding>UTF-8</charset.encoding>
<project.build.sourceEncoding>${charset.encoding}</project.build.sourceEncoding>
<project.build.resourceEncoding>${charset.encoding}</project.build.resourceEncoding>
Expand All @@ -108,11 +103,12 @@ under the License.
<!-- org.apache.maven plugins -->
<maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
<maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
<maven-dependency-plugin.version>3.8.1</maven-dependency-plugin.version>
<maven-deploy-plugin.version>3.1.4</maven-deploy-plugin.version>
<maven-enforcer-plugin.version>3.6.0</maven-enforcer-plugin.version>
<maven-enforcer-plugin.version>3.6.1</maven-enforcer-plugin.version>
<maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
<maven-javadoc-plugin.version>3.11.3</maven-javadoc-plugin.version>
<maven-release-plugin.version>3.1.1</maven-release-plugin.version>
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<!-- for surefire, failsafe and surefire-report: -->
Expand Down Expand Up @@ -148,6 +144,7 @@ under the License.
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
</plugin>
Expand All @@ -157,12 +154,20 @@ under the License.
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<fork>true</fork>
<release>${java.version}</release>
<compilerArgs>
<arg></arg>
<arg>-J${jvm.options}</arg> <!-- comma separated or separate args -->
</compilerArgs>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin.version}</version>
</plugin>

<plugin>
<!-- We want to deploy the artifacts to a staging location for perusal -->
<!-- Apache Parent pom: apache-release profile -->
Expand All @@ -184,11 +189,12 @@ under the License.
<configuration>
<rules>
<requireJavaVersion>
<version>[24,)</version> <!-- java.version -->
<version>[25,)</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[${maven.version},4.0.0)</version>
<version>[${maven.version},)</version>
</requireMavenVersion>
<!-- <dependencyConvergence /> -->
<bannedDependencies>
<excludes>
<!--LGPL licensed library-->
Expand Down Expand Up @@ -232,6 +238,10 @@ under the License.
<docfilessubdirs>true</docfilessubdirs>
<show>public</show>
<doclint>all,-missing</doclint>
<release>${java.version}</release>
<additionalJOptions> <!-- requires -J prefix -->
<additionalJOption>-J${jvm.options}</additionalJOption>
</additionalJOptions>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -276,7 +286,9 @@ under the License.
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-failsafe-plugins.version}</version>
<configuration>
<argLine>${jvm-arguments}</argLine>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<argLine>${argLine} ${jvm.options}</argLine> <!-- use space to separate args -->
<trimStackTrace>false</trimStackTrace>
<useManifestOnlyJar>false</useManifestOnlyJar>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
Expand Down Expand Up @@ -383,6 +395,18 @@ under the License.
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down Expand Up @@ -585,25 +609,7 @@ under the License.
</build>
</profile>

<!-- Disable source release assembly for 'apache-release' profile.
This is performed from a script outside Maven
<profile>
<id>apache-release</id>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<executions>
<execution>
<id>source-release-assembly</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile> -->


<profile>
<id>generate-java-files</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@
public interface MemorySegmentRequest {

/**
* Request a new MemorySegment with the given <i>newByteSize</i>.
* Request a new heap MemorySegment with the given <i>newByteSize</i>.
* Because we do not have a reference to an Arena, the default here is to
* allocate a new MemorySegment on the heap. It is up to the user to override this as appropriate.
* @param prevSeg the previous MemorySegment to be possibly closed here or by using the separate
* {@link #requestClose requestClose} method. This is included for convenience, it may be null.
* @param newByteSize The new <i>byteSize</i> being requested.
* @return new MemorySegment with the requested <i>byteSize</i>.
*/
default MemorySegment request(final MemorySegment prevSeg, final long newByteSize) {
default MemorySegment request(final long newByteSize) {
if (newByteSize > Integer.MAX_VALUE) {
throw new SketchesArgumentException("Requested size in bytes exceeds Integer.MAX_VALUE.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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.common;

import java.lang.foreign.Arena;

import java.lang.foreign.MemorySegment;
import java.util.Enumeration;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Objects;

/**
* This is an example of a possible implementation of the MemorySegmentRequest interface
* where all requested segments are allocated off-heap. A local ConcurrentHashMap tracks a newly created
* confined Arena for every new MemorySegment allocated off-heap. This allows individual segments to be freed
* immediately upon receiving the {@link #requestClose(MemorySegment) requestClose(MemorySegment)} call.
*/
public final class MemorySegmentRequestExample implements MemorySegmentRequest {
private final ConcurrentHashMap<MemorySegment, Arena> map = new ConcurrentHashMap<>();

/**
* Request a new off-heap MemorySegment with the given <i>newByteSeze</i>.
* An internal confined Arena is created to exclusively manage the new segment and it is associated
* with the new segment with a ConcurrentHashMap.
*/
@Override
public synchronized MemorySegment request(final long newByteSize) {
final Arena arena = Arena.ofConfined();
final MemorySegment seg = arena.allocate(newByteSize);
map.put(seg, arena);
return seg;

}

@Override
public synchronized void requestClose(final MemorySegment segKey) {
Objects.requireNonNull(segKey, "MemorySegment segKey must not be null");
final Arena arena = map.get(segKey);
if (arena != null) {
if (arena.scope().isAlive()) { arena.close(); }
map.remove(segKey);
} else {
//ignore or
//throw new SketchesArgumentException("Given MemorySegment key is not mapped to an Arena!");
}
}

/**
* This closes any unclosed, off-heap MemorySegments and removes all mappings from the map.
*/
public synchronized void cleanup() {
for (final Enumeration<Arena> e = map.elements(); e.hasMoreElements(); ) {
final Arena arena = e.nextElement();
if (arena.scope().isAlive()) { arena.close(); }
}
map.clear();
}

}
Loading