Skip to content

Commit 63c371a

Browse files
authored
Merge pull request #685 from apache/cleanup_phase3
Cleanup phase 3
2 parents 5abce63 + 2a8c591 commit 63c371a

File tree

81 files changed

+1590
-3505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1590
-3505
lines changed

.github/workflows/auto-jdk-matrix.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
jdk: [ 24 ]
23+
jdk: [ 25 ]
2424

2525
env:
2626
JDK_VERSION: ${{ matrix.jdk }}
2727

2828
steps:
2929
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
30-
uses: actions/checkout@v4
30+
uses: actions/checkout@v5
3131
with:
3232
persist-credentials: false
3333

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

4545
- name: Install Matrix JDK
46-
uses: actions/setup-java@v4
46+
uses: actions/setup-java@v5
4747
with:
4848
java-version: ${{ matrix.jdk }}
4949
distribution: 'temurin'
@@ -67,7 +67,7 @@ jobs:
6767
-Dgpg.skip=true
6868
6969
# Architecture options: x86, x64, armv7, aarch64, ppc64le
70-
# setup-java@v4 has a "with cache" option
70+
# setup-java@v5 has a "with cache" option
7171
# Lifecycle: validate, compile, test, package, verify, install, deploy
7272
# -B batch mode, never stops for user input
7373
# -V show Version without stopping

.github/workflows/auto-os-matrix.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
fail-fast: false
2222

2323
matrix:
24-
jdk: [ 24 ]
24+
jdk: [ 25 ]
2525
os: [ windows-latest, ubuntu-latest, macos-latest ]
2626
include:
2727
- os: windows-latest
@@ -41,7 +41,7 @@ jobs:
4141

4242
steps:
4343
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
44-
uses: actions/checkout@v4
44+
uses: actions/checkout@v5
4545
with:
4646
persist-credentials: false
4747

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

5555
- name: Install Matrix JDK
56-
uses: actions/setup-java@v4
56+
uses: actions/setup-java@v5
5757
with:
5858
java-version: ${{ matrix.jdk }}
5959
distribution: 'temurin'

.github/workflows/check_cpp_files.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
2020

2121
- name: Checkout C++
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2323
with:
2424
repository: apache/datasketches-cpp
2525
path: cpp
2626

2727
- name: Setup Java
28-
uses: actions/setup-java@v4
28+
uses: actions/setup-java@v5
2929
with:
30-
java-version: '24'
30+
java-version: '25'
3131
distribution: 'temurin'
3232

3333
- name: Configure C++ build

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ jobs:
2828

2929
steps:
3030
- name: Checkout repository
31-
uses: actions/checkout@v4
31+
uses: actions/checkout@v5
3232

3333
- name: Setup Java
34-
uses: actions/setup-java@v4
34+
uses: actions/setup-java@v5
3535
with:
3636
distribution: 'temurin'
3737
cache: 'maven'
38-
java-version: '24'
38+
java-version: '25'
3939

4040
- name: Initialize CodeQL
4141
uses: github/codeql-action/init@v3

.github/workflows/javadoc.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414

1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v4
17+
uses: actions/checkout@v5
1818

1919
- name: Setup Java
20-
uses: actions/setup-java@v4
20+
uses: actions/setup-java@v5
2121
with:
22-
java-version: '24'
22+
java-version: '25'
2323
distribution: 'temurin'
2424

2525
- name: Echo Java Version

pom.xml

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ under the License.
6666
</scm>
6767

6868
<issueManagement>
69-
<!-- <system>jira</system>
70-
<url>https://issues.apache.org/jira/browse/DATASKETCHES</url> -->
7169
<system>GitHub</system>
7270
<url>https://github.com/apache/${project.artifactId}/issues</url>
7371
</issueManagement>
@@ -83,8 +81,6 @@ under the License.
8381
</developers>
8482

8583
<properties>
86-
<datasketches-memory.version>6.1.0-SNAPSHOT</datasketches-memory.version>
87-
8884
<!-- Test -->
8985
<testng.version>7.11.0</testng.version>
9086
<!-- these are TestNG groups used for excluding / including groups of tests. See profiles section. -->
@@ -94,11 +90,10 @@ under the License.
9490
<testng.check-cpp-historical-files>check_cpp_historical_files</testng.check-cpp-historical-files>
9591

9692
<!-- System-wide properties -->
97-
<maven.version>3.9.10</maven.version>
98-
<java.version>24</java.version>
99-
<jvm-arguments>-Xmx4g -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8</jvm-arguments>
100-
<maven.compiler.source>${java.version}</maven.compiler.source>
101-
<maven.compiler.target>${java.version}</maven.compiler.target>
93+
<maven.version>3.9.11</maven.version>
94+
<java.version>25</java.version>
95+
<!-- removed: g -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 -->
96+
<jvm.options>-Xmx4g</jvm.options> <!-- use space to separate args -->
10297
<charset.encoding>UTF-8</charset.encoding>
10398
<project.build.sourceEncoding>${charset.encoding}</project.build.sourceEncoding>
10499
<project.build.resourceEncoding>${charset.encoding}</project.build.resourceEncoding>
@@ -108,11 +103,12 @@ under the License.
108103
<!-- org.apache.maven plugins -->
109104
<maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
110105
<maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
106+
<maven-dependency-plugin.version>3.8.1</maven-dependency-plugin.version>
111107
<maven-deploy-plugin.version>3.1.4</maven-deploy-plugin.version>
112-
<maven-enforcer-plugin.version>3.6.0</maven-enforcer-plugin.version>
108+
<maven-enforcer-plugin.version>3.6.1</maven-enforcer-plugin.version>
113109
<maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
114110
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
115-
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
111+
<maven-javadoc-plugin.version>3.11.3</maven-javadoc-plugin.version>
116112
<maven-release-plugin.version>3.1.1</maven-release-plugin.version>
117113
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
118114
<!-- for surefire, failsafe and surefire-report: -->
@@ -148,6 +144,7 @@ under the License.
148144
<plugins>
149145

150146
<plugin>
147+
<groupId>org.apache.maven.plugins</groupId>
151148
<artifactId>maven-assembly-plugin</artifactId>
152149
<version>${maven-assembly-plugin.version}</version>
153150
</plugin>
@@ -157,12 +154,20 @@ under the License.
157154
<artifactId>maven-compiler-plugin</artifactId>
158155
<version>${maven-compiler-plugin.version}</version>
159156
<configuration>
157+
<fork>true</fork>
158+
<release>${java.version}</release>
160159
<compilerArgs>
161-
<arg></arg>
160+
<arg>-J${jvm.options}</arg> <!-- comma separated or separate args -->
162161
</compilerArgs>
163162
</configuration>
164163
</plugin>
165164

165+
<plugin>
166+
<groupId>org.apache.maven.plugins</groupId>
167+
<artifactId>maven-dependency-plugin</artifactId>
168+
<version>${maven-dependency-plugin.version}</version>
169+
</plugin>
170+
166171
<plugin>
167172
<!-- We want to deploy the artifacts to a staging location for perusal -->
168173
<!-- Apache Parent pom: apache-release profile -->
@@ -184,11 +189,12 @@ under the License.
184189
<configuration>
185190
<rules>
186191
<requireJavaVersion>
187-
<version>[24,)</version> <!-- java.version -->
192+
<version>[25,)</version>
188193
</requireJavaVersion>
189194
<requireMavenVersion>
190-
<version>[${maven.version},4.0.0)</version>
195+
<version>[${maven.version},)</version>
191196
</requireMavenVersion>
197+
<!-- <dependencyConvergence /> -->
192198
<bannedDependencies>
193199
<excludes>
194200
<!--LGPL licensed library-->
@@ -232,6 +238,10 @@ under the License.
232238
<docfilessubdirs>true</docfilessubdirs>
233239
<show>public</show>
234240
<doclint>all,-missing</doclint>
241+
<release>${java.version}</release>
242+
<additionalJOptions> <!-- requires -J prefix -->
243+
<additionalJOption>-J${jvm.options}</additionalJOption>
244+
</additionalJOptions>
235245
</configuration>
236246
<executions>
237247
<execution>
@@ -276,7 +286,9 @@ under the License.
276286
<artifactId>maven-surefire-plugin</artifactId>
277287
<version>${maven-surefire-failsafe-plugins.version}</version>
278288
<configuration>
279-
<argLine>${jvm-arguments}</argLine>
289+
<forkCount>1</forkCount>
290+
<reuseForks>true</reuseForks>
291+
<argLine>${argLine} ${jvm.options}</argLine> <!-- use space to separate args -->
280292
<trimStackTrace>false</trimStackTrace>
281293
<useManifestOnlyJar>false</useManifestOnlyJar>
282294
<redirectTestOutputToFile>true</redirectTestOutputToFile>
@@ -383,6 +395,18 @@ under the License.
383395
</plugins>
384396
</pluginManagement>
385397
<plugins>
398+
<plugin>
399+
<groupId>org.apache.maven.plugins</groupId>
400+
<artifactId>maven-assembly-plugin</artifactId>
401+
</plugin>
402+
<plugin>
403+
<groupId>org.apache.maven.plugins</groupId>
404+
<artifactId>maven-compiler-plugin</artifactId>
405+
</plugin>
406+
<plugin>
407+
<groupId>org.apache.maven.plugins</groupId>
408+
<artifactId>maven-dependency-plugin</artifactId>
409+
</plugin>
386410
<plugin>
387411
<groupId>org.apache.maven.plugins</groupId>
388412
<artifactId>maven-deploy-plugin</artifactId>
@@ -585,25 +609,7 @@ under the License.
585609
</build>
586610
</profile>
587611

588-
<!-- Disable source release assembly for 'apache-release' profile.
589-
This is performed from a script outside Maven
590-
<profile>
591-
<id>apache-release</id>
592-
<build>
593-
<plugins>
594-
<plugin>
595-
<artifactId>maven-assembly-plugin</artifactId>
596-
<version>${maven-assembly-plugin.version}</version>
597-
<executions>
598-
<execution>
599-
<id>source-release-assembly</id>
600-
<phase>none</phase>
601-
</execution>
602-
</executions>
603-
</plugin>
604-
</plugins>
605-
</build>
606-
</profile> -->
612+
607613

608614
<profile>
609615
<id>generate-java-files</id>

src/main/java/org/apache/datasketches/common/MemorySegmentRequest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@
2929
public interface MemorySegmentRequest {
3030

3131
/**
32-
* Request a new MemorySegment with the given <i>newByteSize</i>.
32+
* Request a new heap MemorySegment with the given <i>newByteSize</i>.
3333
* Because we do not have a reference to an Arena, the default here is to
3434
* allocate a new MemorySegment on the heap. It is up to the user to override this as appropriate.
35-
* @param prevSeg the previous MemorySegment to be possibly closed here or by using the separate
36-
* {@link #requestClose requestClose} method. This is included for convenience, it may be null.
3735
* @param newByteSize The new <i>byteSize</i> being requested.
3836
* @return new MemorySegment with the requested <i>byteSize</i>.
3937
*/
40-
default MemorySegment request(final MemorySegment prevSeg, final long newByteSize) {
38+
default MemorySegment request(final long newByteSize) {
4139
if (newByteSize > Integer.MAX_VALUE) {
4240
throw new SketchesArgumentException("Requested size in bytes exceeds Integer.MAX_VALUE.");
4341
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.datasketches.common;
21+
22+
import java.lang.foreign.Arena;
23+
24+
import java.lang.foreign.MemorySegment;
25+
import java.util.Enumeration;
26+
import java.util.concurrent.ConcurrentHashMap;
27+
import java.util.Objects;
28+
29+
/**
30+
* This is an example of a possible implementation of the MemorySegmentRequest interface
31+
* where all requested segments are allocated off-heap. A local ConcurrentHashMap tracks a newly created
32+
* confined Arena for every new MemorySegment allocated off-heap. This allows individual segments to be freed
33+
* immediately upon receiving the {@link #requestClose(MemorySegment) requestClose(MemorySegment)} call.
34+
*/
35+
public final class MemorySegmentRequestExample implements MemorySegmentRequest {
36+
private final ConcurrentHashMap<MemorySegment, Arena> map = new ConcurrentHashMap<>();
37+
38+
/**
39+
* Request a new off-heap MemorySegment with the given <i>newByteSeze</i>.
40+
* An internal confined Arena is created to exclusively manage the new segment and it is associated
41+
* with the new segment with a ConcurrentHashMap.
42+
*/
43+
@Override
44+
public synchronized MemorySegment request(final long newByteSize) {
45+
final Arena arena = Arena.ofConfined();
46+
final MemorySegment seg = arena.allocate(newByteSize);
47+
map.put(seg, arena);
48+
return seg;
49+
50+
}
51+
52+
@Override
53+
public synchronized void requestClose(final MemorySegment segKey) {
54+
Objects.requireNonNull(segKey, "MemorySegment segKey must not be null");
55+
final Arena arena = map.get(segKey);
56+
if (arena != null) {
57+
if (arena.scope().isAlive()) { arena.close(); }
58+
map.remove(segKey);
59+
} else {
60+
//ignore or
61+
//throw new SketchesArgumentException("Given MemorySegment key is not mapped to an Arena!");
62+
}
63+
}
64+
65+
/**
66+
* This closes any unclosed, off-heap MemorySegments and removes all mappings from the map.
67+
*/
68+
public synchronized void cleanup() {
69+
for (final Enumeration<Arena> e = map.elements(); e.hasMoreElements(); ) {
70+
final Arena arena = e.nextElement();
71+
if (arena.scope().isAlive()) { arena.close(); }
72+
}
73+
map.clear();
74+
}
75+
76+
}

0 commit comments

Comments
 (0)