Skip to content

Commit 77820e4

Browse files
authored
Merge branch 'deephaven:main' into formatted-autocomplete-md
2 parents f9fd9ed + f1105da commit 77820e4

File tree

251 files changed

+6456
-3678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+6456
-3678
lines changed

.github/workflows/links.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
jobs:
1010
linkChecker:
1111
runs-on: ubuntu-latest
12+
if: ${{ github.repository_owner == 'deephaven' }}
1213
steps:
1314
- uses: actions/checkout@v4
1415

.github/workflows/nightly-check-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
- name: Slack Nightly Failure
103103
uses: slackapi/slack-github-action@v1.27.0
104104
id: slack-nightly-failure
105-
if: ${{ failure() && github.repository_owner == 'deephaven' }}
105+
if: ${{ failure() && github.repository_owner == 'deephaven' && github.ref == 'refs/heads/main' }}
106106
with:
107107
payload: |
108108
{

.lycheeignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
http://localhost:
2+
https://localhost:
23
https://docs.deephaven.io/
34
https://10.0.1.50:8123/iris/connection.json
45
https://deephaven.io/core/release/vX.Y.Z/javadoc

Base/gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
io.deephaven.project.ProjectType=JAVA_PUBLIC
2+
languageLevel=8

Base/src/main/java/io/deephaven/base/FileUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public static URI convertToURI(final String source, final boolean isDirectory) {
282282
return convertToURI(new File(uri), isDirectory);
283283
}
284284
String path = uri.getPath();
285-
final boolean endsWithSlash = path.charAt(path.length() - 1) == URI_SEPARATOR_CHAR;
285+
final boolean endsWithSlash = !path.isEmpty() && path.charAt(path.length() - 1) == URI_SEPARATOR_CHAR;
286286
if (!isDirectory && endsWithSlash) {
287287
throw new IllegalArgumentException("Non-directory URI should not end with a slash: " + uri);
288288
}

Stats/src/main/java/io/deephaven/stats/util/OSUtil.java Base/src/main/java/io/deephaven/base/OSUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
33
//
4-
package io.deephaven.stats.util;
4+
package io.deephaven.base;
55

66
import org.jetbrains.annotations.NotNull;
77

Base/src/main/java/io/deephaven/base/ringbuffer/AggregatingByteRingBuffer.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,16 @@ public void clear() {
434434
final long prevHead = internalBuffer.head;
435435
final int prevSize = size();
436436

437-
internalBuffer.clear();
437+
// Reset the pointers in the ring buffer without clearing the storage array. This leaves existing `identityVal`
438+
// entries in place for the next `evaluate()` call.
439+
internalBuffer.head = internalBuffer.tail = 0;
438440

439441
calcHead = calcTail = 0;
440-
// Reset the cleared storage entries to the identity value
442+
443+
// Reset the previously populated storage entries to the identity value. After this call, all entries in the
444+
// storage buffer are `identityVal`
441445
fillWithIdentityVal(prevHead, prevSize);
446+
442447
// Reset the tree buffer with the identity value
443448
Arrays.fill(treeStorage, identityVal);
444449
}

Base/src/main/java/io/deephaven/base/ringbuffer/AggregatingCharRingBuffer.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,16 @@ public void clear() {
430430
final long prevHead = internalBuffer.head;
431431
final int prevSize = size();
432432

433-
internalBuffer.clear();
433+
// Reset the pointers in the ring buffer without clearing the storage array. This leaves existing `identityVal`
434+
// entries in place for the next `evaluate()` call.
435+
internalBuffer.head = internalBuffer.tail = 0;
434436

435437
calcHead = calcTail = 0;
436-
// Reset the cleared storage entries to the identity value
438+
439+
// Reset the previously populated storage entries to the identity value. After this call, all entries in the
440+
// storage buffer are `identityVal`
437441
fillWithIdentityVal(prevHead, prevSize);
442+
438443
// Reset the tree buffer with the identity value
439444
Arrays.fill(treeStorage, identityVal);
440445
}

Base/src/main/java/io/deephaven/base/ringbuffer/AggregatingDoubleRingBuffer.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,16 @@ public void clear() {
434434
final long prevHead = internalBuffer.head;
435435
final int prevSize = size();
436436

437-
internalBuffer.clear();
437+
// Reset the pointers in the ring buffer without clearing the storage array. This leaves existing `identityVal`
438+
// entries in place for the next `evaluate()` call.
439+
internalBuffer.head = internalBuffer.tail = 0;
438440

439441
calcHead = calcTail = 0;
440-
// Reset the cleared storage entries to the identity value
442+
443+
// Reset the previously populated storage entries to the identity value. After this call, all entries in the
444+
// storage buffer are `identityVal`
441445
fillWithIdentityVal(prevHead, prevSize);
446+
442447
// Reset the tree buffer with the identity value
443448
Arrays.fill(treeStorage, identityVal);
444449
}

Base/src/main/java/io/deephaven/base/ringbuffer/AggregatingFloatRingBuffer.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,16 @@ public void clear() {
434434
final long prevHead = internalBuffer.head;
435435
final int prevSize = size();
436436

437-
internalBuffer.clear();
437+
// Reset the pointers in the ring buffer without clearing the storage array. This leaves existing `identityVal`
438+
// entries in place for the next `evaluate()` call.
439+
internalBuffer.head = internalBuffer.tail = 0;
438440

439441
calcHead = calcTail = 0;
440-
// Reset the cleared storage entries to the identity value
442+
443+
// Reset the previously populated storage entries to the identity value. After this call, all entries in the
444+
// storage buffer are `identityVal`
441445
fillWithIdentityVal(prevHead, prevSize);
446+
442447
// Reset the tree buffer with the identity value
443448
Arrays.fill(treeStorage, identityVal);
444449
}

Base/src/main/java/io/deephaven/base/ringbuffer/AggregatingIntRingBuffer.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,16 @@ public void clear() {
434434
final long prevHead = internalBuffer.head;
435435
final int prevSize = size();
436436

437-
internalBuffer.clear();
437+
// Reset the pointers in the ring buffer without clearing the storage array. This leaves existing `identityVal`
438+
// entries in place for the next `evaluate()` call.
439+
internalBuffer.head = internalBuffer.tail = 0;
438440

439441
calcHead = calcTail = 0;
440-
// Reset the cleared storage entries to the identity value
442+
443+
// Reset the previously populated storage entries to the identity value. After this call, all entries in the
444+
// storage buffer are `identityVal`
441445
fillWithIdentityVal(prevHead, prevSize);
446+
442447
// Reset the tree buffer with the identity value
443448
Arrays.fill(treeStorage, identityVal);
444449
}

Base/src/main/java/io/deephaven/base/ringbuffer/AggregatingLongRingBuffer.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,16 @@ public void clear() {
434434
final long prevHead = internalBuffer.head;
435435
final int prevSize = size();
436436

437-
internalBuffer.clear();
437+
// Reset the pointers in the ring buffer without clearing the storage array. This leaves existing `identityVal`
438+
// entries in place for the next `evaluate()` call.
439+
internalBuffer.head = internalBuffer.tail = 0;
438440

439441
calcHead = calcTail = 0;
440-
// Reset the cleared storage entries to the identity value
442+
443+
// Reset the previously populated storage entries to the identity value. After this call, all entries in the
444+
// storage buffer are `identityVal`
441445
fillWithIdentityVal(prevHead, prevSize);
446+
442447
// Reset the tree buffer with the identity value
443448
Arrays.fill(treeStorage, identityVal);
444449
}

Base/src/main/java/io/deephaven/base/ringbuffer/AggregatingObjectRingBuffer.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,16 @@ public void clear() {
434434
final long prevHead = internalBuffer.head;
435435
final int prevSize = size();
436436

437-
internalBuffer.clear();
437+
// Reset the pointers in the ring buffer without clearing the storage array. This leaves existing `identityVal`
438+
// entries in place for the next `evaluate()` call.
439+
internalBuffer.head = internalBuffer.tail = 0;
438440

439441
calcHead = calcTail = 0;
440-
// Reset the cleared storage entries to the identity value
442+
443+
// Reset the previously populated storage entries to the identity value. After this call, all entries in the
444+
// storage buffer are `identityVal`
441445
fillWithIdentityVal(prevHead, prevSize);
446+
442447
// Reset the tree buffer with the identity value
443448
Arrays.fill(treeStorage, identityVal);
444449
}

Base/src/main/java/io/deephaven/base/ringbuffer/AggregatingShortRingBuffer.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,16 @@ public void clear() {
434434
final long prevHead = internalBuffer.head;
435435
final int prevSize = size();
436436

437-
internalBuffer.clear();
437+
// Reset the pointers in the ring buffer without clearing the storage array. This leaves existing `identityVal`
438+
// entries in place for the next `evaluate()` call.
439+
internalBuffer.head = internalBuffer.tail = 0;
438440

439441
calcHead = calcTail = 0;
440-
// Reset the cleared storage entries to the identity value
442+
443+
// Reset the previously populated storage entries to the identity value. After this call, all entries in the
444+
// storage buffer are `identityVal`
441445
fillWithIdentityVal(prevHead, prevSize);
446+
442447
// Reset the tree buffer with the identity value
443448
Arrays.fill(treeStorage, identityVal);
444449
}

Base/src/main/java/io/deephaven/base/ringbuffer/ByteRingBuffer.java

+35-15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import io.deephaven.base.MathUtil;
1111
import io.deephaven.base.verify.Assert;
12+
import org.jetbrains.annotations.TestOnly;
1213

1314
import java.io.Serializable;
1415
import java.util.NoSuchElementException;
@@ -19,7 +20,7 @@
1920
* {@code long} values. Head and tail will not wrap around; instead we use storage arrays sized to 2^N to allow fast
2021
* determination of storage indices through a mask operation.
2122
*/
22-
public class ByteRingBuffer implements Serializable {
23+
public class ByteRingBuffer implements RingBuffer, Serializable {
2324
static final long FIXUP_THRESHOLD = 1L << 62;
2425
final boolean growable;
2526
byte[] storage;
@@ -32,7 +33,7 @@ public class ByteRingBuffer implements Serializable {
3233
*
3334
* @param capacity minimum capacity of the ring buffer
3435
*/
35-
public ByteRingBuffer(int capacity) {
36+
public ByteRingBuffer(final int capacity) {
3637
this(capacity, true);
3738
}
3839

@@ -42,7 +43,7 @@ public ByteRingBuffer(int capacity) {
4243
* @param capacity minimum capacity of ring buffer
4344
* @param growable whether to allow growth when the buffer is full.
4445
*/
45-
public ByteRingBuffer(int capacity, boolean growable) {
46+
public ByteRingBuffer(final int capacity, final boolean growable) {
4647
Assert.leq(capacity, "ByteRingBuffer capacity", MathUtil.MAX_POWER_OF_2);
4748

4849
this.growable = growable;
@@ -59,7 +60,7 @@ public ByteRingBuffer(int capacity, boolean growable) {
5960
*
6061
* @param increase Increase amount. The ring buffer's capacity will be increased by at least this amount.
6162
*/
62-
protected void grow(int increase) {
63+
protected void grow(final int increase) {
6364
final int size = size();
6465
final long newCapacity = (long) storage.length + increase;
6566
// assert that we are not asking for the impossible
@@ -83,7 +84,7 @@ protected void grow(int increase) {
8384
*
8485
* @param dest The destination buffer.
8586
*/
86-
protected void copyRingBufferToArray(byte[] dest) {
87+
protected void copyRingBufferToArray(final byte[] dest) {
8788
final int size = size();
8889
final int storageHead = (int) (head & mask);
8990

@@ -99,27 +100,35 @@ protected void copyRingBufferToArray(byte[] dest) {
99100
System.arraycopy(storage, 0, dest, firstCopyLen, secondCopyLen);
100101
}
101102

103+
@Override
102104
public boolean isFull() {
103105
return size() == storage.length;
104106
}
105107

108+
@Override
106109
public boolean isEmpty() {
107110
return tail == head;
108111
}
109112

113+
@Override
110114
public int size() {
111115
return Math.toIntExact(tail - head);
112116
}
113117

118+
@Override
114119
public int capacity() {
115120
return storage.length;
116121
}
117122

123+
@Override
118124
public int remaining() {
119125
return storage.length - size();
120126
}
121127

128+
@Override
122129
public void clear() {
130+
// region object-bulk-clear
131+
// endregion object-bulk-clear
123132
tail = head = 0;
124133
}
125134

@@ -131,7 +140,7 @@ public void clear() {
131140
* @throws UnsupportedOperationException when {@code growable} is {@code false} and buffer is full
132141
* @return {@code true} if the byte was added successfully
133142
*/
134-
public boolean add(byte e) {
143+
public boolean add(final byte e) {
135144
if (isFull()) {
136145
if (!growable) {
137146
throw new UnsupportedOperationException("Ring buffer is full and growth is disabled");
@@ -151,7 +160,8 @@ public boolean add(byte e) {
151160
* @param count the minimum number of empty entries in the buffer after this call
152161
* @throws UnsupportedOperationException when {@code growable} is {@code false} and buffer is full
153162
*/
154-
public void ensureRemaining(int count) {
163+
@Override
164+
public void ensureRemaining(final int count) {
155165
if (remaining() < count) {
156166
if (!growable) {
157167
throw new UnsupportedOperationException("Ring buffer is full and growth is disabled");
@@ -168,7 +178,7 @@ public void ensureRemaining(int count) {
168178
*
169179
* @param e the value to add to the buffer
170180
*/
171-
public void addUnsafe(byte e) {
181+
public void addUnsafe(final byte e) {
172182
// This is an extremely paranoid wrap check that in all likelihood will never run. With FIXUP_THRESHOLD at
173183
// 1 << 62, and the user pushing 2^32 values per second(!), it will take 68 years to wrap this counter .
174184
if (tail >= FIXUP_THRESHOLD) {
@@ -188,7 +198,7 @@ public void addUnsafe(byte e) {
188198
* @param notFullResult value to return is the buffer is not full
189199
* @return the overwritten entry if the buffer is full, the provided value otherwise
190200
*/
191-
public byte addOverwrite(byte e, byte notFullResult) {
201+
public byte addOverwrite(final byte e, final byte notFullResult) {
192202
byte val = notFullResult;
193203
if (isFull()) {
194204
val = remove();
@@ -204,7 +214,7 @@ public byte addOverwrite(byte e, byte notFullResult) {
204214
* @param e the byte to be added to the buffer
205215
* @return true if the value was added successfully, false otherwise
206216
*/
207-
public boolean offer(byte e) {
217+
public boolean offer(final byte e) {
208218
if (isFull()) {
209219
return false;
210220
}
@@ -218,7 +228,7 @@ public boolean offer(byte e) {
218228
* @param count The number of elements to remove.
219229
* @throws NoSuchElementException if the buffer is empty
220230
*/
221-
public byte[] remove(int count) {
231+
public byte[] remove(final int count) {
222232
final int size = size();
223233
if (size < count) {
224234
throw new NoSuchElementException();
@@ -264,7 +274,7 @@ public byte removeUnsafe() {
264274
* @param onEmpty the value to return if the ring buffer is empty
265275
* @return The removed element if the ring buffer was non-empty, otherwise the value of 'onEmpty'
266276
*/
267-
public byte poll(byte onEmpty) {
277+
public byte poll(final byte onEmpty) {
268278
if (isEmpty()) {
269279
return onEmpty;
270280
}
@@ -291,7 +301,7 @@ public byte element() {
291301
* @param onEmpty the value to return if the ring buffer is empty
292302
* @return The head element if the ring buffer is non-empty, otherwise the value of 'onEmpty'
293303
*/
294-
public byte peek(byte onEmpty) {
304+
public byte peek(final byte onEmpty) {
295305
if (isEmpty()) {
296306
return onEmpty;
297307
}
@@ -314,7 +324,7 @@ public byte front() {
314324
* @throws NoSuchElementException if the buffer is empty
315325
* @return The element at the specified offset
316326
*/
317-
public byte front(int offset) {
327+
public byte front(final int offset) {
318328
if (offset < 0 || offset >= size()) {
319329
throw new NoSuchElementException();
320330
}
@@ -341,7 +351,7 @@ public byte back() {
341351
* @param onEmpty the value to return if the ring buffer is empty
342352
* @return The tail element if the ring buffer is non-empty, otherwise the value of 'onEmpty'
343353
*/
344-
public byte peekBack(byte onEmpty) {
354+
public byte peekBack(final byte onEmpty) {
345355
if (isEmpty()) {
346356
return onEmpty;
347357
}
@@ -385,4 +395,14 @@ public void remove() {
385395
throw new UnsupportedOperationException();
386396
}
387397
}
398+
399+
/**
400+
* Get the storage array for this ring buffer. This is intended for testing and debugging purposes only.
401+
*
402+
* @return The storage array for this ring buffer.
403+
*/
404+
@TestOnly
405+
public byte[] getStorage() {
406+
return storage;
407+
}
388408
}

0 commit comments

Comments
 (0)