run: >
mvn clean install
-DskipTests=true
- -Dmaven.javadoc.skip=true
-Dgpg.skip=true
--toolchains .github/workflows/.toolchains.xml
- name: Package
run: >
mvn package
- -Dmaven.javadoc.skip=true
+ -Dmaven.javadoc.skip=false
-Dgpg.skip=true
- -Denvironment=ci
- -Dmatrix.jdk.version=${{matrix.jdk}}
--toolchains .github/workflows/.toolchains.xml
# The GitTag for CI purposes is irrelevant
- name: Custom build script
run: |
- ./tools/scripts/compile-package-jar.sh $JAVA_HOME x.y.z .
+ ./tools/scripts/package-single-release-jar.sh $JAVA_HOME x.y.z .
shell: bash
- name: Test & Report
-Dcoveralls-repo-token=${repo_token}
-Dmaven.javadoc.skip=true
-Dgpg.skip=true
- -Dmatrix.jdk.version=${{matrix.jdk}}
- --toolchains .github/workflows/.toolchains.xml
\ No newline at end of file
+ --toolchains .github/workflows/.toolchains.xml
*.properties
*.releaseBackup
*.next
-*.tag
+*.asc
# Jekyll
_site/
* If your application **is not a JPMS module** use the following table. Choose the columns that describe your use of the Memory API. If any of the columns contain a *Yes*, then the JVM argument in the first column of the row containing a *Yes* will be required. If you are not sure the extent of the Memory API being used, there is no harm in specifying all 4 JVM arguments. Note: do not embed any spaces in the full argument.
-| JVM Arguments for non-JPMS Applications | Direct ByteBuffer | Direct | MemoryMapped Files |
-|:------------------------------------------------------:|:----------------:|:------:|:------------------:|
-| --add-exports java.base/jdk.internal.misc= ALL-UNNAMED | | Yes | |
-| --add-exports java.base/jdk.internal.ref= ALL-UNNAMED | | Yes | Yes |
-| --add-opens java.base/java.nio= ALL-UNNAMED | | Yes | Yes |
-| --add-opens java.base/sun.nio.ch= ALL-UNNAMED | | | Yes |
+| JVM Arguments for non-JPMS Applications | Direct ByteBuffer | Direct | MemoryMapped Files |
+| :----------------------------------------------------: | :---------------: | :----: | :----------------: |
+| --add-exports java.base/jdk.internal.misc= ALL-UNNAMED | | Yes | |
+| --add-exports java.base/jdk.internal.ref= ALL-UNNAMED | | Yes | Yes |
+| --add-opens java.base/java.nio= ALL-UNNAMED | | Yes | Yes |
+| --add-opens java.base/sun.nio.ch= ALL-UNNAMED | | | Yes |
* If your application **is a JPMS module** use the following table. Choose the columns that describe your use of the Memory API. If any of the columns contain a *Yes*, then the JVM argument in the first column of the row containing a *Yes* will be required. If you are not sure the extent of the Memory API being used, there is no harm in specifying all 4 JVM arguments. Note: do not embed any spaces in the full argument.
-| JVM Arguments for JPMS Applications | Direct ByteBuffer | Direct | MemoryMapped Files |
-|:-------------------------------------------------------------------------:|:----------------:|:------:|:------------------:|
-| --add-exports java.base/jdk.internal.misc= org.apache.datasketches.memory | | Yes | |
-| --add-exports java.base/jdk.internal.ref= org.apache.datasketches.memory | | Yes | Yes |
-| --add-opens java.base/java.nio= org.apache.datasketches.memory | | Yes | Yes |
-| --add-opens java.base/sun.nio.ch= org.apache.datasketches.memory | Yes | | Yes |
+| JVM Arguments for JPMS Applications | Direct ByteBuffer | Direct | MemoryMapped Files |
+| :-----------------------------------------------------------------------: | :---------------: | :----: | :----------------: |
+| --add-exports java.base/jdk.internal.misc= org.apache.datasketches.memory | | Yes | |
+| --add-exports java.base/jdk.internal.ref= org.apache.datasketches.memory | | Yes | Yes |
+| --add-opens java.base/java.nio= org.apache.datasketches.memory | | Yes | Yes |
+| --add-opens java.base/sun.nio.ch= org.apache.datasketches.memory | Yes | | Yes |
## DEVELOPER USAGE
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)
-2) This project is structured as a Maven multi-module project.
- Building this project might affect plugins that require early dependency resolution, such as the
- javadoc and eclipse plugins.
- The Maven build instructions below have been modified to use the `process-classes` phase (instead of `compile`)
- for these use cases.
-
- For more information, see this [Maven Reactor Issue](https://issues.apache.org/jira/browse/MNG-3283).
-
#### Dependencies
There are no run-time dependencies. See the pom.xml file for test dependencies.
To run javadoc on this multi-module project, use:
- mvn clean process-classes javadoc:javadoc -DskipTests=true
+ mvn clean javadoc:javadoc -DskipTests=true
-To run the CI tests against the multi-release JAR for specific JVM versions [11-13], use:
+To build the multi-release JAR, use:
- mvn clean package -Denvironment=ci -Dmatrix.jdk.version=11
+ mvn clean package
To run the eclipse plugin on this multi-module project, use:
- mvn clean process-classes eclipse:eclipse -DskipTests=true
+ mvn clean eclipse:eclipse -DskipTests=true
To install jars built from the downloaded source:
#### Building for a specific java version
-A build script named **compile-package-jar.sh** has been provided to package a JAR for a specific java version. This is necessary in cases where a developer is unable to install all the required versions of the JDK that are required as part of the Maven build.
+A build script named **package-single-release-jar.sh** has been provided to package a JAR for a specific java version. This is necessary in cases where a developer is unable to install all the required versions of the JDK that are required as part of the Maven build.
The build script performs the following steps:
1. Sets up staging directories under **target/** for the package files
2. Uses git commands to gather information about the current Git commit and branch
3. Compiles java source tree
-4. Packages a JAR containing compiled sources together with the Manifest, Licence and Notice files
+4. Packages a JAR containing compiled sources together with the Manifest, License and Notice files
5. Checks and tests the assembled JAR by using the API to access four different resource types
The build script is located in the **tools/scripts/** directory and requires the following arguments:
To run the script for a release version:
- ./tools/scripts/compile-package-jar.sh $JAVA_HOME 2.1.0 /src/datasketches-memory
+ ./tools/scripts/package-single-release-jar.sh $JAVA_HOME 2.1.0 /src/datasketches-memory
To run the script for a snapshot version:
- ./tools/scripts/compile-package-jar.sh $JAVA_HOME 2.2.0-SNAPSHOT /src/datasketches-memory
+ ./tools/scripts/package-single-release-jar.sh $JAVA_HOME 2.2.0-SNAPSHOT /src/datasketches-memory
To run the script for an RC version:
- ./tools/scripts/compile-package-jar.sh $JAVA_HOME 2.1.0-RC1 /src/datasketches-memory
+ ./tools/scripts/package-single-release-jar.sh $JAVA_HOME 2.1.0-RC1 /src/datasketches-memory
Note that the script does **not** use the _Git Version Tag_ to adjust the working copy to a remote tag - it is expected that the user has a pristine copy of the desired branch/tag available **before** using the script.
- [Eclipse IDE Setup](docs/eclipse.md)
- [IntelliJ IDE Setup](docs/intellij.md)
+
+For releasing to AppNexus, please use the `sign-deploy-jar.sh` script in the scripts directory.
+See the documentation within the script for usage instructions.
<parent>
<groupId>org.apache.datasketches</groupId>
<artifactId>datasketches-memory-root</artifactId>
- <version>2.2.0-SNAPSHOT</version>
+ <version>2.3.0-SNAPSHOT</version>
</parent>
<artifactId>datasketches-memory-java11</artifactId>
</pluginManagement>
</build>
+ <profiles>
+ <profile>
+ <id>assemble-mr-jar</id>
+ <activation>
+ <property>
+ <name>!unsetDefaultProfile</name>
+ </property>
+ </activation>
+ <properties>
+ <assembly.script.path>${maven.multiModuleProjectDirectory}/tools/scripts/package-multi-release-jar.sh</assembly.script.path>
+ <assembly.java.home>${env.JAVA_HOME}</assembly.java.home>
+ <assembly.git.tag>${project.version}</assembly.git.tag>
+ <assembly.base.dir>${maven.multiModuleProjectDirectory}</assembly.base.dir>
+ </properties>
+ <build>
+ <defaultGoal>exec:exec</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <!-- The trailing comment on the line below ignores an eclipse warning. The version is required for dependency updates. -->
+ <version>${maven-exec-plugin.version}</version><!--$NO-MVN-MAN-VER$-->
+ <executions>
+ <execution>
+ <id>package-mr-jar</id>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <executable>bash</executable>
+ <commandlineArgs>${assembly.script.path} ${assembly.java.home} ${assembly.git.tag} ${assembly.base.dir}</commandlineArgs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
* under the License.
*/
-package org.apache.datasketches.memory.internal;
\ No newline at end of file
+package org.apache.datasketches.memory.internal;
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
- http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory-root</artifactId>
- <version>2.2.0-SNAPSHOT</version>
- </parent>
-
- <dependencies>
- <!-- Test Scope -->
- <dependency>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory-java8</artifactId>
- <version>${project.parent.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <!-- Used for UTF8 testing -->
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <!-- Used for xxHash testing -->
- <groupId>net.openhft</groupId>
- <artifactId>zero-allocation-hashing</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <artifactId>datasketches-memory-java8-tests</artifactId>
- <name>${project.artifactId}</name>
- <packaging>jar</packaging>
-
- <properties>
- <java.version>1.8</java.version>
- <jdk-toolchain.version>8</jdk-toolchain.version>
- <maven.compiler.source>${java.version}</maven.compiler.source>
- <maven.compiler.target>${java.version}</maven.compiler.target>
- </properties>
-
-</project>
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.datasketches.memory.test;
-
-import java.io.File;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.ByteOrder;
-
-import org.apache.datasketches.memory.MemoryRequestServer;
-
-public final class ReflectUtil {
-
- private ReflectUtil() {}
-
- static final Class<?> BASE_STATE;
- static final Class<?> BASE_WRITABLE_MEMORY_IMPL;
- static final Class<?> ALLOCATE_DIRECT_MAP;
- static final Class<?> NIO_BITS;
-
- static final Method CHECK_VALID; //BaseStateImpl
- static final Method GET_DIRECT_ALLOCATIONS_COUNT; //NioBits
- static final Method GET_MAX_DIRECT_BYTE_BUFFER_MEMORY; //NioBits
- static final Method GET_NATIVE_BASE_OFFSET; //BaseStateImpl
- static final Method GET_RESERVED_MEMORY; //NioBits
- static final Method GET_TOTAL_CAPACITY; //NioBits
- static final Method GET_UNSAFE_OBJECT; //BaseStateImpl
- static final Method IS_BB_TYPE; //BaseStateImpl
- static final Method IS_BUFFER_TYPE; //BaseStateImpl
- static final Method IS_DIRECT_TYPE; //BaseStateImpl
- static final Method IS_DUPLICATE_TYPE; //BaseStateImpl
- static final Method IS_FILE_READ_ONLY; //AllocateDirectMap
- static final Method IS_HEAP_TYPE; //BaseStateImpl
- static final Method IS_MAP_TYPE; //BaseStateImpl
- static final Method IS_NON_NATIVE_TYPE; //BaseStateImpl
- static final Method IS_PAGE_ALIGHED; //NioBits
- static final Method IS_READ_ONLY_TYPE; //BaseStateImpl
- static final Method IS_REGION_TYPE; //BaseStateImpl
- static final Method PAGE_COUNT; //NioBits
- static final Method PAGE_SIZE; //NioBits
- static final Method RESERVE_MEMORY; //NioBits
- static final Method UNRESERVE_MEMORY; //NioBits
- static final Method WRAP_DIRECT; //BaseWritableMemoryImpl
-
- static {
- BASE_STATE =
- getClass("org.apache.datasketches.memory.internal.BaseStateImpl");
- BASE_WRITABLE_MEMORY_IMPL =
- getClass("org.apache.datasketches.memory.internal.BaseWritableMemoryImpl");
- ALLOCATE_DIRECT_MAP =
- getClass("org.apache.datasketches.memory.internal.AllocateDirectMap");
- NIO_BITS =
- getClass("org.apache.datasketches.memory.internal.NioBits");
-
- CHECK_VALID =
- getMethod(BASE_STATE, "checkValid", (Class<?>[])null); //not static
- GET_DIRECT_ALLOCATIONS_COUNT =
- getMethod(NIO_BITS, "getDirectAllocationsCount", (Class<?>[])null); //static
- GET_MAX_DIRECT_BYTE_BUFFER_MEMORY =
- getMethod(NIO_BITS, "getMaxDirectByteBufferMemory", (Class<?>[])null); //static
- GET_NATIVE_BASE_OFFSET =
- getMethod(BASE_STATE, "getNativeBaseOffset", (Class<?>[])null);
- GET_RESERVED_MEMORY =
- getMethod(NIO_BITS, "getReservedMemory", (Class<?>[])null); //static
- GET_TOTAL_CAPACITY =
- getMethod(NIO_BITS, "getTotalCapacity", (Class<?>[])null); //static
- GET_UNSAFE_OBJECT =
- getMethod(BASE_STATE, "getUnsafeObject", (Class<?>[])null); //not static
- IS_BB_TYPE =
- getMethod(BASE_STATE, "isBBType", (Class<?>[])null); //not static
- IS_BUFFER_TYPE =
- getMethod(BASE_STATE, "isBufferType", (Class<?>[])null); //not static
- IS_DIRECT_TYPE =
- getMethod(BASE_STATE, "isDirectType", (Class<?>[])null); //not static
- IS_DUPLICATE_TYPE =
- getMethod(BASE_STATE, "isDuplicateType", (Class<?>[])null); //not static
- IS_FILE_READ_ONLY =
- getMethod(ALLOCATE_DIRECT_MAP, "isFileReadOnly", File.class);
- IS_HEAP_TYPE =
- getMethod(BASE_STATE, "isHeapType", (Class<?>[])null); //not static
- IS_MAP_TYPE =
- getMethod(BASE_STATE, "isMapType", (Class<?>[])null); //not static
- IS_NON_NATIVE_TYPE =
- getMethod(BASE_STATE, "isNonNativeType", (Class<?>[])null); //not static
- IS_PAGE_ALIGHED =
- getMethod(NIO_BITS, "isPageAligned", (Class<?>[])null); //static
- IS_READ_ONLY_TYPE =
- getMethod(BASE_STATE, "isReadOnlyType", (Class<?>[])null); //not static
- IS_REGION_TYPE =
- getMethod(BASE_STATE, "isRegionType", (Class<?>[])null); //not static
- PAGE_COUNT =
- getMethod(NIO_BITS, "pageCount", long.class); //static
- PAGE_SIZE =
- getMethod(NIO_BITS, "pageSize", (Class<?>[])null); //static
- RESERVE_MEMORY =
- getMethod(NIO_BITS, "reserveMemory", long.class, long.class); //static
- UNRESERVE_MEMORY =
- getMethod(NIO_BITS, "unreserveMemory", long.class, long.class); //static
- WRAP_DIRECT =
- getMethod(BASE_WRITABLE_MEMORY_IMPL,
- "wrapDirect", long.class, ByteOrder.class, MemoryRequestServer.class); //static method
- }
-
- /**
- * Gets a Class reference to the given class loaded by the SystemClassLoader.
- * This will work for private, package-private and abstract classes.
- * @param fullyQualifiedBinaryName the binary name is the name of the class file on disk. This does not instantiate
- * a concrete class, but allows access to constructors, static fields and static methods.
- * @return the Class object of the given class.
- */
- public static Class<?> getClass(final String fullyQualifiedBinaryName) {
- try {
- final ClassLoader scl = ClassLoader.getSystemClassLoader();
- return scl.loadClass(fullyQualifiedBinaryName);
- } catch (final ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Gets a declared constructor given the owner class and parameter types
- * @param ownerClass the Class<?> object of the class loaded by the SystemClassLoader.
- * @param parameterTypes parameter types for the constructor
- * @return the constructor
- */
- public static Constructor<?> getConstructor(final Class<?> ownerClass, final Class<?>... parameterTypes ) {
- try {
- final Constructor<?> ctor = ownerClass.getDeclaredConstructor(parameterTypes);
- ctor.setAccessible(true);
- return ctor;
- } catch (final NoSuchMethodException | SecurityException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Gets a class instance from its constructor and initializing arguments.
- * @param constructor the given Constructor
- * @param initargs the initializing arguments
- * @return the instantiated class.
- */
- public static Object getInstance(final Constructor<?> constructor, final Object... initargs) {
- try {
- constructor.setAccessible(true);
- return constructor.newInstance(initargs);
- } catch (final InstantiationException | IllegalAccessException | IllegalArgumentException
- | InvocationTargetException | SecurityException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Gets a declared field of the given the loaded owner class and field name. The accessible flag will be set true.
- * @param ownerClass the Class<?> object of the class loaded by the SystemClassLoader.
- * @param fieldName the desired field name
- * @return the desired field.
- */
- public static Field getField(final Class<?> ownerClass, final String fieldName) {
- try {
- final Field field = ownerClass.getDeclaredField(fieldName);
- field.setAccessible(true);
- return field;
- } catch (final NoSuchFieldException | SecurityException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Gets a field value given the loaded owner class and the Field. The accessible flag will be set true.
- * @param ownerClass the loaded class owning the field
- * @param field The Field object
- * @return the returned value as an object.
- */
- public static Object getFieldValue(final Class<?> ownerClass, final Field field) {
- try {
- field.setAccessible(true);
- return field.get(ownerClass);
- } catch (final IllegalAccessException | SecurityException | IllegalArgumentException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Gets a declared method of the given the loaded owning class, method name and parameter types.
- * The accessible flag will be set true.
- * @param ownerClass the given owner class
- * @param methodName the given method name
- * @param parameterTypes the list of parameter types
- * @return the desired method.
- */
- public static Method getMethod(
- final Class<?> ownerClass, final String methodName, final Class<?>... parameterTypes ) {
- try {
- final Method method = (parameterTypes == null)
- ? ownerClass.getDeclaredMethod(methodName)
- : ownerClass.getDeclaredMethod(methodName, parameterTypes);
- method.setAccessible(true);
- return method;
- } catch (final NoSuchMethodException | SecurityException e) {
- throw new RuntimeException(e);
- }
- }
-
- static void checkValid(final Object target) {
- try {
- CHECK_VALID.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static long getDirectAllocationsCount() {
- try {
- return (long) GET_DIRECT_ALLOCATIONS_COUNT.invoke(null);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static long getMaxDirectByteBufferMemory() {
- try {
- return (long) GET_MAX_DIRECT_BYTE_BUFFER_MEMORY.invoke(null);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static long getNativeBaseOffset(final Object target) {
- try {
- return (long) GET_NATIVE_BASE_OFFSET.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static long getReservedMemory() {
- try {
- return (long) GET_RESERVED_MEMORY.invoke(null);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static long getTotalCapacity() {
- try {
- return (long) GET_TOTAL_CAPACITY.invoke(null);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static Object getUnsafeObject(final Object target) {
- try {
- return GET_UNSAFE_OBJECT.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isBBType(final Object target) {
- try {
- return (boolean) IS_BB_TYPE.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isBufferType(final Object target) {
- try {
- return (boolean) IS_BUFFER_TYPE.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isDirectType(final Object target) {
- try {
- return (boolean) IS_DIRECT_TYPE.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isDuplicateType(final Object target) {
- try {
- return (boolean) IS_DUPLICATE_TYPE.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isFileReadOnly(final File file) {
- try {
- return (boolean) IS_FILE_READ_ONLY.invoke(null, file);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isHeapType(final Object target) {
- try {
- return (boolean) IS_HEAP_TYPE.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isMapType(final Object target) {
- try {
- return (boolean) IS_MAP_TYPE.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isNonNativeType(final Object target) {
- try {
- return (boolean) IS_NON_NATIVE_TYPE.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isPageAligned() {
- try {
- return (boolean) IS_PAGE_ALIGHED.invoke(null);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isReadOnlyType(final Object target) {
- try {
- return (boolean) IS_READ_ONLY_TYPE.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static boolean isRegionType(final Object target) {
- try {
- return (boolean) IS_REGION_TYPE.invoke(target);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static int pageCount(final long bytes) {
- try {
- return (int) PAGE_COUNT.invoke(null, bytes);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static int pageSize() {
- try {
- return (int) PAGE_SIZE.invoke(null);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static void reserveMemory(final long allocationSize, final long capacity) {
- try {
- RESERVE_MEMORY.invoke(null, allocationSize, capacity);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- static void unreserveMemory(final long allocationSize, final long capacity) {
- try {
- UNRESERVE_MEMORY.invoke(null, allocationSize, capacity);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.datasketches.memory.test;
<parent>
<groupId>org.apache.datasketches</groupId>
<artifactId>datasketches-memory-root</artifactId>
- <version>2.2.0-SNAPSHOT</version>
+ <version>2.3.0-SNAPSHOT</version>
</parent>
<artifactId>datasketches-memory-java8</artifactId>
<maven.javadoc.skip>false</maven.javadoc.skip>
</properties>
- <profiles>
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <!-- Used for UTF8 testing -->
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <!-- Used for xxHash testing -->
+ <groupId>net.openhft</groupId>
+ <artifactId>zero-allocation-hashing</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <profile>
- <id>strict</id>
- <!-- The error prone compiler is only currently supported for compilation in JDK 8 -->
- <activation>
- <jdk>[1.8, 1.9),8</jdk>
- </activation>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>${maven-compiler-plugin.version}</version>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-javac-errorprone</artifactId>
- <version>${plexus-compiler-javac-errorprone.version}</version>
- </dependency>
- </dependencies>
- <configuration>
- <source>${maven.compiler.source}</source>
- <target>${maven.compiler.target}</target>
- <compilerId>javac-with-errorprone</compilerId>
- <forceJavacCompilerUse>true</forceJavacCompilerUse>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- </profile>
-
- </profiles>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${jacoco-maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <id>report</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
</project>
* Note: Lincoln's Gettysburg Address is in the public domain. See LICENSE.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.apache.datasketches.memory.internal.Util.*;
import static org.testng.Assert.assertEquals;
@Test
public void simpleMap() throws Exception {
File file = getResourceFile("GettysburgAddress.txt");
- assertTrue(ReflectUtil.isFileReadOnly(file));
+ assertTrue(AllocateDirectMap.isFileReadOnly(file));
try (MapHandle rh = Memory.map(file)) {
rh.close();
}
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import org.apache.datasketches.memory.MemoryRequestServer;
import org.apache.datasketches.memory.WritableHandle;
import org.apache.datasketches.memory.WritableMemory;
-import org.apache.datasketches.memory.internal.Util;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
assertEquals(wMem.getLong(i << 3), i);
}
//inside the TWR block the memory should be valid
- ReflectUtil.checkValid(wMem);
+ ((BaseStateImpl)wMem).checkValid();
//OK
}
//The TWR block has exited, so the memory should be invalid
try {
- ReflectUtil.checkValid(wMem);
+ ((BaseStateImpl)wMem).checkValid();
fail();
} catch (final RuntimeException e) {
//OK
* Note: Lincoln's Gettysburg Address is in the public domain. See LICENSE.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.datasketches.memory.internal.Util.getResourceFile;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.nio.ByteOrder;
import org.apache.datasketches.memory.BaseState;
import org.apache.datasketches.memory.WritableHandle;
import org.apache.datasketches.memory.WritableMapHandle;
import org.apache.datasketches.memory.WritableMemory;
-import org.apache.datasketches.memory.internal.Util;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AllocateDirectWritableMapMemoryTest {
private static final String LS = System.getProperty("line.separator");
- static final Method IS_FILE_READ_ONLY;
-
- static {
- IS_FILE_READ_ONLY =
- ReflectUtil.getMethod(ReflectUtil.ALLOCATE_DIRECT_MAP, "isFileReadOnly", File.class);
- }
-
- private static boolean isFileReadOnly(final File file) {
- try {
- return (boolean) IS_FILE_READ_ONLY.invoke(null, file);
- } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
@BeforeClass
public void setReadOnly() {
UtilTest.setGettysburgAddressFileToReadOnly();
@Test(expectedExceptions = ReadOnlyException.class)
public void simpleMap2() throws Exception {
File file = getResourceFile("GettysburgAddress.txt");
- assertTrue(isFileReadOnly(file));
+ assertTrue(file.canRead() && !file.canWrite());
try (WritableMapHandle rh =
WritableMemory.writableMap(file)) { //throws
//
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.fail;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.apache.datasketches.memory.internal.UnsafeUtil.ARRAY_DOUBLE_INDEX_SCALE;
import static org.testng.Assert.assertEquals;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableMemory;
-import org.apache.datasketches.memory.internal.BaseStateImpl;
-import org.apache.datasketches.memory.internal.Prim;
-import org.apache.datasketches.memory.internal.StepBoolean;
-import org.apache.datasketches.memory.internal.Util;
import org.testng.annotations.Test;
public class BaseStateTest {
@Test
public void checkGetNativeBaseOffset_Heap() throws Exception {
WritableMemory wmem = WritableMemory.allocate(8); //heap
- final long offset = ReflectUtil.getNativeBaseOffset(wmem);
+ final long offset = ((BaseStateImpl)wmem).getNativeBaseOffset();
assertEquals(offset, 0L);
}
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import org.apache.datasketches.memory.WritableMemory;
import org.testng.annotations.Test;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import java.nio.ByteBuffer;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.apache.datasketches.memory.internal.Util.isAllBitsClear;
import static org.apache.datasketches.memory.internal.Util.isAllBitsSet;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.apache.datasketches.memory.internal.Util.UNSAFE_COPY_THRESHOLD_BYTES;
import static org.testng.Assert.assertEquals;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertFalse;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import org.apache.datasketches.memory.WritableHandle;
import org.apache.datasketches.memory.WritableMemory;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
/**
* Stripped down version of
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.apache.datasketches.memory.internal.Util.NON_NATIVE_BYTE_ORDER;
import static org.apache.datasketches.memory.internal.Util.otherByteOrder;
try (WritableHandle wdh = WritableMemory.allocateDirect(cap, NBO, dummyMemReqSvr)) {
WritableMemory memNO = wdh.getWritable();
memNO.putShort(0, (short) 1);
- assertNull(ReflectUtil.getUnsafeObject(memNO));
+ assertNull(((BaseStateImpl)memNO).getUnsafeObject());
assertTrue(memNO.isDirect());
checkCombinations(memNO, off, cap, memNO.isDirect(), NBO, false, true);
}
try (WritableHandle wdh = WritableMemory.allocateDirect(cap, NNBO, dummyMemReqSvr)) {
WritableMemory memNNO = wdh.getWritable();
memNNO.putShort(0, (short) 1);
- assertNull(ReflectUtil.getUnsafeObject(memNNO));
+ assertNull(((BaseStateImpl)memNNO).getUnsafeObject());
assertTrue(memNNO.isDirect());
checkCombinations(memNNO, off, cap, memNNO.isDirect(), NNBO, false, true);
}
bb.putShort(0, (short) 1);
WritableMemory mem = WritableMemory.writableWrap(bb, NBO, dummyMemReqSvr);
assertEquals(bb.isDirect(), mem.isDirect());
- assertNotNull(ReflectUtil.getUnsafeObject(mem));
+ assertNotNull(((BaseStateImpl)mem).getUnsafeObject());
checkCombinations(mem, off, cap, mem.isDirect(), mem.getTypeByteOrder(), true, true);
//BB off heap, native order, has ByteBuffer, has MemReqSvr
dbb.putShort(0, (short) 1);
mem = WritableMemory.writableWrap(dbb, NBO, dummyMemReqSvr);
assertEquals(dbb.isDirect(), mem.isDirect());
- assertNull(ReflectUtil.getUnsafeObject(mem));
+ assertNull(((BaseStateImpl)mem).getUnsafeObject());
checkCombinations(mem, off, cap, mem.isDirect(), mem.getTypeByteOrder(), true, true);
//BB on heap, non native order, has ByteBuffer, has MemReqSvr
bb.putShort(0, (short) 1);
mem = WritableMemory.writableWrap(bb, NNBO, dummyMemReqSvr);
assertEquals(bb.isDirect(), mem.isDirect());
- assertNotNull(ReflectUtil.getUnsafeObject(mem));
+ assertNotNull(((BaseStateImpl)mem).getUnsafeObject());
checkCombinations(mem, off, cap, mem.isDirect(), mem.getTypeByteOrder(), true, true);
//BB off heap, non native order, has ByteBuffer, has MemReqSvr
dbb.putShort(0, (short) 1);
mem = WritableMemory.writableWrap(dbb, NNBO, dummyMemReqSvr);
assertEquals(dbb.isDirect(), mem.isDirect());
- assertNull(ReflectUtil.getUnsafeObject(mem));
+ assertNull(((BaseStateImpl)mem).getUnsafeObject());
checkCombinations(mem, off, cap, mem.isDirect(), mem.getTypeByteOrder(), true, true);
}
try (WritableMapHandle wmh = WritableMemory.writableMap(file, off, cap, NBO)) {
WritableMemory memNO = wmh.getWritable();
memNO.putShort(0, (short) 1);
- assertNull(ReflectUtil.getUnsafeObject(memNO));
+ assertNull(((BaseStateImpl)memNO).getUnsafeObject());
assertTrue(memNO.isDirect());
checkCombinations(memNO, off, cap, memNO.isDirect(), NBO, false, false);
}
try (WritableMapHandle wmh = WritableMemory.writableMap(file, off, cap, NNBO)) {
WritableMemory memNNO = wmh.getWritable();
memNNO.putShort(0, (short) 1);
- assertNull(ReflectUtil.getUnsafeObject(memNNO));
+ assertNull(((BaseStateImpl)memNNO).getUnsafeObject());
assertTrue(memNNO.isDirect());
checkCombinations(memNNO, off, cap, memNNO.isDirect(), NNBO, false, false);
}
// On Heap, Native order, No ByteBuffer, No MemReqSvr
WritableMemory memNO = WritableMemory.allocate((int)cap); //assumes NBO
memNO.putShort(0, (short) 1);
- assertNotNull(ReflectUtil.getUnsafeObject(memNO));
+ assertNotNull(((BaseStateImpl)memNO).getUnsafeObject());
assertFalse(memNO.isDirect());
checkCombinations(memNO, off, cap, memNO.isDirect(), NBO, false, false);
// On Heap, Non-native order, No ByteBuffer, No MemReqSvr
WritableMemory memNNO = WritableMemory.allocate((int)cap, NNBO);
memNNO.putShort(0, (short) 1);
- assertNotNull(ReflectUtil.getUnsafeObject(memNNO));
+ assertNotNull(((BaseStateImpl)memNNO).getUnsafeObject());
assertFalse(memNNO.isDirect());
checkCombinations(memNNO, off, cap, memNNO.isDirect(), NNBO, false, false);
}
if (hasMemReqSvr) { assertTrue(mem.getMemoryRequestServer() instanceof DummyMemoryRequestServer); }
- Object obj = ReflectUtil.getUnsafeObject(mem);
+ Object obj = ((BaseStateImpl)mem).getUnsafeObject();
if (direct) {
assertTrue(mem.isDirect());
assertNull(obj);
if (hasMemReqSvr) { assertTrue(buf.getMemoryRequestServer() instanceof DummyMemoryRequestServer); }
- obj = ReflectUtil.getUnsafeObject(buf);
+ obj = ((BaseStateImpl)buf).getUnsafeObject();
if (direct) {
assertTrue(buf.isDirect());
assertNull(obj);
if (hasMemReqSvr) { assertTrue(nnMem.getMemoryRequestServer() instanceof DummyMemoryRequestServer); }
- obj = ReflectUtil.getUnsafeObject(nnMem);
+ obj = ((BaseStateImpl)nnMem).getUnsafeObject();
if (direct) {
assertTrue(nnMem.isDirect());
assertNull(obj);
if (hasMemReqSvr) { assertTrue(nnBuf.getMemoryRequestServer() instanceof DummyMemoryRequestServer); }
- obj = ReflectUtil.getUnsafeObject(nnBuf);
+ obj = ((BaseStateImpl)nnBuf).getUnsafeObject();
if (direct) {
assertTrue(nnBuf.isDirect());
assertNull(obj);
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableMemory;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.datasketches.memory.internal.MemoryCleaner;
import org.testng.annotations.Test;
public class MemoryCleanerTest {
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import org.apache.datasketches.memory.MemoryCloseException;
import org.testng.annotations.Test;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import java.io.File;
import java.io.RandomAccessFile;
* Note: Lincoln's Gettysburg Address is in the public domain. See LICENSE.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.apache.datasketches.memory.internal.Util.getResourceFile;
import static org.testng.Assert.assertEquals;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableHandle;
import org.apache.datasketches.memory.WritableMemory;
-import org.apache.datasketches.memory.internal.Util;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.apache.datasketches.memory.internal.Util.UNSAFE_COPY_THRESHOLD_BYTES;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.datasketches.memory.MurmurHash3v2.hash;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableHandle;
import org.apache.datasketches.memory.WritableMemory;
-import org.apache.datasketches.memory.internal.UnsafeUtil;
-import org.apache.datasketches.memory.internal.Util;
import org.testng.Assert;
import org.testng.annotations.Test;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import org.apache.datasketches.memory.Buffer;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.memory.ReadOnlyException;
-import org.apache.datasketches.memory.internal.UnsafeUtil;
-import org.apache.datasketches.memory.internal.Util;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableMemory;
import org.testng.annotations.Test;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
@Test
public void checkVMParams() {
- println("Max MemoryImpl: " + ReflectUtil.getMaxDirectByteBufferMemory());
- println("Page Aligned: " + ReflectUtil.isPageAligned());
- println("Page Size: " + ReflectUtil.pageSize());
+ println("Max MemoryImpl: " + NioBits.getMaxDirectByteBufferMemory());
+ println("Page Aligned: " + NioBits.isPageAligned());
+ println("Page Size: " + NioBits.pageSize());
}
@Test
// long cap = 1024L + Integer.MAX_VALUE;
long cap = 1L << 10;
printStats();
- ReflectUtil.reserveMemory(cap, cap);
+ NioBits.reserveMemory(cap, cap);
printStats();
- ReflectUtil. unreserveMemory(cap, cap);
+ NioBits. unreserveMemory(cap, cap);
printStats();
}
@Test
public void checkPageCount() {
- assertEquals(ReflectUtil.pageCount(0), 0);
- assertEquals(ReflectUtil.pageCount(1), 1);
+ assertEquals(NioBits.pageCount(0), 0);
+ assertEquals(NioBits.pageCount(1), 1);
}
private static void printStats() {
- long count = ReflectUtil.getDirectAllocationsCount();
- long resMem = ReflectUtil.getReservedMemory();
- long totCap = ReflectUtil.getTotalCapacity();
- long maxDBBmem = ReflectUtil.getMaxDirectByteBufferMemory();
+ long count = NioBits.getDirectAllocationsCount();
+ long resMem = NioBits.getReservedMemory();
+ long totCap = NioBits.getTotalCapacity();
+ long maxDBBmem = NioBits.getMaxDirectByteBufferMemory();
String s = String.format("%,10d\t%,15d\t%,15d\t%,15d", count, resMem, totCap, maxDBBmem);
println(s);
}
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.apache.datasketches.memory.WritableHandle;
import org.apache.datasketches.memory.WritableMapHandle;
import org.apache.datasketches.memory.WritableMemory;
-import org.apache.datasketches.memory.internal.Util;
import org.testng.annotations.Test;
/**
bb.order(ByteOrder.nativeOrder());
Memory mem = Memory.wrap(bb).region(0, bytes, ByteOrder.nativeOrder());
- assertTrue(ReflectUtil.isBBType(mem));
+ assertTrue(((BaseStateImpl)mem).isBBType());
assertTrue(mem.isReadOnly());
checkCrossLeafTypeIds(mem);
Buffer buf = mem.asBuffer().region(0, bytes, ByteOrder.nativeOrder());
Buffer buf2 = mem2.asBuffer().region(0, bytes, Util.NON_NATIVE_BYTE_ORDER);
Buffer buf3 = buf2.duplicate();
- assertTrue(ReflectUtil.isRegionType(mem));
- assertTrue(ReflectUtil.isRegionType(mem2));
- assertTrue(ReflectUtil.isRegionType(buf));
- assertTrue(ReflectUtil.isRegionType(buf2));
- assertTrue(ReflectUtil.isDuplicateType(buf3));
+ assertTrue(((BaseStateImpl)mem).isRegionType());
+ assertTrue(((BaseStateImpl)mem2).isRegionType());
+ assertTrue(((BaseStateImpl)buf).isRegionType());
+ assertTrue(((BaseStateImpl)buf2).isRegionType());
+ assertTrue(((BaseStateImpl)buf3).isDuplicateType());
}
@Test
int bytes = 128;
try (WritableHandle h = WritableMemory.allocateDirect(bytes)) {
WritableMemory wmem = h.getWritable(); //native mem
- assertTrue(ReflectUtil.isDirectType(wmem));
+ assertTrue(((BaseStateImpl)wmem).isDirectType());
assertFalse(wmem.isReadOnly());
checkCrossLeafTypeIds(wmem);
WritableMemory nnwmem = wmem.writableRegion(0, bytes, Util.NON_NATIVE_BYTE_ORDER);
Buffer buf2 = mem2.asBuffer().region(0, bytes, Util.NON_NATIVE_BYTE_ORDER);
Buffer buf3 = buf2.duplicate();
- assertTrue(ReflectUtil.isRegionType(mem));
- assertTrue(ReflectUtil.isRegionType(mem2));
- assertTrue(ReflectUtil.isRegionType(buf));
- assertTrue(ReflectUtil.isRegionType(buf2));
- assertTrue(ReflectUtil.isDuplicateType(buf3));
+ assertTrue(((BaseStateImpl)mem).isRegionType());
+ assertTrue(((BaseStateImpl)mem2).isRegionType());
+ assertTrue(((BaseStateImpl)buf).isRegionType());
+ assertTrue(((BaseStateImpl)buf2).isRegionType());
+ assertTrue(((BaseStateImpl)buf3).isDuplicateType());
}
}
try (WritableMapHandle h = WritableMemory.writableMap(file, 0L, bytes, ByteOrder.nativeOrder())) {
WritableMemory mem = h.getWritable(); //native mem
- assertTrue(ReflectUtil.isMapType(mem));
+ assertTrue(((BaseStateImpl)mem).isMapType());
assertFalse(mem.isReadOnly());
checkCrossLeafTypeIds(mem);
Memory nnreg = mem.region(0, bytes, Util.NON_NATIVE_BYTE_ORDER);
Buffer buf2 = reg2.asBuffer().region(0, bytes, Util.NON_NATIVE_BYTE_ORDER);
Buffer buf3 = buf2.duplicate();
- assertTrue(ReflectUtil.isRegionType(reg));
- assertTrue(ReflectUtil.isRegionType(reg2));
- assertTrue(ReflectUtil.isRegionType(buf));
- assertTrue(ReflectUtil.isRegionType(buf2));
- assertTrue(ReflectUtil.isDuplicateType(buf3));
- assertTrue(ReflectUtil.isDuplicateType(buf4));
+ assertTrue(((BaseStateImpl)reg).isRegionType());
+ assertTrue(((BaseStateImpl)reg2).isRegionType());
+ assertTrue(((BaseStateImpl)buf).isRegionType());
+ assertTrue(((BaseStateImpl)buf2).isRegionType());
+ assertTrue(((BaseStateImpl)buf3).isDuplicateType());
+ assertTrue(((BaseStateImpl)buf4).isDuplicateType());
}
}
public void checkHeapLeafs() {
int bytes = 128;
Memory mem = Memory.wrap(new byte[bytes]);
- assertTrue(ReflectUtil.isHeapType(mem));
- assertTrue(ReflectUtil.isReadOnlyType(mem));
+ assertTrue(((BaseStateImpl)mem).isHeapType());
+ assertTrue(((BaseStateImpl)mem).isReadOnlyType());
checkCrossLeafTypeIds(mem);
Memory nnreg = mem.region(0, bytes, Util.NON_NATIVE_BYTE_ORDER);
Buffer buf2 = reg2.asBuffer().region(0, bytes, Util.NON_NATIVE_BYTE_ORDER);
Buffer buf3 = buf2.duplicate();
- assertFalse(ReflectUtil.isRegionType(mem));
- assertTrue(ReflectUtil.isRegionType(reg2));
- assertTrue(ReflectUtil.isRegionType(buf));
- assertTrue(ReflectUtil.isRegionType(buf2));
- assertTrue(ReflectUtil.isDuplicateType(buf3));
- assertTrue(ReflectUtil.isDuplicateType(buf4));
+ assertFalse(((BaseStateImpl)mem).isRegionType());
+ assertTrue(((BaseStateImpl)reg2).isRegionType());
+ assertTrue(((BaseStateImpl)buf).isRegionType());
+ assertTrue(((BaseStateImpl)buf2).isRegionType());
+ assertTrue(((BaseStateImpl)buf3).isDuplicateType());
+ assertTrue(((BaseStateImpl)buf4).isDuplicateType());
}
private static void checkCrossLeafTypeIds(Memory mem) {
Memory reg1 = mem.region(0, mem.getCapacity());
- assertTrue(ReflectUtil.isRegionType(reg1));
+ assertTrue(((BaseStateImpl)reg1).isRegionType());
Buffer buf1 = reg1.asBuffer();
- assertTrue(ReflectUtil.isRegionType(buf1));
- assertTrue(ReflectUtil.isBufferType(buf1));
+ assertTrue(((BaseStateImpl)buf1).isRegionType());
+ assertTrue(((BaseStateImpl)buf1).isBufferType());
assertTrue(buf1.isReadOnly());
Buffer buf2 = buf1.duplicate();
- assertTrue(ReflectUtil.isRegionType(buf2));
- assertTrue(ReflectUtil.isBufferType(buf2));
- assertTrue(ReflectUtil.isDuplicateType(buf2));
+ assertTrue(((BaseStateImpl)buf2).isRegionType());
+ assertTrue(((BaseStateImpl)buf2).isBufferType());
+ assertTrue(((BaseStateImpl)buf2).isDuplicateType());
assertTrue(buf2.isReadOnly());
Memory mem2 = buf1.asMemory(); //
- assertTrue(ReflectUtil.isRegionType(mem2));
- assertFalse(ReflectUtil.isBufferType(mem2));
- assertFalse(ReflectUtil.isDuplicateType(mem2));
+ assertTrue(((BaseStateImpl)mem2).isRegionType());
+ assertFalse(((BaseStateImpl)mem2).isBufferType());
+ assertFalse(((BaseStateImpl)mem2).isDuplicateType());
assertTrue(mem2.isReadOnly());
Buffer buf3 = buf1.duplicate(Util.NON_NATIVE_BYTE_ORDER);
- assertTrue(ReflectUtil.isRegionType(buf3));
- assertTrue(ReflectUtil.isBufferType(buf3));
- assertTrue(ReflectUtil.isDuplicateType(buf3));
- assertTrue(ReflectUtil.isNonNativeType(buf3));
+ assertTrue(((BaseStateImpl)buf3).isRegionType());
+ assertTrue(((BaseStateImpl)buf3).isBufferType());
+ assertTrue(((BaseStateImpl)buf3).isDuplicateType());
+ assertTrue(((BaseStateImpl)buf3).isNonNativeType());
assertTrue(buf3.isReadOnly());
Memory mem3 = buf3.asMemory();
- assertTrue(ReflectUtil.isRegionType(mem3));
- assertFalse(ReflectUtil.isBufferType(mem3));
- assertTrue(ReflectUtil.isDuplicateType(mem3));
- assertTrue(ReflectUtil.isNonNativeType(mem3));
+ assertTrue(((BaseStateImpl)mem3).isRegionType());
+ assertFalse(((BaseStateImpl)mem3).isBufferType());
+ assertTrue(((BaseStateImpl)mem3).isDuplicateType());
+ assertTrue(((BaseStateImpl)mem3).isNonNativeType());
assertTrue(mem3.isReadOnly());
}
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
-import org.apache.datasketches.memory.internal.Ints;
-import org.apache.datasketches.memory.internal.UnsafeUtil;
import org.testng.annotations.Test;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
* Note: Lincoln's Gettysburg Address is in the public domain. See LICENSE.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.apache.datasketches.memory.internal.Util.characterPad;
import static org.apache.datasketches.memory.internal.Util.getResourceBytes;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermissions;
-import org.apache.datasketches.memory.internal.UnsafeUtil;
-import org.apache.datasketches.memory.internal.Util;
import org.apache.datasketches.memory.WritableMemory;
import org.testng.annotations.Test;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import org.apache.datasketches.memory.internal.VirtualMachineMemory;
import org.testng.annotations.Test;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.memory.WritableBuffer;
import org.apache.datasketches.memory.WritableMemory;
-import org.apache.datasketches.memory.internal.Util;
import org.testng.annotations.Test;
public class WritableMemoryTest {
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.apache.datasketches.memory.XxHash.*;
import static org.testng.Assert.assertEquals;
* under the License.
*/
-package org.apache.datasketches.memory.test;
+package org.apache.datasketches.memory.internal;
import static org.testng.Assert.assertEquals;
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
- http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory-root</artifactId>
- <version>2.2.0-SNAPSHOT</version>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <!-- Used for UTF8 testing -->
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <!-- Used for xxHash testing -->
- <groupId>net.openhft</groupId>
- <artifactId>zero-allocation-hashing</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <artifactId>datasketches-memory-resources</artifactId>
- <name>${project.artifactId}</name>
-
- <!-- The tests in the following profiles run against the assembled MR-JAR. Hence, they
- only run during the Maven package phase. Different profiles are selected based on
- the environment-specific version of Java that was used to run `mvn package`. This
- is because the new JPMS runtime arguments result in a catastrophic system error whilst
- using Java 8. Tests are scanned from dependency JARs using `dependenciesToScan`. -->
- <profiles>
- <profile>
- <id>java8</id>
- <activation>
- <jdk>[1.8,1.9),8</jdk>
- <property>
- <name>environment</name>
- <value>ci</value>
- </property>
- </activation>
-
- <properties>
- <jdk-toolchain.version>1.8</jdk-toolchain.version>
- <java.version>8</java.version>
- <maven.compiler.source>${java.version}</maven.compiler.source>
- <maven.compiler.target>${java.version}</maven.compiler.target>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory-java8-tests</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
-
- <plugin>
- <!-- Apache Parent pom, pluginManagement-->
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>${maven-surefire-plugin.version}</version>
- <executions>
- <execution>
- <id>package-test</id>
- <phase>package</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <!-- does not provide JPMS runtime arguments -->
- <configuration>
- <skip>false</skip>
- <dependenciesToScan>
- <dependency>org.apache.datasketches:datasketches-memory-java8-tests</dependency>
- </dependenciesToScan>
- <reportsDirectory>${project.build.directory}/test-output/${maven.build.timestamp}</reportsDirectory>
- <argLine />
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>java11to13</id>
- <activation>
- <jdk>[11,14)</jdk>
- <property>
- <name>environment</name>
- <value>ci</value>
- </property>
- </activation>
-
- <properties>
- <!--suppress UnresolvedMavenProperty -->
- <jdk-toolchain.version>${matrix.jdk.version}</jdk-toolchain.version>
- <!--suppress UnresolvedMavenProperty -->
- <java.version>${matrix.jdk.version}</java.version>
- <maven.compiler.source>${java.version}</maven.compiler.source>
- <maven.compiler.target>${java.version}</maven.compiler.target>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory-java8-tests</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
-
- <plugin>
- <!-- Apache Parent pom, pluginManagement-->
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>${maven-surefire-plugin.version}</version>
- <executions>
- <execution>
- <id>package-test</id>
- <phase>package</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <skip>false</skip>
- <argLine>
- --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
- --add-exports java.base/jdk.internal.ref=ALL-UNNAMED
- --add-opens java.base/java.nio=ALL-UNNAMED
- --add-opens java.base/sun.nio.ch=ALL-UNNAMED
- </argLine>
- <dependenciesToScan>
- <dependency>org.apache.datasketches:datasketches-memory-java8-tests</dependency>
- </dependenciesToScan>
- <reportsDirectory>${project.build.directory}/test-output/${maven.build.timestamp}</reportsDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
-
- </profiles>
-</project>
+++ /dev/null
-Abraham Lincoln's Gettysburg Address:
-
- Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.
-
- Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.
-
- But, in a larger sense, we can not dedicate —- we can not consecrate —- we can not hallow —- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -— that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -— that we here highly resolve that these dead shall not have died in vain -— that this nation, under God, shall have a new birth of freedom -— and that government of the people, by the people, for the people, shall not perish from the earth.
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
- http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache</groupId>
- <artifactId>apache</artifactId>
- <version>23</version>
- <!-- Bypass resolution within source directory and resolve parent from remote repository instead -->
- <relativePath />
- </parent>
-
- <!-- datasketches-memory assembly module
-
- NOTE:
- This uses the Maven project-aggregation feature and does not inherit from the parent
- so that there is no runtime dependency on the parent project (root module).
- As a result, some properties from the root POM are duplicated here for inclusion in
- the assembled artifacts. For more information, see:
- https://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Project_Aggregation -->
-
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory</artifactId>
- <version>2.2.0-SNAPSHOT</version>
-
- <name>${project.artifactId}</name>
- <description>High-performance native memory access.</description>
- <url>https://datasketches.apache.org/</url>
- <inceptionYear>2015</inceptionYear>
-
- <mailingLists>
- <mailingList>
- <name>DataSketches Developers</name>
- <subscribe>dev-subscribe@datasketches.apache.org</subscribe>
- <unsubscribe>dev-unsubscribe@datasketches.apache.org</unsubscribe>
- <post>dev@datasketches.apache.org</post>
- <archive>https://mail-archives.apache.org/mod_mbox/datasketches-dev</archive>
- </mailingList>
- <mailingList>
- <name>DataSketches Users</name>
- <subscribe>user-subscribe@datasketches.apache.org</subscribe>
- <unsubscribe>user-unsubscribe@datasketches.apache.org</unsubscribe>
- <post>user@datasketches.apache.org</post>
- <archive>https://mail-archives.apache.org/mod_mbox/datasketches-user</archive>
- </mailingList>
- </mailingLists>
-
- <scm>
- <connection>scm:git:ssh://git@github.com/apache/${project.artifactId}.git</connection>
- <developerConnection>scm:git:ssh://git@github.com/apache/${project.artifactId}.git</developerConnection>
- <url>https://github.com/apache/${project.artifactId}</url>
- <tag>HEAD</tag>
- </scm>
-
- <issueManagement>
- <!-- <system>jira</system>
- <url>https://issues.apache.org/jira/browse/DATASKETCHES</url> -->
- <system>GitHub</system>
- <url>https://github.com/apache/${project.artifactId}/issues</url>
- </issueManagement>
-
- <developers>
- <developer>
- <name>The Apache DataSketches Team</name>
- <email>dev@datasketches.apache.org</email>
- <url>https://datasketches.apache.org</url>
- <organization>Apache Software Foundation</organization>
- <organizationUrl>http://www.apache.org</organizationUrl>
- </developer>
- </developers>
-
- <properties>
- <!-- UNIQUE FOR THIS JAVA COMPONENT -->
- <protobuf-java.version>4.0.0-rc-2</protobuf-java.version>
- <!-- Used for UTF8 testing -->
- <zero-allocation-hashing.version>0.15</zero-allocation-hashing.version>
- <!-- END:UNIQUE FOR THIS JAVA COMPONENT -->
-
- <!-- Test -->
- <testng.version>7.5</testng.version>
-
- <!-- System-wide properties -->
- <maven.version>3.5.0</maven.version>
- <java.version>1.8</java.version>
- <maven.source.skip>true</maven.source.skip>
- <maven.compiler.source>${java.version}</maven.compiler.source>
- <maven.compiler.target>${java.version}</maven.compiler.target>
- <!-- deploy artifacts to nexus from this module only -->
- <maven.deploy.skip>false</maven.deploy.skip>
- <maven.install.skip>false</maven.install.skip>
- <maven.javadoc.skip>true</maven.javadoc.skip>
-
- <!-- Maven Plugins -->
- <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version> <!-- overrides parent -->
- <maven-enforcer-plugin.version>3.0.0</maven-enforcer-plugin.version> <!-- overrides parent -->
- <maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version> <!-- overrides parent -->
- <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version> <!-- overrides parent -->
- <maven-remote-resources-plugin.version>1.7.0</maven-remote-resources-plugin.version> <!-- overrides parent -->
- <!-- org.jacoco Maven Plugins -->
- <jacoco-maven-plugin.version>0.8.6</jacoco-maven-plugin.version>
- <!-- git plugin -->
- <git-commit-id-plugin.version>4.0.4</git-commit-id-plugin.version>
- </properties>
-
- <dependencies>
- <!-- These dependencies are required during assembly but not runtime -->
- <dependency>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory-java8</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory-java11</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <!-- Test Scope -->
- <dependency>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-memory-java8-tests</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <!-- Used for UTF8 testing -->
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
- <version>${protobuf-java.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <!-- Used for xxHash testing -->
- <groupId>net.openhft</groupId>
- <artifactId>zero-allocation-hashing</artifactId>
- <version>${zero-allocation-hashing.version}</version>
- <scope>test</scope>
- </dependency>
- <!-- END: UNIQUE FOR THIS JAVA COMPONENT -->
-
- </dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
-
- <!-- The assembly plugin builds all artifacts for this project from the other modules
- within the project. These modules are complementary and not standalone. Therefore,
- they are not installed and downloaded independently by the end user.
- Instead, the maven-assembly plugin builds all jars, and hides the multi-module
- configuration from the end user. -->
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>${maven-assembly-plugin.version}</version>
- <!--suppress MavenModelInspection -->
- <configuration>
- <archive>
- <manifest>
- <addDefaultEntries>false</addDefaultEntries>
- <addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
- <addDefaultImplementationEntries>false</addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <Build-Jdk>${java.version} (${java.vendor} ${java.vm.version})</Build-Jdk>
- <Build-OS>${os.name} ${os.arch} ${os.version}</Build-OS>
- <Implementation-Vendor>The Apache Software Foundation</Implementation-Vendor>
- <GroupId-ArtifactId>${project.groupId}:${project.artifactId}</GroupId-ArtifactId>
- <!-- these properties are generated by the git-commit-id-plugin during initialize -->
- <!--suppress UnresolvedMavenProperty -->
- <git-branch>${git.branch}</git-branch>
- <!--suppress UnresolvedMavenProperty -->
- <git-commit-id>${git.commit.id.full}</git-commit-id>
- <!--suppress UnresolvedMavenProperty -->
- <git-commit-time>${git.commit.time}</git-commit-time>
- <!--suppress UnresolvedMavenProperty -->
- <git-commit-user-email>${git.commit.user.email}</git-commit-user-email>
- <!--suppress UnresolvedMavenProperty -->
- <git-commit-tag>${git.tags}</git-commit-tag>
- </manifestEntries>
- </archive>
- </configuration>
- <executions>
-
- <!-- multi-release (MR) jar -->
- <execution>
- <id>assemble-jar</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <appendAssemblyId>false</appendAssemblyId>
- <attach>true</attach>
- <descriptors>
- <descriptor>src/assembly/assemble-mr-jar.xml</descriptor>
- </descriptors>
- <!-- The class loader requires this to be set in a multi-release JAR's manifest -->
- <archive>
- <manifestEntries>
- <Multi-Release>true</Multi-Release>
- </manifestEntries>
- </archive>
- </configuration>
- </execution>
-
- <!-- sources, tests and javadocs jars -->
- <execution>
- <id>assemble-sources-tests-javadocs</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <appendAssemblyId>true</appendAssemblyId>
- <attach>true</attach>
- <descriptors>
- <!-- tests jar -->
- <descriptor>src/assembly/assemble-test-jar.xml</descriptor>
- <!-- sources.jar -->
- <descriptor>src/assembly/assemble-sources.xml</descriptor>
- <!-- test-sources.jar -->
- <descriptor>src/assembly/assemble-test-sources.xml</descriptor>
- <!-- javadoc jar -->
- <descriptor>src/assembly/assemble-javadoc.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
-
- </executions>
- </plugin>
-
- <plugin>
- <!-- Generates aggregate code coverage report from website.
- This applies across all Maven submodules. -->
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>${jacoco-maven-plugin.version}</version>
- <executions>
- <execution>
- <id>default-report</id>
- <phase>verify</phase>
- <goals>
- <goal>report-aggregate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>${maven-enforcer-plugin.version}</version>
- <executions>
- <execution>
- <id>enforce-banned-dependencies</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireJavaVersion>
- <version>[1.8, 1.9),[8],[11,14),[17,18)</version>
- </requireJavaVersion>
- <requireMavenVersion>
- <version>[${maven.version},)</version>
- </requireMavenVersion>
- <bannedDependencies>
- <excludes>
- <!--LGPL licensed library-->
- <exclude>com.google.code.findbugs:annotations</exclude>
- </excludes>
- </bannedDependencies>
- </rules>
- <fail>true</fail>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>pl.project13.maven</groupId>
- <artifactId>git-commit-id-plugin</artifactId>
- <version>${git-commit-id-plugin.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>revision</goal>
- </goals>
- <phase>initialize</phase>
- </execution>
- </executions>
- <configuration>
- <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
- <dateFormatTimeZone>UTC</dateFormatTimeZone>
- <verbose>false</verbose>
- <skipPoms>false</skipPoms>
- <format>json</format>
- <generateGitPropertiesFile>true</generateGitPropertiesFile>
- <generateGitPropertiesFilename>${project.build.directory}/git.properties</generateGitPropertiesFilename>
- <!-- Maven commands are sometimes run on the release artifact directly, which is not a Git repository -->
- <failOnNoGitDirectory>false</failOnNoGitDirectory>
- <failOnUnableToExtractRepoInfo>true</failOnUnableToExtractRepoInfo>
- <commitIdGenerationMode>full</commitIdGenerationMode>
- <includeOnlyProperties>
- <includeProperty>git.branch</includeProperty>
- <includeProperty>git.commit.id.full</includeProperty>
- <includeProperty>git.commit.time</includeProperty>
- <includeProperty>git.commit.user.email</includeProperty>
- <includeProperty>git.tags</includeProperty>
- </includeOnlyProperties>
- <gitDescribe>
- <skip>false</skip>
- <always>true</always>
- <abbrev>7</abbrev>
- <dirty>-dirty</dirty>
- <tags>true</tags>
- <forceLongFormat>true</forceLongFormat>
- </gitDescribe>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>${maven-jar-plugin.version}</version>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>pl.project13.maven</groupId>
- <artifactId>git-commit-id-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
-
- <!-- This profile is used to release signed jars to the Apache Nexus repository.
- This must be executed from a git repository set at the proper Release branch (e.g., 1.1.X)
- and at a Release Candidate tag (e.g., 1.1.0-RC1).
- The pom version in the release branch must be properly set to something like: "1.1.0".
- The pom version in the master would be set to something like: "1.2.0-SNAPSHOT".
- Test Command: mvn clean verify -Pnexus-jars -DskipTests=true
- Command: mvn clean deploy -Dnexus-jars
- Verify Command (from terminal): gpg -v --verify $ASC $FILE # dashdashverify
- -->
- <profile>
- <id>nexus-jars</id>
- <build>
- <pluginManagement>
- <plugins>
- <!-- We want to sign the artifacts, POM, and all attached artifacts -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
- <version>${maven-gpg-plugin.version}</version>
- <executions>
- <execution>
- <id>sign-artifacts</id>
- <phase>verify</phase>
- <goals>
- <goal>sign</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <gpgArguments>
- <arg>--verbose</arg>
- <!-- prints the algorithm used -->
- <arg>--personal-digest-preferences=SHA512</arg>
- </gpgArguments>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
- <plugin>
- <groupId>pl.project13.maven</groupId>
- <artifactId>git-commit-id-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>only-eclipse</id>
- <activation>
- <property>
- <name>m2e.version</name>
- </property>
- </activation>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-remote-resources-plugin</artifactId>
- <version>${maven-remote-resources-plugin.version}</version>
- <executions>
- <execution>
- <id>process-resource-bundles</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-remote-resources-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- </profiles>
-
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
- <id>javadoc</id>
- <formats>
- <format>jar</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <!-- Java apidocs html and stylesheets -->
- <moduleSets>
- <moduleSet>
- <useAllReactorProjects>true</useAllReactorProjects>
- <includes>
- <include>org.apache.datasketches:datasketches-memory-java8</include>
- </includes>
- <sources>
- <includeModuleDirectory>false</includeModuleDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.directory}/apidocs</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
- </fileSets>
- </sources>
- </moduleSet>
- </moduleSets>
-
- <files>
- <!-- DEPENDENCIES, LICENSE and NOTICE -->
- <file>
- <source>${project.build.outputDirectory}/META-INF/DEPENDENCIES</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/LICENSE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/NOTICE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <!-- pom.properties -->
- <file>
- <source>${project.build.directory}/maven-archiver/pom.properties</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- <!-- pom.xml -->
- <file>
- <source>${project.basedir}/pom.xml</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- </files>
-
-</assembly>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
- <id>assemble-jar</id>
- <formats>
- <format>jar</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <!-- Compiled java classes from dependency modules -->
- <moduleSets>
- <!-- java8 -->
- <moduleSet>
- <useAllReactorProjects>true</useAllReactorProjects>
- <includes>
- <include>org.apache.datasketches:datasketches-memory-java8</include>
- </includes>
- <sources>
- <includeModuleDirectory>false</includeModuleDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.outputDirectory}</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
- </fileSets>
- </sources>
- </moduleSet>
- <!-- java11 -->
- <moduleSet>
- <useAllReactorProjects>true</useAllReactorProjects>
- <includes>
- <include>org.apache.datasketches:datasketches-memory-java11</include>
- </includes>
- <binaries>
- <outputDirectory>META-INF/versions/11</outputDirectory>
- <unpack>true</unpack>
- <includeDependencies>false</includeDependencies>
- <unpackOptions>
- <excludes>
- <exclude>/META-INF/**</exclude>
- </excludes>
- </unpackOptions>
- </binaries>
- </moduleSet>
- </moduleSets>
-
- <files>
- <!-- DEPENDENCIES, LICENSE and NOTICE -->
- <file>
- <source>${project.build.outputDirectory}/META-INF/DEPENDENCIES</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/LICENSE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/NOTICE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <!-- pom.properties -->
- <file>
- <source>${project.build.directory}/maven-archiver/pom.properties</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- <!-- pom.xml -->
- <file>
- <source>${project.basedir}/pom.xml</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- </files>
-
-</assembly>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
- <id>sources</id>
- <formats>
- <format>jar</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <!-- Java sources -->
- <moduleSets>
- <moduleSet>
- <useAllReactorProjects>true</useAllReactorProjects>
- <includes>
- <include>org.apache.datasketches:datasketches-memory-java8</include>
- </includes>
- <sources>
- <includeModuleDirectory>false</includeModuleDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.sourceDirectory}</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
- </fileSets>
- </sources>
- </moduleSet>
- </moduleSets>
-
- <files>
- <!-- DEPENDENCIES, LICENSE and NOTICE -->
- <file>
- <source>${project.build.outputDirectory}/META-INF/DEPENDENCIES</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/LICENSE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/NOTICE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <!-- pom.properties -->
- <file>
- <source>${project.build.directory}/maven-archiver/pom.properties</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- <!-- pom.xml -->
- <file>
- <source>${project.basedir}/pom.xml</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- </files>
-
-</assembly>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
- <id>tests</id>
- <formats>
- <format>jar</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <!-- Compiled java classes from dependency test modules -->
- <moduleSets>
- <moduleSet>
- <useAllReactorProjects>true</useAllReactorProjects>
- <includes>
- <include>org.apache.datasketches:datasketches-memory-java8-tests</include>
- </includes>
- <sources>
- <includeModuleDirectory>false</includeModuleDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.testOutputDirectory}</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
- </fileSets>
- </sources>
- </moduleSet>
- </moduleSets>
-
- <files>
- <!-- DEPENDENCIES, LICENSE and NOTICE -->
- <file>
- <source>${project.build.outputDirectory}/META-INF/DEPENDENCIES</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/LICENSE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/NOTICE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <!-- pom.properties -->
- <file>
- <source>${project.build.directory}/maven-archiver/pom.properties</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- <!-- pom.xml -->
- <file>
- <source>${project.basedir}/pom.xml</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- </files>
-
-</assembly>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
- <id>test-sources</id>
- <formats>
- <format>jar</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <!-- Java test sources -->
- <moduleSets>
- <moduleSet>
- <useAllReactorProjects>true</useAllReactorProjects>
- <includes>
- <include>org.apache.datasketches:datasketches-memory-java8-tests</include>
- </includes>
- <sources>
- <includeModuleDirectory>false</includeModuleDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.testSourceDirectory}</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
- </fileSets>
- </sources>
- </moduleSet>
- </moduleSets>
-
- <files>
- <!-- DEPENDENCIES, LICENSE and NOTICE -->
- <file>
- <source>${project.build.outputDirectory}/META-INF/DEPENDENCIES</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/LICENSE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <file>
- <source>${maven.multiModuleProjectDirectory}/NOTICE</source>
- <outputDirectory>META-INF</outputDirectory>
- </file>
- <!-- pom.properties -->
- <file>
- <source>${project.build.directory}/maven-archiver/pom.properties</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- <!-- pom.xml -->
- <file>
- <source>${project.basedir}/pom.xml</source>
- <outputDirectory>META-INF/maven/org.apache.datasketches/datasketches-memory</outputDirectory>
- </file>
- </files>
-
-</assembly>
### Java compiler versions
-Settings are usually synchronised with Maven Toolchain configuration, otherwise the Java version
+Settings are usually synchronized with Maven Toolchain configuration, otherwise the Java version
for a Maven module should be set as follows:
-| Maven submodule | JDK |
-| --------------------------------- | --- |
-| datasketches-memory-root | 8 |
-| datasketches-memory | 8 |
-| datasketches-memory-java8 | 8 |
-| datasketches-memory-java8-tests | 8 |
-| datasketches-memory-java11 | 11 |
-| datasketches-memory-resources | 8 |
+| Maven submodule | JDK |
+| -------------------------- | --- |
+| datasketches-memory | 8 |
+| datasketches-memory-java8 | 8 |
+| datasketches-memory-java11 | 11 |
### Compiler arguments for JPMS
In order to compile Maven modules in Java versions 11 and above, it is necessary to provide the
-following arguments to the compiler. These are usually synchronised with the `pom.xml`
+following arguments to the compiler. These are usually synchronized with the `pom.xml`
configuration:
```xml
The [Eclipse Maven plugin](https://maven.apache.org/plugins/maven-eclipse-plugin/) is used to
generate Eclipse IDE files. In order to run the eclipse plugin use:
- $ mvn clean process-classes eclipse:eclipse -DskipTests=true
+ $ mvn clean eclipse:eclipse -DskipTests=true
More information about using the eclipse plugin with multi-module Maven builds can be found
in the Maven
You might need to verify this for each module, making sure the correct compliance level is used:
- `datasketches-memory-java11` should use level 11 compliance.
-- all other modules should use level 1.8 compliance.
+- `datasketches-memory-java8` should use level 1.8 compliance.
---
### Running unit tests
-- Under the `datasketches-memory-java-8-tests` module, right-click on the `src/test/java`
+- Under the `datasketches-memory-java8` module, right-click on the `src/test/java`
directory.
- Select **Run-As** / **TestNG Test**
- It should open a new window and run over 400 tests without error.
Settings are usually synchronised with maven toolchain configuration, otherwise the Java version
for a maven module should be set as follows:
-| Maven submodule | JDK |
-| --------------------------------- | --- |
-| datasketches-memory-root | 8 |
-| datasketches-memory | 8 |
-| datasketches-memory-java8 | 8 |
-| datasketches-memory-java8-tests | 8 |
-| datasketches-memory-java11 | 11 |
-| datasketches-memory-resources | 8 |
+| Maven submodule | JDK |
+| -------------------------- | --- |
+| datasketches-memory | 8 |
+| datasketches-memory-java8 | 8 |
+| datasketches-memory-java11 | 11 |
#### Compiler arguments for JPMS
# Maven Configuration: Multi-Module Project
This project is a multi-module Maven project. A multi-module Maven project consists of an
-aggregator project (the `datasketches-memory-root` project), together with a set of submodules.
+aggregator project (the `datasketches-memory` project), together with a set of submodules.
The aggregator's configuration is inherited by each submodule, thus reducing duplication.
Datasketches Memory makes use of some features of the Java platform, for example, `Unsafe`,
This project has been divided into the following submodules:
* datasketches-memory-java8 (base version of the JVM that is currently supported)
-* datasketches-memory-java8-tests
* datasketches-memory-java11 (Java11 equivalent of some platform specific classes in
-datasketches-memory-java8)
-* datasketches-memory (MR-JAR assembly, does not contain source files)
-* datasketches-memory-resources (Runs test suite against assembled MR-JAR)
### Artifact assembly
-The [Maven assembly plugin](https://maven.apache.org/plugins/maven-assembly-plugin/) builds all
-artifacts for this project from the other modules within the project.
-These modules are complementary and not standalone.
-Therefore, they are not installed and downloaded independently by the end user.
+During the Maven package phase, the [Maven exec plugin](https://www.mojohaus.org/exec-maven-plugin/index.html)
+invokes a custom bash script `package-mr-jar.sh` located in the `tools/scripts` directory.
+This script assembles sources and compiled classes from the individual maven modules into
+a coherent set of JARs that appear to the end user to originate from a single module.
-Instead, the Maven assembly plugin builds all jars, and hides the multi-module configuration
-from the end user.
-
-The following jars are assembled by the `datasketches-memory` module:
+The following jars are assembled by the bash package script:
* datasketches-memory-X.Y.Z.jar The compiled main class files.
* datasketches-memory-X.Y.Z-tests.jar The compiled test class files.
#### org.apache.datasketches.memory
-In the `datasketches-memory-java11` maven submodule root, the following module declaration has
+In the `datasketches-memory-java11` maven submodule source root, the following module declaration has
been added:
```java
### Assembly
-The Maven assembly plugin uses the Maven submodules during the `package` phase.
-The following maven submodules to source the compiled class files for the MR-JAR:
+During the Maven package phase, the [Maven exec plugin](https://www.mojohaus.org/exec-maven-plugin/index.html)
+invokes a custom bash script `package-mr-jar.sh` located in the `tools/scripts` directory.
+This script requires that the prior phases in the Maven lifecycle have been completed.
+
+The following maven submodules are used to source the compiled class files for the MR-JAR:

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.datasketches</groupId>
<artifactId>datasketches-memory-root</artifactId>
- <version>2.2.0-SNAPSHOT</version>
+ <version>2.3.0-SNAPSHOT</version>
<!-- Required for multi-module project -->
<packaging>pom</packaging>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version> <!-- overrides parent -->
<maven-toolchains-plugin.version>3.0.0</maven-toolchains-plugin.version>
<maven-install-plugin.version>3.0.0-M1</maven-install-plugin.version>
+ <maven-exec-plugin.version>3.0.0</maven-exec-plugin.version>
<!-- Apache Plugins -->
<apache-rat-plugin.version>0.13</apache-rat-plugin.version> <!-- overrides parent -->
<!-- org.jacoco Maven Plugins -->
<exclude>**/test-output/**/*</exclude>
<exclude>**/img/**/*.png</exclude>
<exclude>**/git.properties</exclude>
- <exclude>**/scripts/LoremIpsum.txt</exclude>
+ <exclude>**/scripts/assets/LoremIpsum.txt</exclude>
<exclude>LICENSE</exclude>
<exclude>NOTICE</exclude>
</excludes>
<!--suppress UnresolvedMavenProperty -->
<repoToken>${coveralls-repo-token}</repoToken>
<!--suppress UnresolvedMavenProperty -->
- <jacocoReports>${maven.multiModuleProjectDirectory}/datasketches-memory/target/site/jacoco-aggregate/jacoco.xml</jacocoReports>
+ <jacocoReports>${maven.multiModuleProjectDirectory}/datasketches-memory-java8/target/site/jacoco/jacoco.xml</jacocoReports>
</configuration>
</plugin>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>${maven-exec-plugin.version}</version>
+ </plugin>
+
</plugins>
</pluginManagement>
<plugins>
</build>
</profile>
-
</profiles>
<!-- This Maven project is divided into an aggregator project (the root), that manages a group of submodules that
contribute to this project -->
<modules>
<module>datasketches-memory-java8</module>
- <module>datasketches-memory-java8-tests</module>
<module>datasketches-memory-java11</module>
- <module>datasketches-memory</module>
- <module>datasketches-memory-resources</module>
</modules>
</project>
#Add Implementation Vendor
prop=$prop'Implementation-Vendor: '
-tmp='The Apache Software Foundataion'$CR
+tmp='The Apache Software Foundation'$CR
prop=$prop$tmp
#Add GroupId : ArtifactId
prop=$prop$tmp
# Add Branch
-prop=$prop'git.branch: '
+prop=$prop'Git-Branch: '
tmp=''$(git rev-parse --abbrev-ref HEAD)''$CR
prop=$prop$tmp
#Add commit-id
-prop=$prop'git.commit.id.full: '
+prop=$prop'Git-Commit-Id-Full: '
ID=$(git rev-parse HEAD)
tmp=''$ID''$CR
prop=$prop$tmp
#Add timestamp
-prop=$prop'git.commit.time: '
+prop=$prop'Git-Commit-Time: '
tmp=''$(git show --no-patch --no-notes --pretty='%cI' $ID)''$CR
prop=$prop$tmp
#Add user email
-prop=$prop'git-commit-user-email: '
+prop=$prop'Git-Commit-User-Email: '
tmp=''$(git show --no-patch --no-notes --pretty='%ce' $ID)''$CR
prop=$prop$tmp
#Add Tag
-prop=$prop'git.commit.tag: '
+prop=$prop'Git-Commit-Tag: '
tmp=''$Tag''$CR
prop=$prop$tmp
--- /dev/null
+#!/bin/bash -e
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This is a general bash script to build a datasketches-memory-X.jar
+# with multi-release functionality. The sources, test-sources, tests and
+# javadoc jars are also included in the output.
+# It does use git and also uses the script get-git-properties.sh.
+#
+# NOTE: This script assumes that `mvn package` has been run prior to invocation.
+# By default, it is called from the maven exec-plugin.
+
+# Required Input Parameters:
+# \$1 = absolute path of JDK home directory
+# \$2 = Git Version Tag for this deployment
+# Example tag for SNAPSHOT : 1.0.0-SNAPSHOT
+# Example tag for Release Candidate: 1.0.0-RC1
+# Example tag for Release : 1.0.0
+# \$3 = absolute path of project.basedir
+# For example: $ <this script>.sh $JAVA_HOME 2.1.0 .
+
+if [ -z "$1" ]; then echo "Missing JDK home"; exit 1; fi
+if [ -z "$2" ]; then echo "Missing Git Tag"; exit 1; fi
+if [ -z "$3" ]; then echo "Missing project.basedir"; exit 1; fi
+
+#### Extract JDKHome, Version and ProjectBaseDir from input parameters ####
+JDKHome=$1
+GitTag=$2
+ProjectBaseDir=$3 #this must be an absolute path
+
+#### Setup absolute directory references ####
+ProjectArtifactId="datasketches-memory"
+ScriptsDir=${ProjectBaseDir}/tools/scripts/
+
+#### Initialise path dependent variables ####
+OutputDir=target
+OutputMrJar=${OutputDir}/datasketches-memory-${GitTag}.jar
+OutputTests=${OutputDir}/datasketches-memory-${GitTag}-tests.jar
+OutputJavaDoc=${OutputDir}/datasketches-memory-${GitTag}-javadoc.jar
+OutputSources=${OutputDir}/datasketches-memory-${GitTag}-sources.jar
+OutputTestSources=${OutputDir}/datasketches-memory-${GitTag}-test-sources.jar
+
+ArchiveDir=${OutputDir}/archive-tmp
+PackageSources=${ArchiveDir}/sources
+PackageTestSources=${ArchiveDir}/test-sources
+PackageTests=${ArchiveDir}/tests
+PackageJavaDoc=${ArchiveDir}/javadoc
+PackageMrJar=${ArchiveDir}/jar
+
+#### Move to project directory ####
+cd ${ProjectBaseDir}
+
+#### Use JAVA_HOME to set required executables ####
+if [[ -n "$JDKHome" ]] && [[ -x "${JDKHome}/bin/jar" ]]; then Jar_="${JDKHome}/bin/jar"; else echo "No jar version could be found."; exit 1; fi
+
+MemoryJava8Classes=datasketches-memory-java8/target/classes
+MemoryJava8TestClasses=datasketches-memory-java8/target/test-classes
+MemoryJava8Sources=datasketches-memory-java8/src/main/java
+MemoryJava8TestSources=datasketches-memory-java8/src/test/java
+MemoryJava8Docs=datasketches-memory-java8/target/apidocs/
+MemoryJava11Classes=datasketches-memory-java11/target/classes
+MemoryJava11Sources=datasketches-memory-java11/src/main/java
+MemoryJava8Docs=datasketches-memory-java8/target/apidocs/
+MavenArchiver=target/maven-archiver
+
+if ! [[ -x "${MemoryJava8Classes}" ]]; then echo "No compiled classes - run mvn package first."; exit 1; fi
+if ! [[ -x "${MemoryJava8TestClasses}" ]]; then echo "No compiled test classes - run mvn package first."; exit 1; fi
+if ! [[ -x "${MemoryJava11Classes}" ]]; then echo "No compiled classes - run mvn package first."; exit 1; fi
+if ! [[ -x "${MemoryJava8Docs}" ]]; then echo "No javadocs - run mvn package first."; exit 1; fi
+if ! [[ -x "${MavenArchiver}" ]]; then echo "No maven archiver - run mvn package first."; exit 1; fi
+
+#### Cleanup and setup output directories ####
+echo
+if [ -d "$OutputDir" ]; then rm -f $OutputDir/*.jar; fi
+if [ -d "$ArchiveDir" ]; then rm -r $ArchiveDir; fi
+
+mkdir -p $PackageSources
+mkdir -p $PackageTestSources
+mkdir -p $PackageTests
+mkdir -p $PackageJavaDoc
+mkdir -p $PackageMrJar
+
+#### JAR Metadata function
+prepare_jar () {
+ JarBase=$1
+ JarMeta=${JarBase}/META-INF
+ JarMaven=${JarMeta}/maven/org.apache.datasketches/datasketches-memory
+
+ mkdir -p ${JarMeta}/versions/11
+ mkdir -p ${JarMaven}
+
+ #### Generate DEPENDENCIES ####
+ cat >> ${JarMeta}/DEPENDENCIES<< EOF
+// ------------------------------------------------------------------
+// Transitive dependencies of this project determined from the
+// maven pom organized by organization.
+// ------------------------------------------------------------------
+EOF
+
+ #### Copy LICENSE and NOTICE ####
+ cp LICENSE $JarMeta
+ cp NOTICE $JarMeta
+
+ #### Copy pom.properties
+ cp ${MavenArchiver}/pom.properties $JarMaven
+ cp pom.xml $JarMaven
+
+}
+
+#### Generate MANIFEST.MF ####
+cat >> ${ArchiveDir}/MANIFEST.MF<< EOF
+Manifest-Version: 1.0
+Created-By: Apache Datasketches Memory package-mr-jar.sh
+Multi-Release: true
+EOF
+#### Generate git.properties file ####
+echo "$($ScriptsDir/get-git-properties.sh $ProjectBaseDir $ProjectArtifactId $GitTag)" >> ${ArchiveDir}/MANIFEST.MF
+
+###########################
+#### MULTI-RELEASE JAR ####
+###########################
+prepare_jar $PackageMrJar
+#### Copy java 8 compiled classes to target/jar
+rsync -q -a -I --filter="- .*" ${MemoryJava8Classes}/org $PackageMrJar
+#### Copy java 11 compiled classes to target/jar/META-INF/versions/11
+rsync -q -a -I --filter="- .*" ${MemoryJava11Classes}/org ${PackageMrJar}/META-INF/versions/11
+cp ${MemoryJava11Classes}/module-info.class ${PackageMrJar}/META-INF/versions/11
+
+${Jar_} cfm $OutputMrJar ${ArchiveDir}/MANIFEST.MF -C $PackageMrJar .
+echo "Created multi-release jar ${OutputMrJar}"
+
+###########################
+#### TESTS JAR ####
+###########################
+prepare_jar $PackageTests
+#### Copy java 8 compiled test classes to target/jar
+rsync -q -a -I --filter="- .*" ${MemoryJava8TestClasses}/org $PackageTests
+
+${Jar_} cfm $OutputTests ${ArchiveDir}/MANIFEST.MF -C $PackageTests .
+echo "Created tests jar ${OutputTests}"
+
+###########################
+#### SOURCES JAR ####
+###########################
+prepare_jar $PackageSources
+#### Copy java 8 source files to target/sources
+rsync -q -a -I --filter="- .*" ${MemoryJava8Sources}/org $PackageSources
+#### Copy java 11 source files to target/sources/META-INF/versions/11
+rsync -q -a -I --filter="- .*" ${MemoryJava11Sources}/org ${PackageSources}/META-INF/versions/11
+cp ${MemoryJava11Sources}/module-info.java ${PackageSources}/META-INF/versions/11
+
+${Jar_} cfm $OutputSources ${ArchiveDir}/MANIFEST.MF -C $PackageSources .
+echo "Created sources jar ${OutputSources}"
+
+###########################
+#### TEST SOURCES JAR ####
+###########################
+prepare_jar $PackageTestSources
+#### Copy java 8 test source files to target/test-sources
+rsync -q -a -I --filter="- .*" ${MemoryJava8TestSources}/org $PackageTestSources
+
+${Jar_} cfm $OutputTestSources ${ArchiveDir}/MANIFEST.MF -C $PackageTestSources .
+echo "Created test sources jar ${OutputTestSources}"
+
+###########################
+#### JAVADOC JAR ####
+###########################
+prepare_jar $PackageJavaDoc
+
+rsync -q -a -I --filter="- .*" ${MemoryJava8Docs} $PackageJavaDoc
+${Jar_} cfm $OutputJavaDoc ${ArchiveDir}/MANIFEST.MF -C $PackageJavaDoc .
+echo "Created javadoc jar ${OutputJavaDoc}"
+
+echo "$($ScriptsDir/test-jar.sh $JDKHome $GitTag $OutputMrJar $ProjectBaseDir)"
# who do not wish to install several versions of the JDK on their
# machine.
# The script does not assume a POM file and does not use Maven.
-# It does use git and also uses the script getGitProperties.sh.
+# It does use git and also uses the script get-git-properties.sh and
+# test-jar.sh scripts.
# Required Input Parameters:
# \$1 = absolute path of JDK home directory
#### Setup absolute directory references ####
ProjectArtifactId="memory"
ScriptsDir=${ProjectBaseDir}/tools/scripts/
-MemoryMapFile=$ScriptsDir/LoremIpsum.txt
+MemoryMapFile=$ScriptsDir/assets/LoremIpsum.txt
#### Initialise path dependent variables ####
OutputDir=target
#### Generate MANIFEST.MF ####
cat >> ${PackageManifest}<< EOF
Manifest-Version: 1.0
-Created-By: Apache Datasketches Memory compile-package-jar.sh
+Created-By: Apache Datasketches Memory package-single-release-jar.sh
Multi-Release: false
EOF
#### Generate git.properties file ####
-echo "$($ScriptsDir/getGitProperties.sh $ProjectBaseDir $ProjectArtifactId $GitTag)" >> $PackageManifest
+echo "$($ScriptsDir/get-git-properties.sh $ProjectBaseDir $ProjectArtifactId $GitTag)" >> $PackageManifest
#### Copy source tree to target/src
rsync -a -I $MemoryJava8Src $PackageSrc
echo "--- JARS ---"
echo
echo "Building JAR from ${PackageContents}..."
-${Jar_} cf $OutputJar -C $PackageContents .
+${Jar_} cfm $OutputJar ${PackageManifest} -C $PackageContents .
echo
+echo "Successfully built ${OutputJar}"
# Uncomment this section to display JAR contents
# echo "--- JAR CONTENTS ---"
# ${Jar_} tf ${OutputJar}
# echo
-echo "--- RUN JAR CHECKS ---"
-echo
-if [[ $JavaVersion -eq 8 ]]; then
- ${Javac_} -cp $OutputJar -d $PackageTests $(find $ScriptsDir -name '*.java')
- ${Java_} -cp $PackageTests:$OutputJar org.apache.datasketches.memory.tools.scripts.CheckMemoryJar $MemoryMapFile
-else
- ${Javac_} \
- --add-modules org.apache.datasketches.memory \
- -p "$OutputJar" -d $PackageTests $(find $ScriptsDir -name '*.java')
-
- ${Java_} \
- --add-modules org.apache.datasketches.memory \
- --add-exports java.base/jdk.internal.misc=org.apache.datasketches.memory \
- --add-exports java.base/jdk.internal.ref=org.apache.datasketches.memory \
- --add-opens java.base/java.nio=org.apache.datasketches.memory \
- --add-opens java.base/sun.nio.ch=org.apache.datasketches.memory \
- -p $OutputJar -cp $PackageTests org.apache.datasketches.memory.tools.scripts.CheckMemoryJar $MemoryMapFile
-fi
-echo
-echo "Successfully built ${OutputJar}"
+echo "$($ScriptsDir/test-jar.sh $JDKHome $GitTag $OutputJar $ProjectBaseDir)"
--- /dev/null
+#!/bin/bash -e
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This is a general bash script to sign and deploy a datasketches-memory-X.jar.
+# This is intended to be used for releasing the Memory component to Maven central.
+
+# Required Input Parameters:
+# \$1 = Git Version Tag for this deployment
+# Example tag for SNAPSHOT : 1.0.0-SNAPSHOT
+# Example tag for Release Candidate: 1.0.0-RC1
+# Example tag for Release : 1.0.0
+# \$2 = absolute path of project.basedir
+# For example: $ <this script>.sh 2.1.0 .
+
+#### Extract GitTag, TestJar and ProjectBaseDir from input parameters ####
+GitTag=$1
+ProjectBaseDir=$2
+
+#### Setup absolute directory references ####
+OutputDir=${ProjectBaseDir}/target
+
+OutputMrJar=${OutputDir}/datasketches-memory-${GitTag}.jar
+OutputTests=${OutputDir}/datasketches-memory-${GitTag}-tests.jar
+OutputJavaDoc=${OutputDir}/datasketches-memory-${GitTag}-javadoc.jar
+OutputSources=${OutputDir}/datasketches-memory-${GitTag}-sources.jar
+OutputTestSources=${OutputDir}/datasketches-memory-${GitTag}-test-sources.jar
+OutputPom=${OutputDir}/datasketches-memory-${GitTag}-pom
+
+#### Use GNU-GPG to create signature
+sign_file () {
+ File=$1
+ gpg --verbose --personal-digest-preferences=SHA512 --detach-sign -a $File
+}
+
+### Deploy to nexus
+if [[ $GitTag == *SNAPSHOT ]]
+then
+ echo "Using SNAPSHOT repository."
+ DistributionsUrl=https://repository.apache.org/content/repositories/snapshots/
+ DistributionsId=apache.snapshots.https
+else
+ echo "Using RELEASES repository."
+ DistributionsUrl=https://repository.apache.org/service/local/staging/deploy/maven2/
+ DistributionsId=apache.releases.https
+fi;
+
+mvn org.apache.maven.plugins:maven-gpg-plugin:3.0.1:sign-and-deploy-file \
+ -Durl=$DistributionsUrl\
+ -DrepositoryId=$DistributionsId \
+ -Dfile=$OutputMrJar \
+ -Dsources=$OutputSources \
+ -Dfiles=$OutputTests,$OutputTestSources \
+ -Dtypes=jar,jar \
+ -Dclassifiers=tests,test-sources \
+ -Djavadoc=$OutputJavaDoc \
+ -Dpackaging=jar \
+ -Dversion=$GitTag \
+ -DupdateReleaseInfo=true \
+ -DpomFile=${ProjectBaseDir}/pom.xml
+
+echo "Successfully signed and deployed jars"
--- /dev/null
+#!/bin/bash -e
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This is a general bash script to test a datasketches-memory-X.jar.
+# This is intended to be used for C/I matrix testing or for quick
+# verification of the output from the assembly process.
+
+# Required Input Parameters:
+# \$1 = absolute path of JDK home directory
+# \$2 = Git Version Tag for this deployment
+# Example tag for SNAPSHOT : 1.0.0-SNAPSHOT
+# Example tag for Release Candidate: 1.0.0-RC1
+# Example tag for Release : 1.0.0
+# \$3 = absolute path of datasketches-memory-X.jar
+# \$4 = absolute path of project.basedir
+# For example: $ <this script>.sh $JAVA_HOME 2.1.0 target/datasketches-memory-X.jar .
+
+#### Extract JDKHome, Version, TestJar and ProjectBaseDir from input parameters ####
+JDKHome=$1
+GitTag=$2
+TestJar=$3
+ProjectBaseDir=$4
+
+#### Setup absolute directory references ####
+ProjectArtifactId="memory"
+ScriptsDir=${ProjectBaseDir}/tools/scripts/
+MemoryMapFile=$ScriptsDir/assets/LoremIpsum.txt
+
+#### Initialise path dependent variables ####
+PackageChecks=target/archive-tmp/checks
+
+#### Move to project directory ####
+cd ${ProjectBaseDir}
+
+#### Use JAVA_HOME to set required executables ####
+if [[ -n "$JDKHome" ]] && [[ -x "${JDKHome}/bin/java" ]]; then Java_="${JDKHome}/bin/java"; else echo "No java version could be found."; exit 1; fi
+if [[ -n "$JDKHome" ]] && [[ -x "${JDKHome}/bin/javac" ]]; then Javac_="${JDKHome}/bin/javac"; else echo "No javac version could be found."; exit 1; fi
+if [[ -n "$JDKHome" ]] && [[ -x "${JDKHome}/bin/jar" ]]; then Jar_="${JDKHome}/bin/jar"; else echo "No jar version could be found."; exit 1; fi
+
+#### Parse java -version into major version number ####
+if [[ "$Java_" ]]; then
+ # This expression extracts the correct major version of the Java runtime.
+ # For older runtime versions, such as 1.8, the leading '1.' is removed.
+ # Adapted from this answer on StackOverflow:
+ # https://stackoverflow.com/questions/7334754/correct-way-to-check-java-version-from-bash-script/56243046#56243046
+ JavaVersion=$("$Java_" -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1)
+else
+ echo "No version information could be determined from installed JDK."; exit 1;
+fi
+
+# Exit if Java version too low (< 8) or too high (> 13)
+if [[ $JavaVersion -lt 8 || $JavaVersion -gt 13 ]]; then
+ echo "Java version not supported: " $JavaVersion; exit 1;
+fi
+
+#### Cleanup and setup output directories ####
+echo
+if [ -d "$PackageChecks" ]; then rm -r $PackageChecks; fi
+mkdir -p $PackageChecks
+
+echo "--- RUN JAR CHECKS ---"
+echo
+if [[ $JavaVersion -eq 8 ]]; then
+ ${Javac_} -cp $TestJar -d $PackageChecks $(find ${ScriptsDir/assets} -name '*.java')
+ ${Java_} -cp $PackageChecks:$TestJar org.apache.datasketches.memory.tools.scripts.CheckMemoryJar $MemoryMapFile
+else
+ ${Javac_} \
+ --add-modules org.apache.datasketches.memory \
+ -p "$TestJar" -d $PackageChecks $(find ${ScriptsDir/assets} -name '*.java')
+
+ ${Java_} \
+ --add-modules org.apache.datasketches.memory \
+ --add-exports java.base/jdk.internal.misc=org.apache.datasketches.memory \
+ --add-exports java.base/jdk.internal.ref=org.apache.datasketches.memory \
+ --add-opens java.base/java.nio=org.apache.datasketches.memory \
+ --add-opens java.base/sun.nio.ch=org.apache.datasketches.memory \
+ -p $TestJar -cp $PackageChecks org.apache.datasketches.memory.tools.scripts.CheckMemoryJar $MemoryMapFile
+fi
+echo
+echo "Successfully checked ${TestJar}"