Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/auto-jdk-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
jdk: [ 21 ] # LTS versions only
jdk: [ 25 ] # LTS versions only
os: [ ubuntu-latest ]
include:
# - os: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion .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: [ 21 ]
jdk: [ 25 ]
os: [ windows-latest, ubuntu-latest, macos-latest ]
include:
- os: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '25'
distribution: 'temurin'

- name: Echo Java Version
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Starting with release *datasketches-memory-5.0.0*, this Memory component support
### Runtime Notes:
* There are no run-time dependencies.
* The DataSketches Java Memory Component is not thread-safe.
* This Release, based on Java 21, leverages the new Java Foreign Function & Memory (FFM) API [JEP 442](https://openjdk.org/jeps/442), which is in its third Preview and will require the JVM flag *--enable-preview* at run-time.
* We recommend Eclipse Adoptium/Temurin 21.0.5+11 or later as earlier releases of 21 have bugs that affect this product.
* This Release, based on Java 25, leverages the new Java Foreign Function & Memory (FFM) API [JEP 454](https://openjdk.org/jeps/454).
* We recommend Eclipse Adoptium/Temurin 25.0.0+36-LTS or later as earlier releases of 25 have bugs that affect this product.
* This component is not designed as a Java Module, so the Jar file should be part of the application classpath.

## Build Instructions
Expand All @@ -83,7 +83,6 @@ __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 *--enable-preview* (see [JEP 442](https://openjdk.org/jeps/442)).


#### Build & Test Dependencies
Expand Down
26 changes: 12 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ under the License.

<!-- System-wide properties -->
<maven.version>3.6.3</maven.version>
<java.version>21</java.version>
<enable.preview>--enable-preview</enable.preview>
<java.version>25</java.version>
<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 ${enable.preview}</argLine>
<argLine>-Xmx4g -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8</argLine>
<charset.encoding>UTF-8</charset.encoding>
<project.build.sourceEncoding>${charset.encoding}</project.build.sourceEncoding>
<project.build.resourceEncoding>${charset.encoding}</project.build.resourceEncoding>
Expand Down Expand Up @@ -115,7 +114,7 @@ under the License.
<coveralls-repo-token></coveralls-repo-token>
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
<!-- org.jacoco.maven plugins -->
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.13</jacoco-maven-plugin.version>
<!-- org.mojohaus plugins -->
<versions-maven-plugin.version>2.18.0</versions-maven-plugin.version>
<!-- other -->
Expand Down Expand Up @@ -154,11 +153,6 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>${enable.preview}</arg>
</compilerArgs>
</configuration>
</plugin>

<plugin>
Expand All @@ -182,7 +176,7 @@ under the License.
<configuration>
<rules>
<requireJavaVersion>
<version>${java.version},</version>
<version>${java.version}</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[${maven.version},4.0.0)</version>
Expand Down Expand Up @@ -229,9 +223,6 @@ under the License.
<configuration>
<excludePackageNames>org.apache.datasketches.memory/internal</excludePackageNames>
<show>public</show>
<additionalOptions>
<additionalOption>${enable.preview}</additionalOption>
</additionalOptions>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -276,7 +267,6 @@ under the License.
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-failsafe-plugins.version}</version>
<configuration>
<argLine>${enable.preview}</argLine>
<trimStackTrace>false</trimStackTrace>
<useManifestOnlyJar>false</useManifestOnlyJar>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
Expand Down Expand Up @@ -431,6 +421,14 @@ under the License.
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>25</source>
<target>25</target>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

package org.apache.datasketches.memory.internal;

import static org.apache.datasketches.memory.internal.Util.characterPad;
import org.apache.datasketches.memory.MemoryRequestServer;
import org.apache.datasketches.memory.Resource;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableMemory;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
Expand All @@ -29,10 +32,7 @@
import java.nio.ByteOrder;
import java.util.Objects;

import org.apache.datasketches.memory.MemoryRequestServer;
import org.apache.datasketches.memory.Resource;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableMemory;
import static org.apache.datasketches.memory.internal.Util.characterPad;

/**
* Implements the root Resource methods plus some common static variables and check methods.
Expand Down Expand Up @@ -387,7 +387,7 @@ public MemorySegment getMemorySegment() {
@Override
public final long getRelativeOffset(final Resource that) {
final ResourceImpl that2 = (ResourceImpl) that;
return this.seg.segmentOffset(that2.seg);
return that2.seg.address() - this.seg.address();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

package org.apache.datasketches.memory.internal;

import static java.nio.channels.FileChannel.MapMode.READ_ONLY;
import static java.nio.channels.FileChannel.MapMode.READ_WRITE;
import org.apache.datasketches.memory.*;

import java.io.ByteArrayOutputStream;
import java.io.File;
Expand All @@ -36,11 +35,8 @@
import java.util.Objects;
import java.util.Set;

import org.apache.datasketches.memory.Buffer;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.memory.MemoryRequestServer;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableMemory;
import static java.nio.channels.FileChannel.MapMode.READ_ONLY;
import static java.nio.channels.FileChannel.MapMode.READ_WRITE;

/**
* Common base of native-ordered and non-native-ordered {@link WritableMemory} implementations.
Expand Down Expand Up @@ -165,7 +161,7 @@ public static WritableMemory wrapByteBuffer(
* @throws IllegalArgumentException if file is not readable.
* @throws IOException if mapping is not successful.
*/
@SuppressWarnings({"resource","preview"})
@SuppressWarnings("resource")
public static WritableMemory wrapMap(
final File file,
final long fileOffsetBytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@

package org.apache.datasketches.memory.internal;

import static org.apache.datasketches.memory.internal.ResourceImpl.LS;
import static org.apache.datasketches.memory.internal.Util.getResourceFile;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import org.apache.datasketches.memory.Memory;
import org.testng.annotations.Test;

import java.io.File;
import java.io.IOException;
import java.lang.foreign.Arena;
import java.nio.ByteOrder;

import org.apache.datasketches.memory.Memory;
import org.testng.annotations.Test;
import static org.apache.datasketches.memory.internal.ResourceImpl.LS;
import static org.apache.datasketches.memory.internal.Util.getResourceFile;
import static org.testng.Assert.*;

public class AllocateDirectMapMemoryTest {

Expand All @@ -50,6 +47,7 @@ public void simpleMap() throws IOException {
} //The Try-With-Resources will throw since it is already closed
catch (IllegalStateException e) { /* OK */ }
if (mem != null) { assertFalse(mem.isAlive()); }
UtilTest.setGettysburgAddressFileToReadWrite();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@

package org.apache.datasketches.memory.internal;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.datasketches.memory.internal.ResourceImpl.LS;
import static org.apache.datasketches.memory.internal.ResourceImpl.NON_NATIVE_BYTE_ORDER;
import static org.apache.datasketches.memory.internal.Util.getResourceFile;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.lang.foreign.Arena;
import java.nio.ByteOrder;
import java.nio.file.InvalidPathException;

import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.memory.MemoryRequestServer;
import org.apache.datasketches.memory.Resource;
import org.apache.datasketches.memory.WritableMemory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.io.*;
import java.lang.foreign.Arena;
import java.nio.ByteOrder;
import java.nio.file.InvalidPathException;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.datasketches.memory.internal.ResourceImpl.LS;
import static org.apache.datasketches.memory.internal.ResourceImpl.NON_NATIVE_BYTE_ORDER;
import static org.apache.datasketches.memory.internal.Util.getResourceFile;
import static org.testng.Assert.*;

public class AllocateDirectWritableMapMemoryTest {
private final MemoryRequestServer memReqSvr = Resource.defaultMemReqSvr;

@BeforeClass
public void setReadOnly() throws IOException {
public void setReadOnly() {
UtilTest.setGettysburgAddressFileToReadOnly();
}

@AfterClass
public void clearReadOnly() {
UtilTest.setGettysburgAddressFileToReadWrite();
}

@Test
public void simpleMap() throws IllegalArgumentException, InvalidPathException, IllegalStateException,
UnsupportedOperationException, IOException, SecurityException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,14 @@

package org.apache.datasketches.memory.internal;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import org.apache.datasketches.memory.*;
import org.testng.annotations.Test;

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

import org.apache.datasketches.memory.Resource;
import org.apache.datasketches.memory.Buffer;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableMemory;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

public class Buffer2Test {

Expand Down Expand Up @@ -352,7 +345,7 @@ public void testAsMemory() {
}
}

@Test(expectedExceptions = UnsupportedOperationException.class)
@Test(expectedExceptions = { IllegalArgumentException.class, UnsupportedOperationException.class })
public void testROByteBuffer() {
byte[] arr = new byte[64];
ByteBuffer roBB = ByteBuffer.wrap(arr).asReadOnlyBuffer();
Expand All @@ -361,7 +354,7 @@ public void testROByteBuffer() {
wbuf.putByte(0, (byte) 1);
}

@Test(expectedExceptions = UnsupportedOperationException.class)
@Test(expectedExceptions = { IllegalArgumentException.class, UnsupportedOperationException.class })
public void testROByteBuffer2() {
byte[] arr = new byte[64];
ByteBuffer roBB = ByteBuffer.wrap(arr).asReadOnlyBuffer();
Expand All @@ -370,7 +363,7 @@ public void testROByteBuffer2() {
wbuf.putByteArray(arr, 0, 64);
}

@Test(expectedExceptions = UnsupportedOperationException.class)
@Test(expectedExceptions = { IllegalArgumentException.class, UnsupportedOperationException.class })
public void testIllegalFill() {
byte[] arr = new byte[64];
ByteBuffer roBB = ByteBuffer.wrap(arr).asReadOnlyBuffer();
Expand Down
Loading