This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch update_7.0.X
in repository https://gitbox.apache.org/repos/asf/datasketches-memory.git
The following commit(s) were added to refs/heads/update_7.0.X by this push:
new a683bddc Make it more obvious what methods in main have been disabled
by commenting them out.
a683bddc is described below
commit a683bddcea79bd8482fdb11b3406ec43dedaa299
Author: Lee Rhodes <[email protected]>
AuthorDate: Sat May 30 10:06:03 2026 -0700
Make it more obvious what methods in main have been disabled by
commenting them out.
---
.../org/apache/datasketches/memory/Resource.java | 12 +-
.../datasketches/memory/internal/ResourceImpl.java | 36 +++---
.../org/apache/datasketches/memory/Memory.java | 72 +++++------
.../org/apache/datasketches/memory/Resource.java | 132 ++++++++++-----------
.../apache/datasketches/memory/WritableMemory.java | 71 +++++------
.../memory/internal/BaseWritableMemoryImpl.java | 36 ++++++
.../datasketches/memory/internal/ResourceImpl.java | 56 ++++++---
.../apache/datasketches/memory/package-info.java | 2 +
pom.xml | 5 -
9 files changed, 233 insertions(+), 189 deletions(-)
diff --git
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/Resource.java
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/Resource.java
index 49b5ad74..1490d37d 100644
---
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/Resource.java
+++
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/Resource.java
@@ -259,6 +259,12 @@ public interface Resource extends AutoCloseable {
*/
boolean isLoaded();
+ /**
+ * Returns {@code true} if the backing resource is a memory-mapped file.
+ * @return {@code true} if the backing resource is a memory-mapped file.
+ */
+ boolean isMapped();
+
/**
* If {@code true}, this is a <i>Memory</i> or <i>WritableMemory</i>
instance, which provides the Memory API.
* The Memory API is the principal API for this Memory Component.
@@ -275,12 +281,6 @@ public interface Resource extends AutoCloseable {
*/
boolean isMemory();
- /**
- * Returns {@code true} if the backing resource is a memory-mapped file.
- * @return {@code true} if the backing resource is a memory-mapped file.
- */
- boolean isMapped();
-
/**
* If true, all put and get operations will assume the non-native ByteOrder.
* Otherwise, all put and get operations will assume the native ByteOrder.
diff --git
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/ResourceImpl.java
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/ResourceImpl.java
index 5553e480..53957b1f 100644
---
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/ResourceImpl.java
+++
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/ResourceImpl.java
@@ -37,8 +37,7 @@ import org.apache.datasketches.memory.Resource;
*/
//@SuppressWarnings("restriction")
public abstract class ResourceImpl implements Resource {
- public static final int JDK_MAJOR; //11, 17, 21
- public static final String unsupportedJDK;
+ public static final int JAVA_MAJOR; //11, 17, 21
//Used to convert "type" to bytes: bytes = longs << LONG_SHIFT
static final int BOOLEAN_SHIFT = 0;
@@ -83,10 +82,9 @@ public abstract class ResourceImpl implements Resource {
static final String THREAD_EXCEPTION_TEXT = "Attempted access outside owning
thread";
static {
- final String jdkVer = System.getProperty("java.version");
- JDK_MAJOR = parseJavaVersion(jdkVer);
- unsupportedJDK = "JDK Not supported. Please use JDK 11. Given JDK: ";
- checkJavaVersion(JDK_MAJOR);
+ final String javaVer = System.getProperty("java.version");
+ JAVA_MAJOR = parseJavaVersion(javaVer);
+ checkJavaVersion(JAVA_MAJOR);
}
//set by the leaf nodes
@@ -143,11 +141,11 @@ public abstract class ResourceImpl implements Resource {
/**
* Checks the runtime Java Version string.
- * @param jdkMajor the first number from the
<i>System.getProperty("java.version")</i> string."
+ * @param javaMajor the first number from the
<i>System.getProperty("java.version")</i> string."
*/
- static void checkJavaVersion(final int jdkMajor) {
- final boolean ok = jdkMajor == 11;
- if (!ok) { throw new IllegalArgumentException(unsupportedJDK + jdkMajor);
+ static void checkJavaVersion(final int javaMajor) {
+ final boolean ok = javaMajor == 11;
+ if (!ok) { throw new IllegalArgumentException("This Java version is not
supported: " + javaMajor);
}
}
@@ -367,22 +365,22 @@ public abstract class ResourceImpl implements Resource {
}
/**
- * Returns the JDK major version.
- * @return the JDK major version.
+ * Returns the Java major version.
+ * @return the Java major version.
* @throws IllegalArgumentException for an improper Java version string.
*/
- static final int parseJavaVersion(final String jdkVer) {
- final int jdkMajor;
+ static final int parseJavaVersion(final String javaVer) {
+ final int javaMajor;
try {
- String[] parts = jdkVer.trim().split("^0-9\\.");//grab only number
groups and "."
+ String[] parts = javaVer.trim().split("^0-9\\.");//grab only number
groups and "."
parts = parts[0].split("\\."); //split out the number groups
final int p0 = Integer.parseInt(parts[0]); //the first number group
final int p1 = (parts.length > 1) ? Integer.parseInt(parts[1]) : 0;
//2nd number group, or 0
- jdkMajor = (p0 == 1) ? p1 : p0;
+ javaMajor = (p0 == 1) ? p1 : p0; //1.X becomes X
} catch (final NumberFormatException | ArrayIndexOutOfBoundsException e) {
- throw new IllegalArgumentException("Improper Java version string: " +
jdkVer + LS + e);
+ throw new IllegalArgumentException("Improper Java version string: " +
javaVer + LS + e);
}
- return jdkMajor;
+ return javaMajor;
}
//REACHABILITY FENCE
@@ -443,7 +441,7 @@ public abstract class ResourceImpl implements Resource {
sb.append("Read Only : ").append(state.isReadOnly()).append(LS);
sb.append("Type Byte Order :
").append(state.getTypeByteOrder().toString()).append(LS);
sb.append("Native Byte Order :
").append(ByteOrder.nativeOrder().toString()).append(LS);
- sb.append("JDK Runtime Version : ").append(JDK_MAJOR).append(LS);
+ sb.append("JDK Runtime Version : ").append(JAVA_MAJOR).append(LS);
//Data detail
if (withData) {
sb.append("Data, bytes : 0 1 2 3 4 5 6 7");
diff --git
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/Memory.java
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/Memory.java
index 3fab1b80..350298f5 100644
---
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/Memory.java
+++
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/Memory.java
@@ -19,9 +19,7 @@
package org.apache.datasketches.memory;
-import static
org.apache.datasketches.memory.internal.ResourceImpl.unsupportedJDK;
-
-import java.io.File;
+//import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -70,39 +68,41 @@ public interface Memory extends Resource {
//Duplicates make no sense here
//MAP
- /**
- * NOTE: This operation is unsupported for JDKs 17 and 21.
- * Calling this method will resort in an {@link
UnsupportedOperationException}
- *
- * <p>Maps the given file into <i>Memory</i> for read operations.</p>
- * Calling this method is equivalent to calling
- * {@link #map(File, long, long, ByteOrder)
- * map(file, 0, file.length(), ByteOrder.nativeOrder())}.
- * @param file the given file to map. It must be non-null with a
non-negative length and readable.
- * @return <i>Memory</i> for managing the mapped memory.
- */
- static Memory map(final File file) {
- return map(file, 0, file.length(), ByteOrder.nativeOrder());
- }
-
- /**
- * NOTE: This operation is unsupported for JDKs 17 and 21.
- * Please use datasketches-java 9.0+, which supports JDK 25.
- *
- * <p>Maps the specified portion of the given file into <i>Memory</i> for
read operations.</p>
- * @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
be ≥ 0.
- * @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 <i>Memory</i> for managing the mapped memory.
- */
- static Memory map(
- final File file,
- final long fileOffsetBytes,
- final long capacityBytes,
- final ByteOrder byteOrder) {
- throw new UnsupportedOperationException(unsupportedJDK);
- }
+// /**
+// * Maps the given file into <i>Memory</i> for read operations
+// * Calling this method is equivalent to calling
+// * {@link #map(File, long, long, ByteOrder)
+// * map(file, 0, file.length(), ByteOrder.nativeOrder())}.
+// * @param file the given file to map. It must be non-null with a
non-negative length and readable.
+// * @return <i>Memory</i> for managing the mapped memory.
+// * @throws IllegalArgumentException if path is not associated with the
default file system.
+// * @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 Memory map(final File file) throws IOException {
+// return map(file, 0, file.length(), ByteOrder.nativeOrder());
+// }
+
+// /**
+// * Maps the specified portion of the given file into <i>Memory</i> for
read operations.
+// * @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
be ≥ 0.
+// * @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 <i>Memory</i> for managing the mapped memory.
+// * @throws IllegalArgumentException if path is not associated with the
default file system.
+// * @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 Memory map(
+// final File file,
+// final long fileOffsetBytes,
+// final long capacityBytes,
+// final ByteOrder byteOrder) throws IOException {
+// return BaseWritableMemoryImpl.wrapMap(file, fileOffsetBytes,
capacityBytes, true, byteOrder);
+// }
//NO ALLOCATE OFF-HEAP, makes no sense
diff --git
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/Resource.java
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/Resource.java
index ec9bfbe3..6ce938cb 100644
---
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/Resource.java
+++
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/Resource.java
@@ -19,8 +19,6 @@
package org.apache.datasketches.memory;
-import static
org.apache.datasketches.memory.internal.ResourceImpl.unsupportedJDK;
-
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -135,29 +133,30 @@ public interface Resource extends AutoCloseable {
long thatOffsetBytes,
long lengthBytes);
- /**
- * NOTE: This operation is unsupported for JDKs 17 and 21.
- * Please use datasketches-java 9.0+, which supports JDK 25.
- *
- * <p>Forces any changes made to the contents of this memory-mapped Resource
to be written to the storage
- * device described by the configured file descriptor.</p>
- *
- * <p>If the file descriptor associated with this memory-mapped Resource
resides on a local storage device then when
- * this method returns, it is guaranteed that all changes made to this
mapped Resource since it was created, or since
- * this method was last invoked, will have been written to that device.</p>
- *
- * <p>If the file descriptor associated with this memory-mapped Resource
does not reside on a local device then no
- * such guarantee is made.</p>
- *
- * <p>If this memory-mapped Resource was not mapped in read/write mode
- * ({@link java.nio.channels.FileChannel.MapMode#READ_WRITE}) then invoking
this method may have no effect.
- * In particular, this method has no effect for files mapped in read-only or
private
- * mapping modes. This method may or may not have an effect for
implementation-specific mapping modes.</p>
- *
- */
- default void force() {
- throw new UnsupportedOperationException(unsupportedJDK);
- }
+// /**
+// * Forces any changes made to the contents of this memory-mapped Resource
to be written to the storage
+// * device described by the configured file descriptor.
+// *
+// * <p>If the file descriptor associated with this memory-mapped Resource
resides on a local storage device then when
+// * this method returns, it is guaranteed that all changes made to this
mapped Resource since it was created, or since
+// * this method was last invoked, will have been written to that device.</p>
+// *
+// * <p>If the file descriptor associated with this memory-mapped Resource
does not reside on a local device then no
+// * such guarantee is made.</p>
+// *
+// * <p>If this memory-mapped Resource was not mapped in read/write mode
+// * ({@link java.nio.channels.FileChannel.MapMode#READ_WRITE}) then
invoking this method may have no effect.
+// * In particular, this method has no effect for files mapped in read-only
or private
+// * mapping modes. This method may or may not have an effect for
implementation-specific mapping modes.</p>
+// *
+// * @throws IllegalStateException if this Resource is not <em>alive</em>.
+// * @throws IllegalStateException if this method is not accessed from the
owning thread.
+// * @throws UnsupportedOperationException if this Resource is not
memory-mapped, e.g. if {@code isMapped() == false}.
+// * @throws ReadOnlyException if this Resource is read-only.
+// * @throws RuntimeException if there is some other error writing the
contents of this
+// * memory-mapped Resource to the associated storage device.
+// */
+// void force();
/**
* Gets the capacity of this object in bytes
@@ -239,27 +238,32 @@ public interface Resource extends AutoCloseable {
*/
boolean isHeap();
- /**
- * NOTE: This operation returns {@code false} for JDKs 17 and 21..
- * Please use datasketches-java 9.0+, which supports JDK 25.
- *
- * <p>Tells whether or not the contents of this memory-mapped Resource is
resident in physical memory.</p>
- *
- * <p>A return value of {@code true} implies that it is highly likely that
all of the data in this memory-mapped
- * Resource is resident in physical memory and may therefore be accessed
without incurring any virtual-memory page
- * faults or I/O operations.</p>
- *
- * <p>A return value of {@code false} does not necessarily imply that all of
the data in this memory-mapped Resource
- * is not resident in physical memory.</p>
- *
- * <p>The returned value is a hint, rather than a guarantee, because the
underlying operating system may have paged
- * out some of this Resource's data by the time that an invocation of this
method returns.</p>
- *
- * @return true if it is likely that all of the data in this memory-mapped
Resource is resident in physical memory
- */
- default boolean isLoaded() {
- return false;
- }
+// /**
+// * Tells whether or not the contents of this memory-mapped Resource is
resident in physical memory.
+// *
+// * <p>A return value of {@code true} implies that it is highly likely that
all of the data in this memory-mapped
+// * Resource is resident in physical memory and may therefore be accessed
without incurring any virtual-memory page
+// * faults or I/O operations.</p>
+// *
+// * <p>A return value of {@code false} does not necessarily imply that all
of the data in this memory-mapped Resource
+// * is not resident in physical memory.</p>
+// *
+// * <p>The returned value is a hint, rather than a guarantee, because the
underlying operating system may have paged
+// * out some of this Resource's data by the time that an invocation of this
method returns.</p>
+// *
+// * @return true if it is likely that all of the data in this memory-mapped
Resource is resident in physical memory
+// *
+// * @throws IllegalStateException if this Resource is not <em>alive</em>.
+// * @throws IllegalStateException if this method is not accessed from the
owning thread.
+// * @throws UnsupportedOperationException if this Resource is not
memory-mapped, e.g. if {@code isMapped() == false}.
+// */
+// boolean isLoaded();
+
+// /**
+// * Returns {@code true} if the backing resource is a memory-mapped file.
+// * @return {@code true} if the backing resource is a memory-mapped file.
+// */
+// boolean isMapped();
/**
* If {@code true}, this is a <i>Memory</i> or <i>WritableMemory</i>
instance, which provides the Memory API.
@@ -277,17 +281,6 @@ public interface Resource extends AutoCloseable {
*/
boolean isMemory();
- /**
- * NOTE: This operation returns {@code false} for JDKs 17 and 21..
- * Please use datasketches-java 9.0+, which supports JDK 25.
- *
- * <p>Returns {@code true} if the backing resource is a memory-mapped
file.</p>
- * @return {@code true} if the backing resource is a memory-mapped file.
- */
- default boolean isMapped() {
- return false;
- }
-
/**
* If true, all put and get operations will assume the non-native ByteOrder.
* Otherwise, all put and get operations will assume the native ByteOrder.
@@ -324,19 +317,18 @@ public interface Resource extends AutoCloseable {
*/
boolean isAlive();
- /**
- * NOTE: This operation is unsupported for JDKs 17 and 21.
- * Please use datasketches-java 9.0+, which supports JDK 25.
- *
- * <p>Loads the contents of this memory-mapped Resource into physical
memory.</p>
- *
- * <p>This method makes a best effort to ensure that, when it returns, this
contents of the memory-mapped Resource is
- * resident in physical memory. Invoking this method may cause some number
of page faults and
- * I/O operations to occur.</p>
- */
- default void load() {
- throw new UnsupportedOperationException(unsupportedJDK);
- }
+// /**
+// * Loads the contents of this memory-mapped Resource into physical memory.
+// *
+// * <p>This method makes a best effort to ensure that, when it returns,
this contents of the memory-mapped Resource is
+// * resident in physical memory. Invoking this method may cause some number
of page faults and
+// * I/O operations to occur.</p>
+// *
+// * @throws IllegalStateException if this Resource is not <em>alive</em>.
+// * @throws IllegalStateException if this method is not accessed from the
owning thread.
+// * @throws UnsupportedOperationException if this Resource is not
memory-mapped, e.g. if {@code isMapped() == false}.
+// */
+// void load();
/**
* Returns a description of this object with an optional formatted hex
string of the data
diff --git
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/WritableMemory.java
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/WritableMemory.java
index 4b495f46..3e076b6f 100644
---
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/WritableMemory.java
+++
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/WritableMemory.java
@@ -19,10 +19,10 @@
package org.apache.datasketches.memory;
-import static
org.apache.datasketches.memory.internal.ResourceImpl.unsupportedJDK;
import static org.apache.datasketches.memory.internal.Util.negativeCheck;
-import java.io.File;
+//import java.io.File;
+//import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Objects;
@@ -73,38 +73,41 @@ public interface WritableMemory extends Memory {
//Duplicates make no sense here
//MAP
- /**
- * NOTE: This operation is unsupported for JDKs 17 and 21.
- * Please use datasketches-java 9.0+, which supports JDK 25.
- *
- * <p>Maps the entire given file into native-ordered WritableMemory for
write operations.</p>
- * Calling this method is equivalent to calling
- * {@link #writableMap(File, long, long, ByteOrder) writableMap(file, 0,
file.length(), ByteOrder.nativeOrder())}.
- * @param file the given file to map. It must be non-null and writable.
- * @return a file-mapped WritableMemory
- */
- static WritableMemory writableMap(final File file) {
- return writableMap(file, 0, file.length(), ByteOrder.nativeOrder());
- }
-
- /**
- * NOTE: This operation is unsupported for JDKs 17 and 21.
- * Please use datasketches-java 9.0+, which supports JDK 25.
- *
- * <p>Maps the specified portion of the given file into Memory for write
operations.</p>
- * @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
be ≥ 0.
- * @param capacityBytes the size of the mapped Memory. It must be ≥ 0.
- * @param byteOrder the given <i>ByteOrder</i>. It must be non-null.
- * @return a file-mapped WritableMemory.
- */
- static WritableMemory writableMap(
- final File file,
- final long fileOffsetBytes,
- final long capacityBytes,
- final ByteOrder byteOrder) {
- throw new UnsupportedOperationException(unsupportedJDK);
- }
+// /**
+// * Maps the entire given file into native-ordered WritableMemory for write
operations
+// * Calling this method is equivalent to calling
+// * {@link #writableMap(File, long, long, ByteOrder) writableMap(file, 0,
file.length(), ByteOrder.nativeOrder())}.
+// * @param file the given file to map. It must be non-null and writable.
+// * @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
+// * required by the implementation.
+// */
+// static WritableMemory writableMap(final File file) throws IOException {
+// return writableMap(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.
+// * @param fileOffsetBytes the position in the given file in bytes. It must
be ≥ 0.
+// * @param capacityBytes the size of the mapped Memory. It must be ≥ 0.
+// * @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
+// * required by the implementation.
+// */
+// static WritableMemory writableMap(
+// final File file,
+// final long fileOffsetBytes,
+// final long capacityBytes,
+// final ByteOrder byteOrder) throws IOException {
+// if (!file.canWrite()) { throw new ReadOnlyException("file must be
writable."); }
+// return BaseWritableMemoryImpl.wrapMap(file, fileOffsetBytes,
capacityBytes, false, byteOrder);
+// }
//ALLOCATE OFF-HEAP
diff --git
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java
index d9c18975..2ab1dc40 100644
---
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java
+++
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java
@@ -29,6 +29,7 @@ import static
org.apache.datasketches.memory.internal.UnsafeUtil.ARRAY_SHORT_IND
import static org.apache.datasketches.memory.internal.UnsafeUtil.unsafe;
import static org.apache.datasketches.memory.internal.Util.negativeCheck;
+//import java.io.File
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -110,6 +111,41 @@ public abstract class BaseWritableMemoryImpl extends
ResourceImpl implements Wri
abb.offsetBytes, abb.capacityBytes, typeId, cumOffsetBytes,
memReqSvr, byteBuffer);
}
+// /**
+// * The static constructor that chooses the correct Map leaf node based on
the byte order.
+// * @param file the file being wrapped. It must be non-null.
+// * @param fileOffsetBytes the file offset bytes. It must be ≥ 0.
+// * @param capacityBytes the requested capacity of the memory mapped
region. It must be ≥ 0.
+// * @param localReadOnly the requested read-only state
+// * @param byteOrder the requested byte-order. It must be non-null.
+// * @return this class constructed via the leaf node.
+// */
+// public static WritableMemory wrapMap(final File file, final long
fileOffsetBytes,
+// final long capacityBytes, final boolean localReadOnly, final ByteOrder
byteOrder) {
+// Objects.requireNonNull(file, "File must be non-null.");
+// Util.negativeCheck(fileOffsetBytes, "fileOffsetBytes");
+// Util.negativeCheck(capacityBytes, "capacityBytes");
+// Objects.requireNonNull(byteOrder, "ByteOrder must be non-null.");
+// final AllocateDirectWritableMap dirWMap =
+// new AllocateDirectWritableMap(file, fileOffsetBytes, capacityBytes,
localReadOnly);
+// final int typeId = (dirWMap.resourceReadOnly || localReadOnly) ?
READONLY : 0;
+// final long cumOffsetBytes = dirWMap.nativeBaseOffset;
+// final BaseWritableMemoryImpl wmem = Util.isNativeByteOrder(byteOrder)
+// ? new MapWritableMemoryImpl(
+// dirWMap,
+// 0L,
+// capacityBytes,
+// typeId,
+// cumOffsetBytes)
+// : new MapNonNativeWritableMemoryImpl(
+// dirWMap,
+// 0L,
+// capacityBytes,
+// typeId,
+// cumOffsetBytes);
+// return wmem;
+// }
+
/**
* The static constructor that chooses the correct Direct leaf node based on
the byte order.
* @param capacityBytes the requested capacity for the Direct (off-heap)
memory. It must be ≥ 0.
diff --git
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/internal/ResourceImpl.java
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/internal/ResourceImpl.java
index 299edf01..9a1fe309 100644
---
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/internal/ResourceImpl.java
+++
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/internal/ResourceImpl.java
@@ -37,8 +37,7 @@ import org.apache.datasketches.memory.Resource;
*/
//@SuppressWarnings("restriction")
public abstract class ResourceImpl implements Resource {
- public static final int JDK_MAJOR; //11, 17, 21
- public static final String unsupportedJDK;
+ public static final int JAVA_MAJOR; //11, 17, 21
//Used to convert "type" to bytes: bytes = longs << LONG_SHIFT
static final int BOOLEAN_SHIFT = 0;
@@ -83,10 +82,9 @@ public abstract class ResourceImpl implements Resource {
static final String THREAD_EXCEPTION_TEXT = "Attempted access outside owning
thread";
static {
- final String jdkVer = System.getProperty("java.version");
- JDK_MAJOR = parseJavaVersion(jdkVer);
- unsupportedJDK = "JDK Not supported. Please use JDK 17 or 21. Given JDK:
";
- checkJavaVersion(JDK_MAJOR);
+ final String javaVer = System.getProperty("java.version");
+ JAVA_MAJOR = parseJavaVersion(javaVer);
+ checkJavaVersion(JAVA_MAJOR);
}
//set by the leaf nodes
@@ -143,11 +141,11 @@ public abstract class ResourceImpl implements Resource {
/**
* Checks the runtime Java Version string.
- * @param jdkMajor the first number from the
<i>System.getProperty("java.version")</i> string."
+ * @param javaMajor the first number from the
<i>System.getProperty("java.version")</i> string."
*/
- static void checkJavaVersion(final int jdkMajor) {
- final boolean ok = ( (jdkMajor == 17) || (jdkMajor == 21) );
- if (!ok) { throw new IllegalArgumentException(unsupportedJDK + jdkMajor);
+ static void checkJavaVersion(final int javaMajor) {
+ final boolean ok = ( (javaMajor == 17) || (javaMajor == 21) );
+ if (!ok) { throw new IllegalArgumentException("This Java version is not
supported: " + javaMajor);
}
}
@@ -226,6 +224,11 @@ public abstract class ResourceImpl implements Resource {
return CompareAndCopy.equals(this, thisOffsetBytes, (ResourceImpl) that,
thatOffsetBytes, lengthBytes);
}
+// @Override
+// public void force() { //overridden by Map Leaves
+// throw new UnsupportedOperationException(NOT_MAPPED_FILE_RESOURCE);
+// }
+
//Overridden by ByteBuffer Leaves. Used internally and for tests.
ByteBuffer getByteBuffer() {
return null;
@@ -298,6 +301,16 @@ public abstract class ResourceImpl implements Resource {
return getUnsafeObject() != null;
}
+// @Override
+// public boolean isLoaded() { //overridden by Map Leaves
+// throw new IllegalStateException(NOT_MAPPED_FILE_RESOURCE);
+// }
+//
+// @Override
+// public boolean isMapped() {
+// return (getTypeId() & MAP) > 0;
+// }
+
@Override
public boolean isMemory() {
return (getTypeId() & BUFFER) == 0;
@@ -342,27 +355,32 @@ public abstract class ResourceImpl implements Resource {
return true;
}
+// @Override
+// public void load() { //overridden by Map leaves
+// throw new IllegalStateException(NOT_MAPPED_FILE_RESOURCE);
+// }
+
private static String pad(final String s, final int fieldLen) {
return characterPad(s, fieldLen, ' ' , true);
}
/**
- * Returns the JDK major version.
- * @return the JDK major version.
+ * Returns the Java major version.
+ * @return the Java major version.
* @throws IllegalArgumentException for an improper Java version string.
*/
- static final int parseJavaVersion(final String jdkVer) {
- final int jdkMajor;
+ static final int parseJavaVersion(final String javaVer) {
+ final int javaMajor;
try {
- String[] parts = jdkVer.trim().split("^0-9\\.");//grab only number
groups and "."
+ String[] parts = javaVer.trim().split("^0-9\\.");//grab only number
groups and "."
parts = parts[0].split("\\."); //split out the number groups
final int p0 = Integer.parseInt(parts[0]); //the first number group
final int p1 = (parts.length > 1) ? Integer.parseInt(parts[1]) : 0;
//2nd number group, or 0
- jdkMajor = (p0 == 1) ? p1 : p0;
+ javaMajor = (p0 == 1) ? p1 : p0; //1.X becomes X
} catch (final NumberFormatException | ArrayIndexOutOfBoundsException e) {
- throw new IllegalArgumentException("Improper Java version string: " +
jdkVer + LS + e);
+ throw new IllegalArgumentException("Improper Java version string: " +
javaVer + LS + e);
}
- return jdkMajor;
+ return javaMajor;
}
//REACHABILITY FENCE
@@ -423,7 +441,7 @@ public abstract class ResourceImpl implements Resource {
sb.append("Read Only : ").append(state.isReadOnly()).append(LS);
sb.append("Type Byte Order :
").append(state.getTypeByteOrder().toString()).append(LS);
sb.append("Native Byte Order :
").append(ByteOrder.nativeOrder().toString()).append(LS);
- sb.append("JDK Runtime Version : ").append(JDK_MAJOR).append(LS);
+ sb.append("JDK Runtime Version : ").append(JAVA_MAJOR).append(LS);
//Data detail
if (withData) {
sb.append("Data, bytes : 0 1 2 3 4 5 6 7");
diff --git
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/package-info.java
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/package-info.java
index f4013025..17bc4916 100644
---
a/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/package-info.java
+++
b/datasketches-memory-java17_21/src/main/java/org/apache/datasketches/memory/package-info.java
@@ -20,6 +20,8 @@
/**
* <b>This package defines the interfaces for the DataSketches-Memory project
* for Java 17 and Java 21.</b>
+ *
+ * Note: Memory Mapping is disabled for this product.
*
* @author Lee Rhodes
*/
diff --git a/pom.xml b/pom.xml
index 923eb41b..6f24e714 100644
--- a/pom.xml
+++ b/pom.xml
@@ -421,11 +421,6 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
- <configuration>
- <nonFilteredFileExtensions>
- <nonFilteredFileExtension>DS_Store</nonFilteredFileExtension>
- </nonFilteredFileExtensions>
- </configuration>
</plugin>
<plugin>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]