-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
DataIndex, particularly when used for where() filters had missing parallelization opportunities; and would read more data than strictly necessary to satisfy the filter. --------- Co-authored-by: Ryan Caudy <rcaudy@gmail.com>
- Loading branch information
Showing
22 changed files
with
775 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Base/src/main/java/io/deephaven/base/stats/ThreadSafeCounter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.base.stats; | ||
|
||
import java.util.function.LongFunction; | ||
|
||
// -------------------------------------------------------------------- | ||
|
||
/** | ||
* A statistic where each value represents an additive quantity, and thus the sum of the values <U>does</U> have | ||
* meaning. Examples include event counts and processing duration. If the sum of the values <I>does not</I> have a | ||
* useful interpretation, use {@link State} instead. | ||
* <UL> | ||
* <LI>{@link #increment} updates the counter, recording a single value. This is the most common usage. ({@link #sample} | ||
* does exactly the same thing but is a poor verb to use with a Counter.) | ||
* </UL> | ||
*/ | ||
public class ThreadSafeCounter extends ThreadSafeValue { | ||
|
||
public ThreadSafeCounter(final long now) { | ||
super(now); | ||
} | ||
|
||
public char getTypeTag() { | ||
return Counter.TYPE_TAG; | ||
} | ||
|
||
public static final LongFunction<ThreadSafeCounter> FACTORY = ThreadSafeCounter::new; | ||
} |
37 changes: 37 additions & 0 deletions
37
Base/src/main/java/io/deephaven/base/stats/ThreadSafeValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.base.stats; | ||
|
||
import io.deephaven.base.AtomicUtil; | ||
|
||
import java.util.concurrent.atomic.AtomicLongFieldUpdater; | ||
|
||
/** | ||
* A thread-safe extension of the {@link Value} class. | ||
* | ||
* <p> | ||
* The {@link #sample(long)} method is synchronized, so may introduce contention compared to the unsafe Value version of | ||
* sample. | ||
* </p> | ||
*/ | ||
public abstract class ThreadSafeValue extends Value { | ||
|
||
public ThreadSafeValue(long now) { | ||
super(now); | ||
} | ||
|
||
protected ThreadSafeValue(History history) { | ||
super(history); | ||
} | ||
|
||
@Override | ||
public synchronized void sample(final long x) { | ||
super.sample(x); | ||
} | ||
|
||
@Override | ||
public synchronized String toString() { | ||
return super.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
engine/api/src/main/java/io/deephaven/engine/table/DataIndexOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.engine.table; | ||
|
||
import io.deephaven.annotations.BuildableStyle; | ||
import io.deephaven.api.filter.Filter; | ||
import org.immutables.value.Value; | ||
|
||
/** | ||
* Options for controlling the function of a {@link DataIndex}. | ||
* | ||
*/ | ||
@Value.Immutable | ||
@BuildableStyle | ||
public interface DataIndexOptions { | ||
/** | ||
* Static default options, which expect that operations will use the full table. | ||
*/ | ||
DataIndexOptions DEFAULT = DataIndexOptions.builder().build(); | ||
|
||
/** | ||
* Static options for operations that use a partial table instead of the full table. | ||
*/ | ||
DataIndexOptions USING_PARTIAL_TABLE = DataIndexOptions.builder().operationUsesPartialTable(true).build(); | ||
|
||
/** | ||
* Does this operation use only a subset of the DataIndex? | ||
* | ||
* <p> | ||
* The DataIndex implementation may use this hint to defer work for some row sets. | ||
* </p> | ||
* | ||
* <p> | ||
* Presently, this is used for the {@link Table#where(Filter)} operation to hint that work for computing | ||
* {@link io.deephaven.engine.rowset.RowSet RowSets} for non-matching keys should be deferred. | ||
* </p> | ||
* | ||
* @return if this operation is only going to use a subset of this data index | ||
*/ | ||
@Value.Default | ||
default boolean operationUsesPartialTable() { | ||
return false; | ||
} | ||
|
||
/** | ||
* Create a new builder for a {@link DataIndexOptions}. | ||
* | ||
* @return | ||
*/ | ||
static Builder builder() { | ||
return ImmutableDataIndexOptions.builder(); | ||
} | ||
|
||
/** | ||
* The builder interface to construct a {@link DataIndexOptions}. | ||
*/ | ||
interface Builder { | ||
/** | ||
* Set whether this operation only uses a subset of the data index. | ||
* | ||
* @param usesPartialTable true if this operation only uses a partial table | ||
* @return this builder | ||
*/ | ||
Builder operationUsesPartialTable(boolean usesPartialTable); | ||
|
||
/** | ||
* Build the {@link DataIndexOptions}. | ||
* | ||
* @return an immutable DataIndexOptions structure. | ||
*/ | ||
DataIndexOptions build(); | ||
} | ||
} |
Oops, something went wrong.