This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-java-common.git
The following commit(s) were added to refs/heads/main by this push:
new 1e0219a fix pom, other logistical stuff with regard to Maven, Eclipse
setup.
1e0219a is described below
commit 1e0219a5cfd4d30769eb8076c2d00736dea7bef5
Author: Lee Rhodes <[email protected]>
AuthorDate: Wed Nov 15 17:25:19 2023 -0800
fix pom, other logistical stuff with regard to Maven, Eclipse setup.
---
pom.xml | 10 +-
.../apache/datasketches/test/ResourceFiles.java | 2 +-
.../java/org/apache/datasketches/test/Shuffle.java | 102 +++++++++++++++++++++
.../org/apache/datasketches/test/ShuffleTest.java | 80 ++++++++++++++++
4 files changed, 184 insertions(+), 10 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7c718be..b15b064 100644
--- a/pom.xml
+++ b/pom.xml
@@ -115,7 +115,7 @@ under the License.
<maven-failsafe-plugin.version>3.1.2</maven-failsafe-plugin.version>
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version> <!-- overrides
parent -->
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version> <!-- overrides
parent -->
- <maven-javadoc-plugin.version>3.3.1</maven-javadoc-plugin.version> <!--
overrides parent -->
+ <maven-javadoc-plugin.version>3.6.2</maven-javadoc-plugin.version> <!--
overrides parent -->
<maven-release-plugin.version>3.0.0-M4</maven-release-plugin.version> <!--
overrides parent -->
<maven-remote-resources-plugin.version>[1.7.0,)</maven-remote-resources-plugin.version>
<!-- overrides parent -->
<maven-source-plugin.version>3.2.1</maven-source-plugin.version> <!--
overrides parent -->
@@ -140,12 +140,6 @@ under the License.
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.datasketches</groupId>
- <artifactId>datasketches-java-common</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
@@ -283,7 +277,6 @@ under the License.
<useManifestOnlyJar>false</useManifestOnlyJar>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<reportsDirectory>${project.build.directory}/test-output/${maven.build.timestamp}</reportsDirectory>
-
<excludedGroups>${testng.generate-java-files},${testng.check-cpp-files}</excludedGroups>
</configuration>
</plugin>
@@ -680,7 +673,6 @@ under the License.
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
</argLine>
-
<excludedGroups>${testng.generate-java-files},${testng.check-cpp-files}</excludedGroups>
</configuration>
</plugin>
</plugins>
diff --git a/src/main/java/org/apache/datasketches/test/ResourceFiles.java
b/src/main/java/org/apache/datasketches/test/ResourceFiles.java
index 85f5761..a3f185a 100644
--- a/src/main/java/org/apache/datasketches/test/ResourceFiles.java
+++ b/src/main/java/org/apache/datasketches/test/ResourceFiles.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package main.java.org.apache.datasketches.test;
+package org.apache.datasketches.test;
import java.io.File;
import java.io.FileOutputStream;
diff --git a/src/main/java/org/apache/datasketches/test/Shuffle.java
b/src/main/java/org/apache/datasketches/test/Shuffle.java
new file mode 100644
index 0000000..052a663
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/test/Shuffle.java
@@ -0,0 +1,102 @@
+/*
+ * 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.test;
+
+import java.util.Random;
+
+/**
+ * @author Lee Rhodes
+ */
+public final class Shuffle {
+ private static final Random rand = new Random();
+
+ /**
+ * Shuffle the given input float array
+ * @param array input array
+ */
+ public static void shuffle(final float[] array) {
+ final int arrLen = array.length;
+ for (int i = 0; i < arrLen; i++) {
+ final int r = rand.nextInt(i + 1);
+ swap(array, i, r);
+ }
+ }
+
+ private static void swap(final float[] array, final int i1, final int i2) {
+ final float value = array[i1];
+ array[i1] = array[i2];
+ array[i2] = value;
+ }
+
+ /**
+ * Shuffle the given input double array
+ * @param array input array
+ */
+ public static void shuffle(final double[] array) {
+ final int arrLen = array.length;
+ for (int i = 0; i < arrLen; i++) {
+ final int r = rand.nextInt(i + 1);
+ swap(array, i, r);
+ }
+ }
+
+ private static void swap(final double[] array, final int i1, final int i2) {
+ final double value = array[i1];
+ array[i1] = array[i2];
+ array[i2] = value;
+ }
+
+ /**
+ * Shuffle the given input long array
+ * @param array input array
+ */
+ public static void shuffle(final long[] array) {
+ final int arrLen = array.length;
+ for (int i = 0; i < arrLen; i++) {
+ final int r = rand.nextInt(i + 1);
+ swap(array, i, r);
+ }
+ }
+
+ private static void swap(final long[] array, final int i1, final int i2) {
+ final long value = array[i1];
+ array[i1] = array[i2];
+ array[i2] = value;
+ }
+
+ /**
+ * Shuffle the given input int array
+ * @param array input array
+ */
+ public static void shuffle(final int[] array) {
+ final int arrLen = array.length;
+ for (int i = 0; i < arrLen; i++) {
+ final int r = rand.nextInt(i + 1);
+ swap(array, i, r);
+ }
+ }
+
+ private static void swap(final int[] array, final int i1, final int i2) {
+ final int value = array[i1];
+ array[i1] = array[i2];
+ array[i2] = value;
+ }
+
+}
diff --git a/src/test/java/org/apache/datasketches/test/ShuffleTest.java
b/src/test/java/org/apache/datasketches/test/ShuffleTest.java
new file mode 100644
index 0000000..fcf5473
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/test/ShuffleTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.test;
+
+import static org.testng.Assert.fail;
+
+import org.testng.annotations.Test;
+
+public class ShuffleTest {
+
+ @Test
+ public void checkFloat() {
+ float[] array = new float[10];
+ for (int i = 0; i < array.length; i++) { array[i] = i; }
+ Shuffle.shuffle(array);
+ int neCount = 0;
+ for (int i = 0; i < array.length; i++) {
+ if (array[i] != i) { neCount++; }
+ }
+ //System.out.println(neCount);
+ if (neCount == 0) { fail(); }
+ }
+
+ @Test
+ public void checkDouble() {
+ double[] array = new double[10];
+ for (int i = 0; i < array.length; i++) { array[i] = i; }
+ Shuffle.shuffle(array);
+ int neCount = 0;
+ for (int i = 0; i < array.length; i++) {
+ if (array[i] != i) { neCount++; }
+ }
+ //System.out.println(neCount);
+ if (neCount == 0) { fail(); }
+ }
+
+ @Test
+ public void checkLong() {
+ long[] array = new long[10];
+ for (int i = 0; i < array.length; i++) { array[i] = i; }
+ Shuffle.shuffle(array);
+ int neCount = 0;
+ for (int i = 0; i < array.length; i++) {
+ if (array[i] != i) { neCount++; }
+ }
+ //System.out.println(neCount);
+ if (neCount == 0) { fail(); }
+ }
+
+ @Test
+ public void checkInt() {
+ int[] array = new int[10];
+ for (int i = 0; i < array.length; i++) { array[i] = i; }
+ Shuffle.shuffle(array);
+ int neCount = 0;
+ for (int i = 0; i < array.length; i++) {
+ if (array[i] != i) { neCount++; }
+ }
+ //System.out.println(neCount);
+ if (neCount == 0) { fail(); }
+ }
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]