Skip to content

Commit

Permalink
Merge pull request #242 from apache/frank_grimes_java-21-ffm
Browse files Browse the repository at this point in the history
Frank grimes java 21 ffm
  • Loading branch information
leerho authored Dec 9, 2024
2 parents cf662bf + 5d9cd18 commit 3350ab9
Show file tree
Hide file tree
Showing 54 changed files with 1,634 additions and 1,510 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/auto-jdk-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false

env:
JDK_VERSION: 17
JDK_VERSION: 21

steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
Expand All @@ -36,7 +36,7 @@ jobs:
distribution: 'temurin'
java-package: jdk
architecture: x64
java-version: 17
java-version: 21

- name: Cache local Maven repository
uses: actions/cache@v4
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 @@ -17,7 +17,7 @@ jobs:
fail-fast: false

matrix:
jdk: [ 17 ]
jdk: [ 21 ]
os: [ windows-latest, ubuntu-latest, macos-latest ]
include:
- os: windows-latest
Expand Down Expand Up @@ -55,8 +55,6 @@ jobs:
distribution: 'temurin'
java-package: jdk
architecture: x64
# Architecture options: x86, x64, armv7, aarch64, ppc64le
# setup-java@v4 has a "with cache" option

- name: Echo Java Version
run: >
Expand All @@ -75,6 +73,8 @@ jobs:
-D skipTests=true
${{matrix.os.skip_gpg}}
# Architecture options: x86, x64, armv7, aarch64, ppc64le
# setup-java@v4 has a "with cache" option
# Lifecycle: validate, compile, test, package, verify, install, deploy
# -B batch mode
# -V show Version without stopping
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: JavaDoc

on:
push:
branches: [ 4.0.X, main ]
branches: [ main ]
workflow_dispatch:

jobs:
Expand All @@ -16,17 +16,21 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Echo Java Version
run: java -version

- name: Print Current workflow
run: >
cat .github/workflows/javadoc.yml
- name: Generate JavaDoc
run: mvn javadoc:javadoc

- name: Deploy JavaDoc
uses: JamesIves/github-pages-deploy-action@5dc1d5a192aeb5ab5b7d5a77b7d36aea4a7f5c92
uses: JamesIves/github-pages-deploy-action@v4.6.8
with:
token: ${{ secrets.GITHUB_TOKEN }}
folder: target/reports/apidocs
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ datasketches-memory*/.gitignore
*.ipr
*.iws

# Netbeans project files
nb-configuration.xml

# Additional tools
.clover/

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ Note: *primitive* := *{byte, short, int, long, float, double}*
* *Memory.map(File)* (read only)
* *WritableMemory.writableMap(File)*

## Release 4.0.0 (inclusive) to 5.0.0 (exclusive)
Starting with release *datasketches-memory-4.0.0*, this Memory component supports only Java 17 when compiling from source and should work with later Java versions at runtime.
## Release 5.0.0 (inclusive) to 6.0.0 (exclusive)
Starting with release *datasketches-memory-5.0.0*, this Memory component supports only Java 21 when compiling from source and should work with later Java versions at runtime.

### *NOTE: The DataSketches Java Memory Component is not thread-safe.*
### *NOTES:*
* The DataSketches Java Memory Component is not thread-safe.
* We recommend Eclipse Adoptium/Temurin 21.0.5+11 or later as earlier releases of 21 have bugs that affect this product.

## Build Instructions
__NOTES:__
Expand All @@ -78,14 +80,14 @@ __NOTES:__
As a result, the directory elements of the full absolute path of the target installation directory must qualify as Java identifiers.
In other words, the directory elements must not have any space characters (or non-Java identifier characters) in any of the path elements. This is required by the Oracle Java Specification in order to ensure location-independent access to resources:
[See Oracle Location-Independent Access to Resources](https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html)
* The compile command line must contain the JVM flag *--add-modules=jdk.incubator.foreign*.
* The compile command line must contain the JVM flag *--enable-preview*.
* This component is not designed as a Java Module, so the Jar file should be part of the application classpath.

#### Dependencies
There are no run-time dependencies. See the pom.xml file for test dependencies.

#### Maven build instructions
The Maven build requires JDK-17 to compile:
The Maven build requires JDK-21 to compile:

To run normal unit tests:

Expand Down
46 changes: 36 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ under the License.

<modelVersion>4.0.0</modelVersion>

<!--
<!--
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
Expand All @@ -34,7 +34,7 @@ under the License.

<groupId>org.apache.datasketches</groupId>
<artifactId>datasketches-memory</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>5.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down Expand Up @@ -89,10 +89,11 @@ under the License.

<!-- System-wide properties -->
<maven.version>3.6.3</maven.version>
<java.version>17</java.version>
<java.version>21</java.version>
<enable.preview>--enable-preview</enable.preview>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<argLine>-Xmx4g -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 --add-modules=jdk.incubator.foreign</argLine>
<argLine>-Xmx4g -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 ${enable.preview}</argLine>
<charset.encoding>UTF-8</charset.encoding>
<project.build.sourceEncoding>${charset.encoding}</project.build.sourceEncoding>
<project.build.resourceEncoding>${charset.encoding}</project.build.resourceEncoding>
Expand All @@ -107,11 +108,12 @@ under the License.
<maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
<maven-install-plugin.version>3.1.2</maven-install-plugin.version>
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
<maven-javadoc-plugin.version>3.10.1</maven-javadoc-plugin.version>
<maven-javadoc-plugin.version>3.11.1</maven-javadoc-plugin.version>
<maven-release-plugin.version>3.1.1</maven-release-plugin.version>
<maven-remote-resources-plugin.version>3.2.0</maven-remote-resources-plugin.version>
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<maven-surefire-failsafe-plugins.version>3.5.0</maven-surefire-failsafe-plugins.version> <!-- for surefire, failsafe and surefire-report -->
<maven-surefire-failsafe-plugins.version>3.5.2</maven-surefire-failsafe-plugins.version> <!-- for surefire, failsafe and surefire-report -->
<maven-toolchains-plugin.version>3.2.0</maven-toolchains-plugin.version>
<!-- com.github plugins -->
<git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version>
<!-- org.apache.creadur plugins -->
Expand Down Expand Up @@ -161,7 +163,7 @@ under the License.
<version>${maven-compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>--add-modules=jdk.incubator.foreign</arg>
<arg>${enable.preview}</arg>
</compilerArgs>
</configuration>
</plugin>
Expand All @@ -187,7 +189,7 @@ under the License.
<configuration>
<rules>
<requireJavaVersion>
<version>[17,18)</version>
<version>${java.version}</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[${maven.version},4.0.0)</version>
Expand Down Expand Up @@ -235,7 +237,7 @@ under the License.
<excludePackageNames>org.apache.datasketches.memory/internal</excludePackageNames>
<show>public</show>
<additionalOptions>
<additionalOption>--add-modules=jdk.incubator.foreign</additionalOption>
<additionalOption>${enable.preview}</additionalOption>
</additionalOptions>
</configuration>
<executions>
Expand Down Expand Up @@ -281,14 +283,34 @@ under the License.
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-failsafe-plugins.version}</version>
<configuration>
<argLine>--add-modules=jdk.incubator.foreign</argLine>
<argLine>${enable.preview}</argLine>
<trimStackTrace>false</trimStackTrace>
<useManifestOnlyJar>false</useManifestOnlyJar>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<reportsDirectory>${project.build.directory}/test-output/${maven.build.timestamp}</reportsDirectory>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>${maven-toolchains-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>${java.version}</version>
</jdk>
</toolchains>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
Expand Down Expand Up @@ -392,6 +414,10 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
Expand Down
25 changes: 1 addition & 24 deletions src/main/java/org/apache/datasketches/memory/Buffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,29 +383,6 @@ void getShortArray(
int dstOffsetShorts,
int lengthShorts);

//SPECIAL PRIMITIVE READ METHODS: compareTo.
// No copyTo, No writeTo. Use Memory for that.

/**
* Compares the bytes of this Buffer to <i>that</i> Buffer.
* This uses absolute offsets not the start, position and end.
* Returns <i>(this &lt; that) ? (some negative value) : (this &gt; that) ? (some positive value)
* : 0;</i>.
* If all bytes are equal up to the shorter of the two lengths, the shorter length is
* considered to be less than the other.
* @param thisOffsetBytes the starting offset for <i>this Buffer</i>
* @param thisLengthBytes the length of the region to compare from <i>this Buffer</i>
* @param that the other Buffer to compare with
* @param thatOffsetBytes the starting offset for <i>that Buffer</i>
* @param thatLengthBytes the length of the region to compare from <i>that Buffer</i>
* @return <i>(this &lt; that) ? (some negative value) : (this &gt; that) ? (some positive value)
* : 0;</i>
*/
int compareTo(
long thisOffsetBytes,
long thisLengthBytes,
Buffer that,
long thatOffsetBytes,
long thatLengthBytes);
//SPECIAL PRIMITIVE READ METHODS:none.

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@

package org.apache.datasketches.memory;

import java.lang.foreign.Arena;
import java.nio.ByteOrder;

import jdk.incubator.foreign.ResourceScope;

/**
* This example MemoryRequestServer is simple but demonstrates one of many ways to
* manage continuous requests for larger memory.
Expand Down Expand Up @@ -59,7 +58,7 @@ public DefaultMemoryRequestServer(
public WritableMemory request(
final WritableMemory currentWmem,
final long newCapacityBytes,
final ResourceScope scope) {
final Arena arena) {
final ByteOrder order = currentWmem.getTypeByteOrder();
final long currentBytes = currentWmem.getCapacity();
final WritableMemory newWmem;
Expand All @@ -69,7 +68,7 @@ public WritableMemory request(
}

if (offHeap) {
newWmem = WritableMemory.allocateDirect(newCapacityBytes, 8, scope, order, this);
newWmem = WritableMemory.allocateDirect(newCapacityBytes, 8, order, this, arena);
}
else { //On-heap
if (newCapacityBytes > Integer.MAX_VALUE) {
Expand All @@ -89,8 +88,8 @@ public WritableMemory request(
public void requestClose(
final WritableMemory memToClose,
final WritableMemory newMemory) {
//make this operation idempotent.
if (memToClose.isCloseable()) { memToClose.scope().close(); }
//try to make this operation idempotent.
if (memToClose.isCloseable()) { memToClose.close(); }
}

}
Loading

0 comments on commit 3350ab9

Please sign in to comment.