You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by "frankgrimes97 (via GitHub)" <gi...@apache.org> on 2024/11/18 17:17:52 UTC
[PR] Migrate to Java 21 FFM API [datasketches-memory]
frankgrimes97 opened a new pull request, #241:
URL: https://github.com/apache/datasketches-memory/pull/241
The project's minimium java release requirements moved from Java 17 to Java 21.
Package imports changed from `jdk.incubator.foreign` -> `java.lang.foreign` and a number of API changes were required.
Notably, the new `java.lang.foreign.Arena` class needs to be exposed when allocating native memory regions as it controls the scope and lifecycle of allocations.
Respective API docs are as follows:
- https://docs.oracle.com/en/java/javase/17/docs/api/jdk.incubator.foreign/jdk/incubator/foreign/package-summary.html
- https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/foreign/package-summary.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2484062564
Thank you for your work on this. A couple of things:
- The GitHub/Actions/Workflows will need to be updated to Java 21. Otherwise, guaranteed to fail.
- I am not familiar with NetBeans IDE, but the comments in the nb-configurations.xml file are concerning:
- "The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout." -- I presume this only applies to all NetBeans users only??
- "Without this configuration present, some functionality in the IDE may be limited or fail altogether."
- We don't allow IDE specific configuration files to be part of the version control or part of the released project. Our developers use a number of different IDEs, and they keep their own IDE configuration files as part of their own development environment. So we need to figure out how we can do this without this config file.
- The warning seems severe to me, since all of the changes you have made are nothing but pure java.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "frankgrimes97 (via GitHub)" <gi...@apache.org>.
frankgrimes97 commented on code in PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#discussion_r1850559200
##########
src/main/java/org/apache/datasketches/memory/Memory.java:
##########
@@ -102,39 +106,12 @@ static Memory map(File file) throws IOException {
* required by the implementation.
*/
static Memory map(
+ Arena arena,
File file,
long fileOffsetBytes,
long capacityBytes,
ByteOrder byteOrder) throws IOException {
- final ResourceScope scope = ResourceScope.newConfinedScope();
- return WritableMemoryImpl.wrapMap(file, fileOffsetBytes, capacityBytes, scope, true, byteOrder);
- }
-
- /**
- * Maps the specified portion of the given file into <i>Memory</i> for read operations with a ResourceScope.
- * @param file the given file to map. It must be non-null, readable and length ≥ 0.
- * @param fileOffsetBytes the position in the given file in bytes. It must not be negative.
- * @param capacityBytes the size of the mapped memory. It must not be negative.
- * @param scope the given ResourceScope.
- * It must be non-null.
- * Typically use <i>ResourceScope.newConfinedScope()</i>.
- * Warning: specifying a <i>newSharedScope()</i> is not supported.
Review Comment:
If `Arena.ofConfined()` is the only one which makes sense and is applicable here, then perhaps the Arena shouldn't be exposed in the public API at all?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "frankgrimes97 (via GitHub)" <gi...@apache.org>.
frankgrimes97 commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2483648752
context: https://github.com/apache/datasketches-java/pull/577#issuecomment-2474475021
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2487103763
If this is a temp file we can either make sure it is deleted before you run the rat test or put it in the excludes list.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2487099643
Now it is getting an Apache Rat failure on the file: force_original.txt
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2489414720
There are a couple of things I want to look at once I get this into a branch where it will be easier to me look at and use other tools to search for consistency, etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2581541688
@frankgrimes97
We saw your email to dev@ about joining our apache slack, but the sender email was marked invalid, so we can't reply there. Nonetheless we will need a valid email address for you in order for us to add you to slack. The other option is you can join Apache as a contributor, but that will require a valid email as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "frankgrimes97 (via GitHub)" <gi...@apache.org>.
frankgrimes97 commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2485785830
> Hmm. Some sort of failure on Windows having to do with file access?? I haven't used Windows for over 16 years, so I'm not sure what that is about. All the other OSs passed! Oddly, the 4.1.0 version, Which I assume you based this on, worked with Windows.
Interesting...
FWIW, I have access to a fully up-to-date Windows 11 machine at home and it compiles and runs the test suite without errors with the latest [Amazon Corretto 21](https://github.com/corretto/corretto-21/releases/tag/21.0.5.11.1) release.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2524682052
@frankgrimes97,
Thank you again for your contribution!
I have worked on it some more and migrated much of the Java 17 FFM API to use Java21 FFM API. Also did some cleanup and code consolidation, and updated the POM, and GH action workflows.
I would welcome you adding your review to the PR#242.
(Note that I found a bug in Java 21.0.2 release and had to upgrade to Java 21.0.5. See the README.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2484299617
Hmm. Some sort of failure on Windows having to do with file access?? I haven't used Windows for over 16 years, so I'm not sure what that is about. All the other OSs passed! Oddly, the 4.1.0 version, Which I assume you based this on worked with Windows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#discussion_r1847511881
##########
src/main/java/org/apache/datasketches/memory/WritableMemory.java:
##########
@@ -83,54 +83,50 @@ static WritableMemory writableWrap(
* required by the implementation.
*/
static WritableMemory writableMap(File file) throws IOException {
- return writableMap(file, 0, file.length(), ByteOrder.nativeOrder());
+ return writableMap(Arena.ofConfined(), file, 0, file.length(), ByteOrder.nativeOrder());
}
/**
- * Maps the specified portion of the given file into Memory for write operations.
- * @param file the given file to map. It must be non-null and writable.
+ * Maps the specified portion of the given file into Memory for write operations with a ResourceScope.
+ * @param file the given file to map. It must be non-null with a non-negative length and writable.
* @param fileOffsetBytes the position in the given file in bytes. It must not be negative.
- * @param capacityBytes the size of the mapped Memory.
- * @param byteOrder the given <i>ByteOrder</i>. It must be non-null.
- * @return a file-mapped WritableMemory.
- * @throws IllegalArgumentException if file is not readable or not writable.
- * @throws IOException if the specified path does not point to an existing file, or if some other I/O error occurs.
- * @throws SecurityException If a security manager is installed and it denies an unspecified permission
+ * @param capacityBytes the size of the mapped Memory. It must be ≥ 0.
+ * @param byteOrder the byte order to be used. It must be non-null.
+ * @return mapped WritableMemory.
+ * @throws IllegalArgumentException -- if file is not readable or writable.
+ * @throws IllegalArgumentException -- if file is not writable.
Review Comment:
Good Catch!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "frankgrimes97 (via GitHub)" <gi...@apache.org>.
frankgrimes97 commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2484119877
> * The GitHub/Actions/Workflows will need to be updated to Java 21. Otherwise, guaranteed to fail.
I can look at adding another commit on this PR to address the GitHub Actions/Workflows changes required once I familiarize myself with them.
> -- I presume this only applies to all NetBeans users only??
Yes, that's the case... I see now that I should have simply added it to the `.gitignore` file for consistency for how these kinds of files are currently handled for Eclipse and IntelliJ:
```
# Eclipse project files
.classpath
.project
.settings/
.checkstyle
# IntelliJ project files
*.idea
*.iml
*.ipr
*.iws
# Netbeans project files
nb-configurations.xml
```
I can amend the PR to do so.
FYI, I also added `nb-configurations.xml` to the `apache-rat-plugin`'s exclusions in the `pom.xml` to avoid it complaining with:
```
Too many files with unapproved license
```
I can remove that as well since when building locally I could just skip the spurious license check failure with the right local `mvn` build arguments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2489122616
Excellent! It now passes all tests. Good work!
I want to go through it again before I merge.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#discussion_r1847502818
##########
src/main/java/org/apache/datasketches/memory/Memory.java:
##########
@@ -102,39 +106,12 @@ static Memory map(File file) throws IOException {
* required by the implementation.
*/
static Memory map(
+ Arena arena,
File file,
long fileOffsetBytes,
long capacityBytes,
ByteOrder byteOrder) throws IOException {
- final ResourceScope scope = ResourceScope.newConfinedScope();
- return WritableMemoryImpl.wrapMap(file, fileOffsetBytes, capacityBytes, scope, true, byteOrder);
- }
-
- /**
- * Maps the specified portion of the given file into <i>Memory</i> for read operations with a ResourceScope.
- * @param file the given file to map. It must be non-null, readable and length ≥ 0.
- * @param fileOffsetBytes the position in the given file in bytes. It must not be negative.
- * @param capacityBytes the size of the mapped memory. It must not be negative.
- * @param scope the given ResourceScope.
- * It must be non-null.
- * Typically use <i>ResourceScope.newConfinedScope()</i>.
- * Warning: specifying a <i>newSharedScope()</i> is not supported.
Review Comment:
In cases where the user supplies the _Arena_ I suggest we add in the javadoc something to the effect:
> This Memory component is not thread-safe as it was designed to be used in environments where threading and parallel operation are handled at higher levels. Specifying _global()_, _ofAuto()_ or _ofShared()_ Arenas could produce unpredictable (or disastrous) results
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#discussion_r1847510620
##########
src/main/java/org/apache/datasketches/memory/WritableMemory.java:
##########
@@ -83,54 +83,50 @@ static WritableMemory writableWrap(
* required by the implementation.
*/
static WritableMemory writableMap(File file) throws IOException {
- return writableMap(file, 0, file.length(), ByteOrder.nativeOrder());
+ return writableMap(Arena.ofConfined(), file, 0, file.length(), ByteOrder.nativeOrder());
}
/**
- * Maps the specified portion of the given file into Memory for write operations.
- * @param file the given file to map. It must be non-null and writable.
+ * Maps the specified portion of the given file into Memory for write operations with a ResourceScope.
Review Comment:
I think you meant _Arena_, but that isn't correct either. The write operations of WritableMemory assume that the MemorySegment exists and has already been allocated using an Arena. (I think I made that mistake too.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#discussion_r1847532408
##########
src/main/java/org/apache/datasketches/memory/WritableMemory.java:
##########
@@ -194,12 +193,13 @@ static WritableMemory allocateDirect(
* @return WritableMemory
Review Comment:
Add warning as above, also ResourceScope needs to be replaced at about L186
##########
src/main/java/org/apache/datasketches/memory/MemoryRequestServer.java:
##########
@@ -42,24 +42,24 @@ public interface MemoryRequestServer {
default WritableMemory request(
WritableMemory currentWritableMemory,
long newCapacityBytes) {
- return request(currentWritableMemory, newCapacityBytes, ResourceScope.newConfinedScope());
+
+ return request(currentWritableMemory, newCapacityBytes, Arena.ofConfined());
}
/**
* Request new WritableMemory with the given newCapacityBytes. The current Writable Memory can be used to
* determine the byte order of the returned WritableMemory and other properties.
* @param currentWritableMemory the current writableMemory of the client. It must be non-null.
* @param newCapacityBytes The capacity being requested. It must be > the capacity of the currentWritableMemory.
- * @param scope the ResourceScope to be used for the newly allocated memory.
- * It must be non-null.
+ * @param arena the Arena to be used for the newly allocated memory. It must be non-null.
* Typically use <i>ResourceScope.newConfinedScope()</i>.
* Warning: specifying a <i>newSharedScope()</i> is not supported.
Review Comment:
Add warning as above. Also replace _ResourceScope_
##########
src/main/java/org/apache/datasketches/memory/WritableMemory.java:
##########
@@ -194,12 +193,13 @@ static WritableMemory allocateDirect(
* @return WritableMemory
*/
static WritableMemory allocateDirect(
+ Arena arena,
long capacityBytes,
long alignmentBytes,
- ResourceScope scope,
+ Scope scope,
Review Comment:
I don't think we need and Arena and a MemorySegment.Scope.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "frankgrimes97 (via GitHub)" <gi...@apache.org>.
frankgrimes97 commented on PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#issuecomment-2484141735
@leerho FYI, `nb-configurations.xml` has now been removed and the GitHub Action Workflow files have been updated to also now use Java 21 instead of Java 17.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#discussion_r1847502818
##########
src/main/java/org/apache/datasketches/memory/Memory.java:
##########
@@ -102,39 +106,12 @@ static Memory map(File file) throws IOException {
* required by the implementation.
*/
static Memory map(
+ Arena arena,
File file,
long fileOffsetBytes,
long capacityBytes,
ByteOrder byteOrder) throws IOException {
- final ResourceScope scope = ResourceScope.newConfinedScope();
- return WritableMemoryImpl.wrapMap(file, fileOffsetBytes, capacityBytes, scope, true, byteOrder);
- }
-
- /**
- * Maps the specified portion of the given file into <i>Memory</i> for read operations with a ResourceScope.
- * @param file the given file to map. It must be non-null, readable and length ≥ 0.
- * @param fileOffsetBytes the position in the given file in bytes. It must not be negative.
- * @param capacityBytes the size of the mapped memory. It must not be negative.
- * @param scope the given ResourceScope.
- * It must be non-null.
- * Typically use <i>ResourceScope.newConfinedScope()</i>.
- * Warning: specifying a <i>newSharedScope()</i> is not supported.
Review Comment:
In cases where the user supplies the _Arena_ I suggest we add in the javadoc something to the effect:
> This Memory component is not thread-safe as it was designed to be used in environments where threading and parallel operation are handled at higher levels. Specifying _global()_, _ofAuto()_ or _ofShared()_ Arenas could produce unpredictable (or disastrous) results
.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#discussion_r1847502818
##########
src/main/java/org/apache/datasketches/memory/Memory.java:
##########
@@ -102,39 +106,12 @@ static Memory map(File file) throws IOException {
* required by the implementation.
*/
static Memory map(
+ Arena arena,
File file,
long fileOffsetBytes,
long capacityBytes,
ByteOrder byteOrder) throws IOException {
- final ResourceScope scope = ResourceScope.newConfinedScope();
- return WritableMemoryImpl.wrapMap(file, fileOffsetBytes, capacityBytes, scope, true, byteOrder);
- }
-
- /**
- * Maps the specified portion of the given file into <i>Memory</i> for read operations with a ResourceScope.
- * @param file the given file to map. It must be non-null, readable and length ≥ 0.
- * @param fileOffsetBytes the position in the given file in bytes. It must not be negative.
- * @param capacityBytes the size of the mapped memory. It must not be negative.
- * @param scope the given ResourceScope.
- * It must be non-null.
- * Typically use <i>ResourceScope.newConfinedScope()</i>.
- * Warning: specifying a <i>newSharedScope()</i> is not supported.
Review Comment:
In cases where the user supplies the _Arena_ I suggest we add in the javadoc something to the effect:
> This Memory component is not thread-safe as it was designed to be used in environments where threading and parallel operation are handled at higher levels. Specifying _global()_, _ofAuto()_ or _ofShared()_ Arenas could produce unpredictable results
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho merged PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#discussion_r1847519015
##########
src/main/java/org/apache/datasketches/memory/WritableMemory.java:
##########
@@ -83,54 +83,50 @@ static WritableMemory writableWrap(
* required by the implementation.
*/
static WritableMemory writableMap(File file) throws IOException {
- return writableMap(file, 0, file.length(), ByteOrder.nativeOrder());
+ return writableMap(Arena.ofConfined(), file, 0, file.length(), ByteOrder.nativeOrder());
}
/**
- * Maps the specified portion of the given file into Memory for write operations.
- * @param file the given file to map. It must be non-null and writable.
+ * Maps the specified portion of the given file into Memory for write operations with a ResourceScope.
+ * @param file the given file to map. It must be non-null with a non-negative length and writable.
* @param fileOffsetBytes the position in the given file in bytes. It must not be negative.
- * @param capacityBytes the size of the mapped Memory.
- * @param byteOrder the given <i>ByteOrder</i>. It must be non-null.
- * @return a file-mapped WritableMemory.
- * @throws IllegalArgumentException if file is not readable or not writable.
- * @throws IOException if the specified path does not point to an existing file, or if some other I/O error occurs.
- * @throws SecurityException If a security manager is installed and it denies an unspecified permission
+ * @param capacityBytes the size of the mapped Memory. It must be ≥ 0.
+ * @param byteOrder the byte order to be used. It must be non-null.
+ * @return mapped WritableMemory.
+ * @throws IllegalArgumentException -- if file is not readable or writable.
+ * @throws IllegalArgumentException -- if file is not writable.
+ * @throws IOException - if the specified path does not point to an existing file, or if some other I/O error occurs.
+ * @throws SecurityException - If a security manager is installed and it denies an unspecified permission
* required by the implementation.
*/
static WritableMemory writableMap(
File file,
long fileOffsetBytes,
long capacityBytes,
ByteOrder byteOrder) throws IOException {
- final ResourceScope scope = ResourceScope.newConfinedScope();
- return WritableMemoryImpl.wrapMap(file, fileOffsetBytes, capacityBytes, scope, false, byteOrder);
+ return WritableMemoryImpl.wrapMap(Arena.ofConfined(), file, fileOffsetBytes, capacityBytes, false, byteOrder);
}
/**
- * Maps the specified portion of the given file into Memory for write operations with a ResourceScope.
- * @param file the given file to map. It must be non-null with a non-negative length and writable.
+ * Maps the specified portion of the given file into Memory for write operations.
+ * @param arena the given arena to map. It must be non-null.
+ * @param file the given file to map. It must be non-null and writable.
* @param fileOffsetBytes the position in the given file in bytes. It must not be negative.
- * @param capacityBytes the size of the mapped Memory. It must be ≥ 0.
- * @param scope the given ResourceScope.
- * It must be non-null.
- * Typically use <i>ResourceScope.newConfinedScope()</i>.
- * Warning: specifying a <i>newSharedScope()</i> is not supported.
Review Comment:
Similar warning as above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
Re: [PR] Migrate to Java 21 FFM API [datasketches-memory]
Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #241:
URL: https://github.com/apache/datasketches-memory/pull/241#discussion_r1847510620
##########
src/main/java/org/apache/datasketches/memory/WritableMemory.java:
##########
@@ -83,54 +83,50 @@ static WritableMemory writableWrap(
* required by the implementation.
*/
static WritableMemory writableMap(File file) throws IOException {
- return writableMap(file, 0, file.length(), ByteOrder.nativeOrder());
+ return writableMap(Arena.ofConfined(), file, 0, file.length(), ByteOrder.nativeOrder());
}
/**
- * Maps the specified portion of the given file into Memory for write operations.
- * @param file the given file to map. It must be non-null and writable.
+ * Maps the specified portion of the given file into Memory for write operations with a ResourceScope.
Review Comment:
I think you meant _Arena_, but that isn't correct either. The write operations of WritableMemory assume that the MemorySegment exists and has already been allocated using an Arena.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org