This is an automated email from the ASF dual-hosted git repository. leerho pushed a commit to branch integrateJava17_v3 in repository https://gitbox.apache.org/repos/asf/datasketches-memory.git
commit bedd46e3d4dfcae0555930a796d82b79aedde044 Author: Lee Rhodes <[email protected]> AuthorDate: Tue Jun 4 10:58:47 2024 -0700 more formatting cleanup And adopting workflow configs from ds-java --- .github/workflows/auto-jdk-matrix.yml | 44 +++++++++++----------- .github/workflows/javadoc.yml | 23 +++++++++++ .../org/apache/datasketches/memory/Memory.java | 2 +- .../apache/datasketches/memory/WritableMemory.java | 8 ++-- .../memory/internal/BaseStateImpl.java | 16 ++++---- .../memory/internal/BaseWritableMemoryImpl.java | 2 +- .../AllocateDirectWritableMapMemoryTest.java | 6 +-- .../memory/internal/BufferInvariantsTest.java | 1 - tools/MemoryCheckstyle.xml | 35 ++++++++++++----- 9 files changed, 88 insertions(+), 49 deletions(-) diff --git a/.github/workflows/auto-jdk-matrix.yml b/.github/workflows/auto-jdk-matrix.yml index ed8668b..e14da4b 100644 --- a/.github/workflows/auto-jdk-matrix.yml +++ b/.github/workflows/auto-jdk-matrix.yml @@ -7,64 +7,64 @@ on: workflow_dispatch: env: - MAVEN_OPTS: -Xmx4g -Xms1g + MAVEN_OPTS: -Xmx1g -Xms1g jobs: build: name: Build, Test, Install runs-on: ubuntu-latest + strategy: fail-fast: false - matrix: - jdk: [ 8,11 ] + env: - JDK_VERSION: ${{ matrix.jdk }} + JDK_VERSION: 17 steps: - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" - uses: actions/[email protected] + uses: actions/checkout@v4 with: persist-credentials: false + - name: Print Current workflow + run: > + cat .github/workflows/auto-jdk-matrix.yml + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-package: jdk + architecture: x64 + java-version: 17 + - name: Cache local Maven repository - uses: actions/[email protected] + uses: actions/cache@v4 with: path: ~/.m2/repository key: build-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: build-${{ runner.os }}-maven- - - name: Install Matrix JDK - uses: actions/[email protected] - with: - java-version: | - 8 - 11 - distribution: 'temurin' - java-package: jdk - architecture: x64 -# Architecture options: x86, x64, armv7, aarch64, ppc64le -# setup-java@v3 has a "with cache" option - - name: Echo Java Version run: > java -version - name: Test run: > - mvn clean test -B -X + mvn clean test -B -Dmaven.javadoc.skip=true -Dgpg.skip=true - name: Install run: > - mvn clean install -B -X + mvn clean install -B -DskipTests=true -Dgpg.skip=true # Architecture options: x86, x64, armv7, aarch64, ppc64le -# setup-java@v3 has a "with cache" option +# setup-java@v4 has a "with cache" option # Lifecycle: validate, compile, test, package, verify, install, deploy -# -B batch mode +# -B batch mode, never stops for user input # -V show Version without stopping # -X debug mode # -q quiet, only show errors diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml new file mode 100644 index 0000000..3e54f3e --- /dev/null +++ b/.github/workflows/javadoc.yml @@ -0,0 +1,23 @@ +name: JavaDoc + +on: + push: + branches: + - 2.2.X + workflow_dispatch: + +jobs: + javadoc: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Generate JavaDoc + run: mvn javadoc:javadoc + - name: Deploy JavaDoc + uses: JamesIves/github-pages-deploy-action@5dc1d5a192aeb5ab5b7d5a77b7d36aea4a7f5c92 + with: + token: ${{ secrets.GITHUB_TOKEN }} + folder: datasketches-memory-java8/target/site/apidocs + target-folder: docs/${{ github.ref_name }} + branch: gh-pages diff --git a/src/main/java/org/apache/datasketches/memory/Memory.java b/src/main/java/org/apache/datasketches/memory/Memory.java index 389732c..a9a94dd 100644 --- a/src/main/java/org/apache/datasketches/memory/Memory.java +++ b/src/main/java/org/apache/datasketches/memory/Memory.java @@ -103,7 +103,7 @@ public interface Memory extends BaseState { */ static Memory map(File file, long fileOffsetBytes, long capacityBytes, ByteOrder byteOrder) throws IllegalArgumentException, IllegalStateException, IOException, SecurityException { - final ResourceScope scope = ResourceScope.newConfinedScope(); + final ResourceScope scope = ResourceScope.newConfinedScope(); return BaseWritableMemoryImpl.wrapMap(file, fileOffsetBytes, capacityBytes, scope, true, byteOrder); } diff --git a/src/main/java/org/apache/datasketches/memory/WritableMemory.java b/src/main/java/org/apache/datasketches/memory/WritableMemory.java index df2cec0..4e90865 100644 --- a/src/main/java/org/apache/datasketches/memory/WritableMemory.java +++ b/src/main/java/org/apache/datasketches/memory/WritableMemory.java @@ -101,8 +101,8 @@ public interface WritableMemory extends Memory { * required by the implementation. */ static WritableMemory writableMap(File file, long fileOffsetBytes, long capacityBytes, ByteOrder byteOrder) - throws IllegalArgumentException, IllegalStateException, IOException, SecurityException { - ResourceScope scope = ResourceScope.newConfinedScope(); + throws IllegalArgumentException, IllegalStateException, IOException, SecurityException { + final ResourceScope scope = ResourceScope.newConfinedScope(); return BaseWritableMemoryImpl.wrapMap(file, fileOffsetBytes, capacityBytes, scope, false, byteOrder); } @@ -121,7 +121,7 @@ public interface WritableMemory extends Memory { * required by the implementation. */ static WritableMemory writableMap(File file, long fileOffsetBytes, long capacityBytes, ResourceScope scope, ByteOrder byteOrder) - throws IllegalArgumentException, IllegalStateException, IOException, SecurityException { + throws IllegalArgumentException, IllegalStateException, IOException, SecurityException { return BaseWritableMemoryImpl.wrapMap(file, fileOffsetBytes, capacityBytes, scope, false, byteOrder); } @@ -161,7 +161,7 @@ public interface WritableMemory extends Memory { long alignmentBytes, ByteOrder byteOrder, MemoryRequestServer memReqSvr) { - final ResourceScope scope = ResourceScope.newConfinedScope(); + final ResourceScope scope = ResourceScope.newConfinedScope(); return BaseWritableMemoryImpl.wrapDirect(capacityBytes, alignmentBytes, scope, byteOrder, memReqSvr); } diff --git a/src/main/java/org/apache/datasketches/memory/internal/BaseStateImpl.java b/src/main/java/org/apache/datasketches/memory/internal/BaseStateImpl.java index 9523619..4f9eef2 100644 --- a/src/main/java/org/apache/datasketches/memory/internal/BaseStateImpl.java +++ b/src/main/java/org/apache/datasketches/memory/internal/BaseStateImpl.java @@ -130,7 +130,7 @@ abstract class BaseStateImpl implements BaseState { p0 = Integer.parseInt(parts[0]); //the first number group p1 = (parts.length > 1) ? Integer.parseInt(parts[1]) : 0; //2nd number group, or 0 } catch (final NumberFormatException | ArrayIndexOutOfBoundsException e) { - throw new IllegalArgumentException("Improper Java -version string: " + jdkVer + "\n" + e); + throw new IllegalArgumentException("Improper Java -version string: " + jdkVer + LS + e); } checkJavaVersion(jdkVer, p0); return new int[] {p0, p1}; @@ -320,7 +320,7 @@ abstract class BaseStateImpl implements BaseState { @Override public Thread getOwnerThread() { - return seg.scope().ownerThread(); + return seg.scope().ownerThread(); } @Override @@ -390,9 +390,9 @@ abstract class BaseStateImpl implements BaseState { } @Override - public final boolean isSameResource(BaseState that) { - BaseStateImpl that2 = (BaseStateImpl) that; - return this.seg.address().equals(that2.seg.address()); + public final boolean isSameResource(final BaseState that) { + final BaseStateImpl that2 = (BaseStateImpl) that; + return this.seg.address().equals(that2.seg.address()); } @Override @@ -402,7 +402,7 @@ abstract class BaseStateImpl implements BaseState { public long mismatch(final BaseState that) { Objects.requireNonNull(that); if (!that.isAlive()) { throw new IllegalArgumentException("Given argument is not alive."); } - BaseStateImpl thatBSI = (BaseStateImpl) that; + final BaseStateImpl thatBSI = (BaseStateImpl) that; return seg.mismatch(thatBSI.seg); } @@ -410,7 +410,7 @@ abstract class BaseStateImpl implements BaseState { public final long nativeOverlap(final BaseState that) { if (that == null) { return 0; } if (!that.isAlive()) { return 0; } - BaseStateImpl thatBSI = (BaseStateImpl) that; + final BaseStateImpl thatBSI = (BaseStateImpl) that; if (this == thatBSI) { return seg.byteSize(); } return nativeOverlap(seg, thatBSI.seg); } @@ -447,7 +447,7 @@ abstract class BaseStateImpl implements BaseState { : biggerSmaller(lB, rB, lA, rA); //B bigger than A, reverse parameters } - private static final long biggerSmaller(long lLarge, long rLarge, long lSmall, long rSmall) { + private static final long biggerSmaller(final long lLarge, final long rLarge, final long lSmall, final long rSmall) { if ((rSmall <= rLarge) && (lLarge <= lSmall)) { return rSmall - lSmall; } //Small is totally within Large return (rLarge < rSmall) ? rLarge - lSmall //Partial overlap on right portion of Large diff --git a/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java b/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java index 82f89f3..885d343 100644 --- a/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java +++ b/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java @@ -390,7 +390,7 @@ public abstract class BaseWritableMemoryImpl extends BaseStateImpl implements Wr @Override public final byte[] getArray() { - return seg.toByteArray(); + return seg.toByteArray(); } @Override diff --git a/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java b/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java index 14dee0b..f4744c2 100644 --- a/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java +++ b/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java @@ -82,14 +82,14 @@ public class AllocateDirectWritableMapMemoryTest { java.nio.file.Files.delete(file.toPath()); } assertTrue(file.createNewFile()); - assertTrue (file.setWritable(true, false)); //writable=true, ownerOnly=false - assertTrue (file.isFile()); + assertTrue(file.setWritable(true, false)); //writable=true, ownerOnly=false + assertTrue(file.isFile()); file.deleteOnExit(); //comment out if you want to examine the file. WritableMemory dstMem = null; WritableMemory srcMem = null; try (ResourceScope scope = ResourceScope.newConfinedScope()) { //this scope manages two Memory objects - dstMem = WritableMemory.writableMap(file, 0, numBytes, scope, ByteOrder.nativeOrder()); + dstMem = WritableMemory.writableMap(file, 0, numBytes, scope, ByteOrder.nativeOrder()); srcMem = WritableMemory.allocateDirect(numBytes, 8, scope, ByteOrder.nativeOrder(), memReqSvr); //load source with consecutive longs diff --git a/src/test/java/org/apache/datasketches/memory/internal/BufferInvariantsTest.java b/src/test/java/org/apache/datasketches/memory/internal/BufferInvariantsTest.java index 091bf35..addb7d9 100644 --- a/src/test/java/org/apache/datasketches/memory/internal/BufferInvariantsTest.java +++ b/src/test/java/org/apache/datasketches/memory/internal/BufferInvariantsTest.java @@ -307,7 +307,6 @@ public class BufferInvariantsTest { // printbuf(reg); } - static void printbb(ByteBuffer bb) { println("pos: " + bb.position() + ", lim: " + bb.limit() + ", cap: " + bb.capacity()); int rem = bb.remaining(); diff --git a/tools/MemoryCheckstyle.xml b/tools/MemoryCheckstyle.xml index 95c0988..2079041 100644 --- a/tools/MemoryCheckstyle.xml +++ b/tools/MemoryCheckstyle.xml @@ -36,15 +36,17 @@ under the License. <property name="charset" value="UTF-8"/> <property name="severity" value="warning"/> <property name="fileExtensions" value="java"/> + <property name="basedir" value="${basedir}"/> - <module name="SuppressionFilter"> - <property name="file" value="${samedir}/suppressions.xml"/> - <property name="optional" value="false"/> + <!-- Exclude all module-info.java files + https://checkstyle.org/filefilters/beforeexecutionexclusionfilefilter.html#BeforeExecutionExclusionFileFilter --> + <module name="BeforeExecutionExclusionFileFilter"> + <property name="fileNamePattern" value="module\-info\.java$"/> </module> - <!-- Exclude module-info.java files --> + <!-- Exclude all src/test/... files --> <module name="BeforeExecutionExclusionFileFilter"> - <property name="fileNamePattern" value="module\-info\.java$"/> + <property name="fileNamePattern" value=".*[\\/]src[\\/]test[\\/].*$"/> </module> <module name="FileTabCharacter"> @@ -60,7 +62,7 @@ under the License. <!-- Size Violations --> <module name="LineLength"> <property name="severity" value="warning"/> - <property name="max" value="120"/> + <property name="max" value="140"/> <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/> <!-- <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/> --> </module> @@ -74,7 +76,18 @@ under the License. <!-- ******************************************************** --> <module name="TreeWalker"> - + + <!-- Be able to ignore violations with @SuppressWarnings --> + <!-- See https://checkstyle.org/filters/suppresswarningsfilter.html --> + <module name="SuppressWarningsHolder"/> + + <!-- + <module name="SuppressionFilter"> + <property name="file" value="basedir/tools/suppressions.xml"/> + <property name="optional" value="false"/> + </module> + --> + <!-- Annotations --> <module name="AnnotationLocation"> <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/> @@ -87,7 +100,7 @@ under the License. <!-- Block Checks --> <module name="EmptyBlock"> - <property name="severity" value="warning"/> + <property name="severity" value="ignore"/> <property name="option" value="TEXT"/> <property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/> <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/> @@ -169,6 +182,11 @@ under the License. <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/> </module> + <module name="IllegalTokenText"> + <property name="tokens" value="STRING_LITERAL"/> + <property name="format" value="\\n"/> + </module> + <!-- Class Design --> <module name="OneTopLevelClass"/> @@ -241,7 +259,6 @@ under the License. <property name="severity" value="warning"/> <property name="allowEscapesForControlCharacters" value="true"/> <property name="allowByTailComment" value="true"/> - <property name="allowIfAllCharactersEscaped" value="true"/> <property name="allowNonPrintableEscapes" value="true"/> <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/> </module> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
