Skip to content

Commit

Permalink
Merge branch 'main' into sm-parallel-snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
malhotrashivam committed Jul 9, 2024
2 parents 036dd6d + a301587 commit e314806
Show file tree
Hide file tree
Showing 611 changed files with 31,556 additions and 4,246 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@ updates:
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "chore(github-actions)"
labels:
- "NoDocumentationNeeded"
- "NoReleaseNotesNeeded"
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "chore(gradle)"
labels:
- "NoDocumentationNeeded"
- "NoReleaseNotesNeeded"
6 changes: 3 additions & 3 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
# https://github.com/docker/buildx/pull/535
- name: Docker build server
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
build-args: |
BASE=deephaven/server-base:local-build
Expand All @@ -116,7 +116,7 @@ jobs:

# Note: server-slim does not need BASE/SERVER build-args like the other server images
- name: Docker build server slim
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
build-args: |
DEEPHAVEN_VERSION=${{ steps.deephaven_version.outputs.deephaven_version }}
Expand Down Expand Up @@ -194,7 +194,7 @@ jobs:
echo "deephaven_version=$(cat build/version)" >> $GITHUB_OUTPUT
- name: Docker build
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
build-args: |
DEEPHAVEN_VERSION=${{ steps.deephaven_version.outputs.deephaven_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Check CI

on:
pull_request:
branches: [ main ]
branches: [ 'main', 'rc/v*' ]
push:
branches: [ 'main', 'check/**', 'release/v*' ]

Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/conventional-pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Conventional PR'

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
pr-check:
runs-on: ubuntu-22.04
steps:
- uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Pull Request titles must follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
Breaking changes that are expected to impact users must include "BREAKING CHANGE: <description>" at the end of the PR description.
Details:
```
${{ steps.lint_pr_title.outputs.error_message }}
```
# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true
1 change: 1 addition & 0 deletions .github/workflows/create-docs-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request_target:
branches:
- main
- 'rc/v*'
types:
- closed

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Docs CI

on:
pull_request:
branches: [ main ]
branches: [ 'main', 'rc/v*' ]
push:
branches: [ 'main', 'release/v*' ]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-check-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
# effect the labels because the merge requirements need checks to pass against the most recent
# commit.
types: [ opened, synchronize, reopened, labeled, unlabeled ]
branches: [ main ]
branches: [ 'main', 'rc/v*' ]

jobs:
doc-labels:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ 'main', 'release/v*' ]
pull_request:
branches: [ main ]
branches: [ 'main', 'rc/v*' ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quick-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Quick CI

on:
pull_request:
branches: [ main ]
branches: [ 'main', 'rc/v*' ]
push:
branches: [ 'main', 'check/**', 'release/v*' ]

Expand Down
11 changes: 6 additions & 5 deletions Base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ dependencies {

api project(':clock')

implementation depTrove3
compileOnlyApi depAnnotations
implementation depCommonsLang3
implementation libs.trove
compileOnlyApi libs.jetbrains.annotations
implementation libs.commons.lang3

api 'io.deephaven:hash:0.1.0'

Classpaths.inheritJUnitClassic(project, 'testImplementation')
Classpaths.inheritJMock(project, 'testImplementation')
testImplementation libs.junit4
testImplementation libs.jmock.junit4
testImplementation libs.jmock.imposters
testImplementation project(":base-test-utils")
}

Expand Down
37 changes: 37 additions & 0 deletions Base/src/main/java/io/deephaven/base/MathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
*/
public class MathUtil {

/**
* The maximum power of 2.
*/
public static final int MAX_POWER_OF_2 = 1 << 30;

/**
* Compute ceil(log2(x)). See {@link Integer#numberOfLeadingZeros(int)}.
*
Expand Down Expand Up @@ -108,4 +113,36 @@ public static int base10digits(int n) {
}
return base10guess;
}

/**
* Rounds up to the next power of 2 for {@code x}; if {@code x} is already a power of 2, {@code x} will be returned.
* Values outside the range {@code 1 <= x <= MAX_POWER_OF_2} will return {@code 1}.
*
* <p>
* Equivalent to {@code Math.max(Integer.highestOneBit(x - 1) << 1, 1)}.
*
* @param x the value
* @return the next power of 2 for {@code x}
* @see #MAX_POWER_OF_2
*/
public static int roundUpPowerOf2(int x) {
return Math.max(Integer.highestOneBit(x - 1) << 1, 1);
}

/**
* Rounds up to the next power of 2 for {@code size <= MAX_POWER_OF_2}, otherwise returns
* {@link ArrayUtil#MAX_ARRAY_SIZE}.
*
* <p>
* Equivalent to {@code size <= MAX_POWER_OF_2 ? roundUpPowerOf2(size) : ArrayUtil.MAX_ARRAY_SIZE}.
*
* @param size the size
* @return the
* @see #MAX_POWER_OF_2
* @see #roundUpPowerOf2(int)
* @see ArrayUtil#MAX_ARRAY_SIZE
*/
public static int roundUpArraySize(int size) {
return size <= MAX_POWER_OF_2 ? roundUpPowerOf2(size) : ArrayUtil.MAX_ARRAY_SIZE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// @formatter:off
package io.deephaven.base.ringbuffer;

import io.deephaven.base.ArrayUtil;
import io.deephaven.base.MathUtil;
import io.deephaven.base.verify.Assert;

import java.io.Serializable;
Expand All @@ -20,8 +20,6 @@
* determination of storage indices through a mask operation.
*/
public class ByteRingBuffer implements Serializable {
/** Maximum capacity is the highest power of two that can be allocated (i.e. <= than ArrayUtil.MAX_ARRAY_SIZE). */
static final int RING_BUFFER_MAX_CAPACITY = Integer.highestOneBit(ArrayUtil.MAX_ARRAY_SIZE);
static final long FIXUP_THRESHOLD = 1L << 62;
final boolean growable;
byte[] storage;
Expand All @@ -45,21 +43,13 @@ public ByteRingBuffer(int capacity) {
* @param growable whether to allow growth when the buffer is full.
*/
public ByteRingBuffer(int capacity, boolean growable) {
Assert.leq(capacity, "ByteRingBuffer capacity", RING_BUFFER_MAX_CAPACITY);
Assert.leq(capacity, "ByteRingBuffer capacity", MathUtil.MAX_POWER_OF_2);

this.growable = growable;

// use next larger power of 2 for our storage
final int newCapacity;
if (capacity < 2) {
// sensibly handle the size=0 and size=1 cases
newCapacity = 1;
} else {
newCapacity = Integer.highestOneBit(capacity - 1) << 1;
}

// reset the data structure members
storage = new byte[newCapacity];
storage = new byte[MathUtil.roundUpPowerOf2(capacity)];
mask = storage.length - 1;
tail = head = 0;
}
Expand All @@ -73,9 +63,9 @@ protected void grow(int increase) {
final int size = size();
final long newCapacity = (long) storage.length + increase;
// assert that we are not asking for the impossible
Assert.leq(newCapacity, "ByteRingBuffer capacity", RING_BUFFER_MAX_CAPACITY);
Assert.leq(newCapacity, "ByteRingBuffer capacity", MathUtil.MAX_POWER_OF_2);

final byte[] newStorage = new byte[Integer.highestOneBit((int) newCapacity - 1) << 1];
final byte[] newStorage = new byte[MathUtil.roundUpPowerOf2((int) newCapacity)];

// move the current data to the new buffer
copyRingBufferToArray(newStorage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
package io.deephaven.base.ringbuffer;

import io.deephaven.base.ArrayUtil;
import io.deephaven.base.MathUtil;
import io.deephaven.base.verify.Assert;

import java.io.Serializable;
Expand All @@ -16,8 +16,6 @@
* determination of storage indices through a mask operation.
*/
public class CharRingBuffer implements Serializable {
/** Maximum capacity is the highest power of two that can be allocated (i.e. <= than ArrayUtil.MAX_ARRAY_SIZE). */
static final int RING_BUFFER_MAX_CAPACITY = Integer.highestOneBit(ArrayUtil.MAX_ARRAY_SIZE);
static final long FIXUP_THRESHOLD = 1L << 62;
final boolean growable;
char[] storage;
Expand All @@ -41,21 +39,13 @@ public CharRingBuffer(int capacity) {
* @param growable whether to allow growth when the buffer is full.
*/
public CharRingBuffer(int capacity, boolean growable) {
Assert.leq(capacity, "CharRingBuffer capacity", RING_BUFFER_MAX_CAPACITY);
Assert.leq(capacity, "CharRingBuffer capacity", MathUtil.MAX_POWER_OF_2);

this.growable = growable;

// use next larger power of 2 for our storage
final int newCapacity;
if (capacity < 2) {
// sensibly handle the size=0 and size=1 cases
newCapacity = 1;
} else {
newCapacity = Integer.highestOneBit(capacity - 1) << 1;
}

// reset the data structure members
storage = new char[newCapacity];
storage = new char[MathUtil.roundUpPowerOf2(capacity)];
mask = storage.length - 1;
tail = head = 0;
}
Expand All @@ -69,9 +59,9 @@ protected void grow(int increase) {
final int size = size();
final long newCapacity = (long) storage.length + increase;
// assert that we are not asking for the impossible
Assert.leq(newCapacity, "CharRingBuffer capacity", RING_BUFFER_MAX_CAPACITY);
Assert.leq(newCapacity, "CharRingBuffer capacity", MathUtil.MAX_POWER_OF_2);

final char[] newStorage = new char[Integer.highestOneBit((int) newCapacity - 1) << 1];
final char[] newStorage = new char[MathUtil.roundUpPowerOf2((int) newCapacity)];

// move the current data to the new buffer
copyRingBufferToArray(newStorage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// @formatter:off
package io.deephaven.base.ringbuffer;

import io.deephaven.base.ArrayUtil;
import io.deephaven.base.MathUtil;
import io.deephaven.base.verify.Assert;

import java.io.Serializable;
Expand All @@ -20,8 +20,6 @@
* determination of storage indices through a mask operation.
*/
public class DoubleRingBuffer implements Serializable {
/** Maximum capacity is the highest power of two that can be allocated (i.e. <= than ArrayUtil.MAX_ARRAY_SIZE). */
static final int RING_BUFFER_MAX_CAPACITY = Integer.highestOneBit(ArrayUtil.MAX_ARRAY_SIZE);
static final long FIXUP_THRESHOLD = 1L << 62;
final boolean growable;
double[] storage;
Expand All @@ -45,21 +43,13 @@ public DoubleRingBuffer(int capacity) {
* @param growable whether to allow growth when the buffer is full.
*/
public DoubleRingBuffer(int capacity, boolean growable) {
Assert.leq(capacity, "DoubleRingBuffer capacity", RING_BUFFER_MAX_CAPACITY);
Assert.leq(capacity, "DoubleRingBuffer capacity", MathUtil.MAX_POWER_OF_2);

this.growable = growable;

// use next larger power of 2 for our storage
final int newCapacity;
if (capacity < 2) {
// sensibly handle the size=0 and size=1 cases
newCapacity = 1;
} else {
newCapacity = Integer.highestOneBit(capacity - 1) << 1;
}

// reset the data structure members
storage = new double[newCapacity];
storage = new double[MathUtil.roundUpPowerOf2(capacity)];
mask = storage.length - 1;
tail = head = 0;
}
Expand All @@ -73,9 +63,9 @@ protected void grow(int increase) {
final int size = size();
final long newCapacity = (long) storage.length + increase;
// assert that we are not asking for the impossible
Assert.leq(newCapacity, "DoubleRingBuffer capacity", RING_BUFFER_MAX_CAPACITY);
Assert.leq(newCapacity, "DoubleRingBuffer capacity", MathUtil.MAX_POWER_OF_2);

final double[] newStorage = new double[Integer.highestOneBit((int) newCapacity - 1) << 1];
final double[] newStorage = new double[MathUtil.roundUpPowerOf2((int) newCapacity)];

// move the current data to the new buffer
copyRingBufferToArray(newStorage);
Expand Down
Loading

0 comments on commit e314806

Please sign in to comment.