Skip to content

Commit

Permalink
Merge branch 'master' of github.com:BoiseState/CS321_Bioinformatics
Browse files Browse the repository at this point in the history
  • Loading branch information
boiseamit committed Oct 10, 2023
2 parents a3a8ec7 + e6af465 commit 1970aeb
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 44 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
# - Java 17 (LTS; officially supported since Gradle 7.3)
# - Java 18 (deprecated; officially supported since Gradle 7.5)
# - Java 19 (deprecated; officially supported since Gradle 7.6)
# - Java 20 (current; will be deprecated in September 2023; officially supported since Gradle 8.1)
# - Java 21 (LTS; to be released in September 2023; not officially supported by Gradle)
# - Java 20 (deprecated; officially supported since Gradle 8.1)
# - Java 21 (current; LTS; officially supported since Gradle 8.4)
# - Java 22 (to be released in March 2024; not officially supported by Gradle)
# - Java 23 (to be released in September 2024; not officially supported by Gradle)
name: CS321 Bioinformatics CI with Gradle

on:
Expand All @@ -26,17 +28,17 @@ jobs:

strategy:
matrix:
java: [ '8', '11', '15', '16', '17', '18', '19', '20' ]
java: [ '8', '11', '15', '16', '17', '18', '19', '20', '21' ]
name: Java version ${{ matrix.Java }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.Java }}
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
# the distribution can be either 'adopt' or 'zulu'
distribution: 'adopt'
distribution: 'zulu'
- name: Grant execute permission for gradlew
run: chmod +x gradlew

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ Use the following command to check our installed JDK version:
$ javac -version
```

This project **does not work** with JDK 21.
This project **does not work** with JDK 22.

It is recommended to use either JDK 8, JDK 11 or JDK 17 or JDK 19 or 20.
It is recommended to use any of the following versions:
- JDK 8 (LTS)
- JDK 11 (LTS)
- JDK 17 (LTS)
- JDK 21 (LTS)

:book: See this [wiki page for additional details regarding the supported Java versions and links to download the correct JDK versions](https://github.com/BoiseState/CS321_Bioinformatics/wiki/Install-the-correct-JDK-version).

Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ plugins {
group 'cs321'
version '1.0'

sourceCompatibility = 1.8
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}

repositories {
mavenCentral()
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 6 additions & 5 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -144,15 +141,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
62 changes: 33 additions & 29 deletions src/test/java/cs321/btree/BTreeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ public void testInsertTenDuplicates() throws BTreeException, IOException {

assertEquals(1, b.getSize());
assertEquals(0, b.getHeight());
assertTrue(validateSearchTreeProperty(b));

assertTrue(validateBTreeInserts(b, new long[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}));
}


Expand All @@ -220,13 +221,17 @@ public void testInsertTenThousandObjects() throws BTreeException, IOException {

BTree b = new BTree(2, testFilename);

long[] input = new long[10000];

for (int i = 0; i < 10000; i++) {
input[i] = i;
b.insert(new TreeObject(i));
}

assertEquals(10000, b.getSize());
assertEquals(12, b.getHeight());
assertTrue(validateSearchTreeProperty(b));

assertTrue(validateBTreeInserts(b, input));
}

/**
Expand All @@ -242,24 +247,24 @@ public void testCLRSExample18_6() throws BTreeException, IOException {

BTree b = new BTree(4, testFilename);

b.insert(new TreeObject(1)); //A
b.insert(new TreeObject(4)); //D
b.insert(new TreeObject(6)); //F
b.insert(new TreeObject(8)); //H
b.insert(new TreeObject(12)); //L
b.insert(new TreeObject(14)); //N
b.insert(new TreeObject(16)); //P
// A D F H L N P B
long[] input = new long[]{1, 4, 6, 8, 12, 14, 16, 2};

for (int i = 0; i < input.length - 1; i++) {
b.insert(new TreeObject(input[i]));
}

assertEquals(7, b.getSize());
assertEquals(0, b.getHeight());
assertEquals(1, b.getNumberOfNodes());

b.insert(new TreeObject(2)); //Insert 'B'
b.insert(new TreeObject(input[7])); //Insert 'B'

assertEquals(8, b.getSize());
assertEquals(1, b.getHeight());
assertEquals(3, b.getNumberOfNodes());
assertTrue(validateSearchTreeProperty(b));

assertTrue(validateBTreeInserts(b, input));
}

/**
Expand Down Expand Up @@ -401,22 +406,21 @@ public void testInsertToNotLeaf() throws BTreeException, IOException {

BTree b = new BTree(4, testFilename);

b.insert(new TreeObject(1)); //A
b.insert(new TreeObject(4)); //D
b.insert(new TreeObject(6)); //F
b.insert(new TreeObject(8)); //H
b.insert(new TreeObject(12)); //L
b.insert(new TreeObject(14)); //N
b.insert(new TreeObject(16)); //P
b.insert(new TreeObject(2)); //B
// A D F H L N P B H
long[] input = new long[]{1, 4, 6, 8, 12, 14, 16, 2, 8};

for (int i = 0; i < input.length - 1; i++) {
b.insert(new TreeObject(input[i]));
}

//by inserting a duplicate into a non leaf node, another branch is tested.
b.insert(new TreeObject(8)); //H
b.insert(new TreeObject(input[8])); //H

TreeObject obj = b.search(8);

assertEquals(2, obj.getCount());
assertTrue(validateSearchTreeProperty(b));

assertTrue(validateBTreeInserts(b, input));
}


Expand All @@ -426,8 +430,8 @@ public void testInsertToNotLeaf() throws BTreeException, IOException {
* a full child.
* Assertion is that key 'H' (8) has been counted twice in a search
*
* @throws BTreeException
* @throws IOException
* @throws BTreeException Exception thrown when BTree encounters an unexpected problem
* @throws IOException Exception thrown when testing fails due to IO errors
*/
@Test
public void testInsertToNotLeafFullChild() throws BTreeException, IOException {
Expand All @@ -437,14 +441,14 @@ public void testInsertToNotLeafFullChild() throws BTreeException, IOException {
// A D F H L H
long[] input = new long[]{1, 4, 6, 8, 12, 8};

for (int i = 0; i < input.length; i++) {
b.insert(new TreeObject(input[i]));
for (long l : input) {
b.insert(new TreeObject(l));
}

TreeObject obj = b.search(8);

assertEquals(2, obj.getCount());
assertTrue(validateSearchTreeProperty(b));

assertTrue(validateBTreeInserts(b, input));
}

Expand All @@ -457,7 +461,7 @@ public void testInsertToNotLeafFullChild() throws BTreeException, IOException {
* @return true if there are no keys in the BTree, or if the keys are indeed in sorted order.
*
*/
private boolean validateSearchTreeProperty(BTree b) {
private boolean validateSearchTreeProperty(BTree b) throws IOException {

long[] keys = b.getSortedKeyArray();

Expand Down Expand Up @@ -492,7 +496,7 @@ private boolean validateSearchTreeProperty(BTree b) {
*
* @return true if BTree in order traversal matches provide input
*/
private boolean validateBTreeInserts(BTree b, long[] inputKeys) {
private boolean validateBTreeInserts(BTree b, long[] inputKeys) throws IOException {

long[] bTreeKeys = b.getSortedKeyArray();

Expand Down Expand Up @@ -522,7 +526,7 @@ private boolean validateBTreeInserts(BTree b, long[] inputKeys) {

long prev = bTreeKeys[0];

for (int i = 0; i < inputKeys.length; i++) {
for (int i = 0; i < bTreeKeys.length; i++) {
if (bTreeKeys[i] != inputNoDuplicates.get(i)) {
return false;
}
Expand Down

0 comments on commit 1970aeb

Please sign in to comment.