Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into nightly/1997-file-h…
Browse files Browse the repository at this point in the history
…eaders
  • Loading branch information
niloc132 committed Mar 6, 2024
2 parents e498676 + b01510b commit 44659f3
Show file tree
Hide file tree
Showing 42 changed files with 1,735 additions and 500 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/create-docs-issues.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = async ({ github, context }) => {
const ISSUE_REPO_NAME = "deephaven.io";
const ISSUE_REPO_NAME = "deephaven-docs-community";
const ISSUE_TYPES = ["Community"];

const body =
Expand All @@ -15,7 +15,7 @@ module.exports = async ({ github, context }) => {
repo: ISSUE_REPO_NAME,
title: `${context.payload.pull_request.title}`,
body,
labels: [type, "documentation", "triage", "autogenerated"],
labels: ["triage", "autogenerated"],
})
);

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/Classpaths.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Classpaths {

static final String JETTY11_GROUP = 'org.eclipse.jetty'
static final String JETTY11_NAME = 'jetty-bom'
static final String JETTY11_VERSION = '11.0.19'
static final String JETTY11_VERSION = '11.0.20'

static final String GUAVA_GROUP = 'com.google.guava'
static final String GUAVA_NAME = 'guava'
Expand Down
88 changes: 80 additions & 8 deletions engine/api/src/main/java/io/deephaven/engine/table/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,56 @@ public interface Table extends
@ConcurrentMethod
Table dropColumnFormats();

/**
* Produce a new table with the specified columns renamed using the specified {@link Pair pairs}. The renames are
* simultaneous and unordered, enabling direct swaps between column names. The resulting table retains the original
* column ordering after applying the specified renames.
* <p>
* {@link IllegalArgumentException} will be thrown:
* <ul>
* <li>if a source column does not exist</li>
* <li>if a source column is used more than once</li>
* <li>if a destination column is used more than once</li>
* </ul>
*
* @param pairs The columns to rename
* @return The new table, with the columns renamed
*/
@ConcurrentMethod
Table renameColumns(Collection<Pair> pairs);

/**
* Produce a new table with the specified columns renamed using the syntax {@code "NewColumnName=OldColumnName"}.
* The renames are simultaneous and unordered, enabling direct swaps between column names. The resulting table
* retains the original column ordering after applying the specified renames.
* <p>
* {@link IllegalArgumentException} will be thrown:
* <ul>
* <li>if a source column does not exist</li>
* <li>if a source column is used more than once</li>
* <li>if a destination column is used more than once</li>
* </ul>
*
* @param pairs The columns to rename
* @return The new table, with the columns renamed
*/
@ConcurrentMethod
Table renameColumns(String... pairs);

/**
* Produce a new table with the specified columns renamed using the provided function. The renames are simultaneous
* and unordered, enabling direct swaps between column names. The resulting table retains the original column
* ordering after applying the specified renames.
* <p>
* {@link IllegalArgumentException} will be thrown:
* <ul>
* <li>if a destination column is used more than once</li>
* </ul>
*
* @param renameFunction The function to apply to each column name
* @return The new table, with the columns renamed
*/
@ConcurrentMethod
Table renameAllColumns(UnaryOperator<String> renameFunction);

@ConcurrentMethod
Expand All @@ -343,27 +389,56 @@ public interface Table extends

/**
* Produce a new table with the specified columns moved to the leftmost position. Columns can be renamed with the
* usual syntax, i.e. {@code "NewColumnName=OldColumnName")}.
* usual syntax, i.e. {@code "NewColumnName=OldColumnName")}. The renames are simultaneous and unordered, enabling
* direct swaps between column names. All other columns are left in their original order.
* <p>
* {@link IllegalArgumentException} will be thrown:
* <ul>
* <li>if a source column does not exist</li>
* <li>if a source column is used more than once</li>
* <li>if a destination column is used more than once</li>
* </ul>
*
* @param columnsToMove The columns to move to the left (and, optionally, to rename)
* @return The new table, with the columns rearranged as explained above {@link #moveColumns(int, String...)}
* @return The new table, with the columns rearranged as explained above
*/
@ConcurrentMethod
Table moveColumnsUp(String... columnsToMove);

/**
* Produce a new table with the specified columns moved to the rightmost position. Columns can be renamed with the
* usual syntax, i.e. {@code "NewColumnName=OldColumnName")}.
* usual syntax, i.e. {@code "NewColumnName=OldColumnName")}. The renames are simultaneous and unordered, enabling
* direct swaps between column names. All other columns are left in their original order.
* <p>
* {@link IllegalArgumentException} will be thrown:
* <ul>
* <li>if a source column does not exist</li>
* <li>if a source column is used more than once</li>
* <li>if a destination column is used more than once</li>
* </ul>
*
* @param columnsToMove The columns to move to the right (and, optionally, to rename)
* @return The new table, with the columns rearranged as explained above {@link #moveColumns(int, String...)}
* @return The new table, with the columns rearranged as explained above
*/
@ConcurrentMethod
Table moveColumnsDown(String... columnsToMove);

/**
* Produce a new table with the specified columns moved to the specified {@code index}. Column indices begin at 0.
* Columns can be renamed with the usual syntax, i.e. {@code "NewColumnName=OldColumnName")}.
* Columns can be renamed with the usual syntax, i.e. {@code "NewColumnName=OldColumnName")}. The renames are
* simultaneous and unordered, enabling direct swaps between column names. The resulting table retains the original
* column ordering except for the specified columns, which are inserted at the specified index, in the order of
* {@code columnsToMove}, after the effects of applying any renames.
* <p>
* {@link IllegalArgumentException} will be thrown:
* <ul>
* <li>if a source column does not exist</li>
* <li>if a source column is used more than once</li>
* <li>if a destination column is used more than once</li>
* </ul>
* <p>
* Values of {@code index} outside the range of 0 to the number of columns in the table (exclusive) will be clamped
* to the nearest valid index.
*
* @param index The index to which the specified columns should be moved
* @param columnsToMove The columns to move to the specified index (and, optionally, to rename)
Expand All @@ -372,9 +447,6 @@ public interface Table extends
@ConcurrentMethod
Table moveColumns(int index, String... columnsToMove);

@ConcurrentMethod
Table moveColumns(int index, boolean moveToEnd, String... columnsToMove);

// -----------------------------------------------------------------------------------------------------------------
// Slice Operations
// -----------------------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions engine/table/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
implementation 'com.tdunning:t-digest:3.2'
implementation 'com.squareup:javapoet:1.13.0'
implementation 'io.github.classgraph:classgraph:4.8.165'
implementation 'it.unimi.dsi:fastutil:8.5.13'

implementation project(':plugin')
implementation depCommonsLang3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import io.deephaven.api.Pair;
import io.deephaven.base.Base64;
import io.deephaven.base.log.LogOutput;
import io.deephaven.base.reference.SimpleReference;
Expand Down Expand Up @@ -1034,7 +1035,7 @@ public void copySortableColumns(
destination.setSortableColumns(currentSortableColumns.stream().filter(shouldCopy).collect(Collectors.toList()));
}

void copySortableColumns(BaseTable<?> destination, MatchPair[] renamedColumns) {
void copySortableColumns(BaseTable<?> destination, Collection<Pair> renamedColumns) {
final Collection<String> currentSortableColumns = getSortableColumns();
if (currentSortableColumns == null) {
return;
Expand All @@ -1047,9 +1048,9 @@ void copySortableColumns(BaseTable<?> destination, MatchPair[] renamedColumns) {
// b) The original column exists, and has not been replaced by another. For example
// T1 = [ Col1, Col2, Col3 ]; T1.renameColumns(Col1=Col3, Col2];
if (renamedColumns != null) {
for (MatchPair mp : renamedColumns) {
for (final Pair pair : renamedColumns) {
// Only the last grouping matters.
columnMapping.forcePut(mp.leftColumn(), mp.rightColumn());
columnMapping.forcePut(pair.output().name(), pair.input().name());
}
}

Expand Down Expand Up @@ -1158,7 +1159,9 @@ void maybeCopyColumnDescriptions(final BaseTable<?> destination) {
* @param destination the table which shall possibly have a column-description attribute created
* @param renamedColumns an array of the columns which have been renamed
*/
void maybeCopyColumnDescriptions(final BaseTable<?> destination, final MatchPair[] renamedColumns) {
void maybeCopyColumnDescriptions(
final BaseTable<?> destination,
final Collection<Pair> renamedColumns) {
// noinspection unchecked
final Map<String, String> oldDescriptions =
(Map<String, String>) getAttribute(Table.COLUMN_DESCRIPTIONS_ATTRIBUTE);
Expand All @@ -1168,11 +1171,13 @@ void maybeCopyColumnDescriptions(final BaseTable<?> destination, final MatchPair
}
final Map<String, String> sourceDescriptions = new HashMap<>(oldDescriptions);

if (renamedColumns != null && renamedColumns.length != 0) {
for (final MatchPair mp : renamedColumns) {
final String desc = sourceDescriptions.remove(mp.rightColumn());
if (renamedColumns != null) {
for (final Pair pair : renamedColumns) {
final String desc = sourceDescriptions.remove(pair.input().name());
if (desc != null) {
sourceDescriptions.put(mp.leftColumn(), desc);
sourceDescriptions.put(pair.output().name(), desc);
} else {
sourceDescriptions.remove(pair.output().name());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,30 @@ public static Table blinkToAppendOnly(
}

/**
* Returns true if table is a blink table.
* Returns true if {@code table} is a blink table.
*
* @param table The table to check for blink behavior
* @return Whether this table is a blink table
* @return Whether {@code table} is a blink table
* @see Table#BLINK_TABLE_ATTRIBUTE
*/
public static boolean isBlink(Table table) {
public static boolean isBlink(@NotNull final Table table) {
if (!table.isRefreshing()) {
return false;
}
return Boolean.TRUE.equals(table.getAttribute(Table.BLINK_TABLE_ATTRIBUTE));
}

/**
* Returns true if {@code attributes} indicate a blink table.
*
* @param attributes The map to check for blink table attributes
* @return Whether {@code attributes} indicate a blink table
* @see Table#BLINK_TABLE_ATTRIBUTE
*/
public static boolean hasBlink(@NotNull final Map<String, Object> attributes) {
return Boolean.TRUE.equals(attributes.get(Table.BLINK_TABLE_ATTRIBUTE));
}

private static class BlinkToAppendOnlyOperation implements QueryTable.MemoizableOperation<QueryTable> {
private final QueryTable parent;
private final long sizeLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ boolean attributesCompatible(Map<String, Object> oldAttributes, Map<String, Obje
abstract BaseTable.CopyAttributeOperation copyType();
}

abstract static class BlinkIncompatibleMemoizedOperationKey extends MemoizedOperationKey {
@Override
boolean attributesCompatible(Map<String, Object> oldAttributes, Map<String, Object> newAttributes) {
return BlinkTableTools.hasBlink(oldAttributes) == BlinkTableTools.hasBlink(newAttributes);
}

@Override
abstract BaseTable.CopyAttributeOperation copyType();
}

public interface Provider {
MemoizedOperationKey getMemoKey();
}
Expand Down Expand Up @@ -360,7 +370,7 @@ BaseTable.CopyAttributeOperation getParentCopyType() {
}
}

private static class AggBy extends AttributeAgnosticMemoizedOperationKey {
private static class AggBy extends BlinkIncompatibleMemoizedOperationKey {

private final List<? extends Aggregation> aggregations;
private final boolean preserveEmpty;
Expand Down Expand Up @@ -442,7 +452,7 @@ public int hashCode() {
}
}

private static class Rollup extends AttributeAgnosticMemoizedOperationKey {
private static class Rollup extends BlinkIncompatibleMemoizedOperationKey {

private final AggBy aggBy;
private final boolean includeConstituents;
Expand Down
Loading

0 comments on commit 44659f3

Please sign in to comment.