Skip to content

Commit

Permalink
Simplify Input Table Interface. (deephaven#4923)
Browse files Browse the repository at this point in the history
Removes the InputTableEnumGetter and InputTableRowSetter interfaces that MutableInputTable extended, but are not used by web.

There have been the following class renames:
io.deephaven.engine.util.config.MutableInputTable -> io.deephaven.engine.util.input.InputTableHandler
KeyedArrayBackedMutableTable -> io.deephaven.engine.table.impl.util.KeyedArrayBackedInputTable
AppendOnlyArrayBackedMutableTable -> io.deephaven.engine.table.impl.util.AppendOnlyArrayBackedInputTable

Additionally, the MutableInputTable interface, KeyedArrayBackedMutableTable, and AppendOnlyArrayBackedMutableTable no longer have parameters for enum values. The "allowEdits" parameter has been removed from the interface and all implementations. The delete method that takes a rowSet has been removed.
  • Loading branch information
cpwright authored Dec 8, 2023
1 parent bc352c7 commit 1607606
Show file tree
Hide file tree
Showing 15 changed files with 330 additions and 781 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import io.deephaven.engine.table.Table;
import io.deephaven.engine.table.TableDefinition;
import io.deephaven.engine.table.TableFactory;
import io.deephaven.engine.table.impl.util.AppendOnlyArrayBackedMutableTable;
import io.deephaven.engine.table.impl.util.KeyedArrayBackedMutableTable;
import io.deephaven.engine.table.impl.util.AppendOnlyArrayBackedInputTable;
import io.deephaven.engine.table.impl.util.KeyedArrayBackedInputTable;
import io.deephaven.engine.util.TableTools;
import io.deephaven.qst.TableCreator;
import io.deephaven.qst.table.EmptyTable;
Expand Down Expand Up @@ -163,14 +163,14 @@ public static UpdatableTable of(InputTable inputTable) {
@Override
public UpdatableTable visit(InMemoryAppendOnlyInputTable inMemoryAppendOnly) {
final TableDefinition definition = DefinitionAdapter.of(inMemoryAppendOnly.schema());
return AppendOnlyArrayBackedMutableTable.make(definition);
return AppendOnlyArrayBackedInputTable.make(definition);
}

@Override
public UpdatableTable visit(InMemoryKeyBackedInputTable inMemoryKeyBacked) {
final TableDefinition definition = DefinitionAdapter.of(inMemoryKeyBacked.schema());
final String[] keyColumnNames = inMemoryKeyBacked.keys().toArray(String[]::new);
return KeyedArrayBackedMutableTable.make(definition, keyColumnNames);
return KeyedArrayBackedInputTable.make(definition, keyColumnNames);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.deephaven.engine.rowset.RowSet;
import io.deephaven.engine.rowset.RowSetFactory;
import io.deephaven.engine.rowset.RowSequenceFactory;
import io.deephaven.engine.util.config.InputTableStatusListener;
import io.deephaven.engine.table.impl.QueryTable;
import io.deephaven.engine.table.impl.sources.NullValueColumnSource;
import io.deephaven.engine.table.ChunkSink;
Expand All @@ -18,15 +17,13 @@

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

/**
* An in-memory table that allows you to add rows as if it were an InputTable, which can be updated on the UGP.
* <p>
* The table is not keyed, all rows are added to the end of the table. Deletions and edits are not permitted.
*/
public class AppendOnlyArrayBackedMutableTable extends BaseArrayBackedMutableTable {
public class AppendOnlyArrayBackedInputTable extends BaseArrayBackedInputTable {
static final String DEFAULT_DESCRIPTION = "Append Only In-Memory Input Table";

/**
Expand All @@ -36,64 +33,40 @@ public class AppendOnlyArrayBackedMutableTable extends BaseArrayBackedMutableTab
*
* @return an empty AppendOnlyArrayBackedMutableTable with the given definition
*/
public static AppendOnlyArrayBackedMutableTable make(@NotNull TableDefinition definition) {
return make(definition, Collections.emptyMap());
}

/**
* Create an empty AppendOnlyArrayBackedMutableTable with the given definition.
*
* @param definition the definition of the new table.
* @param enumValues a map of column names to enumeration values
*
* @return an empty AppendOnlyArrayBackedMutableTable with the given definition
*/
public static AppendOnlyArrayBackedMutableTable make(@NotNull TableDefinition definition,
final Map<String, Object[]> enumValues) {
public static AppendOnlyArrayBackedInputTable make(
@NotNull TableDefinition definition) {
// noinspection resource
return make(new QueryTable(definition, RowSetFactory.empty().toTracking(),
NullValueColumnSource.createColumnSourceMap(definition)), enumValues);
}

/**
* Create an AppendOnlyArrayBackedMutableTable with the given initial data.
*
* @param initialTable the initial values to copy into the AppendOnlyArrayBackedMutableTable
*
* @return an empty AppendOnlyArrayBackedMutableTable with the given definition
*/
public static AppendOnlyArrayBackedMutableTable make(final Table initialTable) {
return make(initialTable, Collections.emptyMap());
NullValueColumnSource.createColumnSourceMap(definition)));
}

/**
* Create an AppendOnlyArrayBackedMutableTable with the given initial data.
*
* @param initialTable the initial values to copy into the AppendOnlyArrayBackedMutableTable
* @param enumValues a map of column names to enumeration values
*
* @return an empty AppendOnlyArrayBackedMutableTable with the given definition
*/
public static AppendOnlyArrayBackedMutableTable make(final Table initialTable,
final Map<String, Object[]> enumValues) {
final AppendOnlyArrayBackedMutableTable result = new AppendOnlyArrayBackedMutableTable(
initialTable.getDefinition(), enumValues, new ProcessPendingUpdater());
public static AppendOnlyArrayBackedInputTable make(final Table initialTable) {
final AppendOnlyArrayBackedInputTable result =
new AppendOnlyArrayBackedInputTable(
initialTable.getDefinition(), new ProcessPendingUpdater());
result.setAttribute(Table.ADD_ONLY_TABLE_ATTRIBUTE, Boolean.TRUE);
result.setAttribute(Table.APPEND_ONLY_TABLE_ATTRIBUTE, Boolean.TRUE);
result.setFlat();
processInitial(initialTable, result);
return result;
}

private AppendOnlyArrayBackedMutableTable(@NotNull TableDefinition definition,
final Map<String, Object[]> enumValues, final ProcessPendingUpdater processPendingUpdater) {
private AppendOnlyArrayBackedInputTable(@NotNull TableDefinition definition,
final ProcessPendingUpdater processPendingUpdater) {
// noinspection resource
super(RowSetFactory.empty().toTracking(), makeColumnSourceMap(definition),
enumValues, processPendingUpdater);
processPendingUpdater);
}

@Override
protected void processPendingTable(Table table, boolean allowEdits, RowSetChangeRecorder rowSetChangeRecorder,
Consumer<String> errorNotifier) {
protected void processPendingTable(Table table, RowSetChangeRecorder rowSetChangeRecorder) {
try (final RowSet addRowSet = table.getRowSet().copy()) {
final long firstRow = nextRow;
final long lastRow = firstRow + addRowSet.intSize() - 1;
Expand Down Expand Up @@ -135,28 +108,15 @@ protected List<String> getKeyNames() {
}

@Override
ArrayBackedMutableInputTable makeHandler() {
return new AppendOnlyArrayBackedMutableInputTable();
ArrayBackedInputTableUpdater makeUpdater() {
return new Updater();
}

private class AppendOnlyArrayBackedMutableInputTable extends ArrayBackedMutableInputTable {
@Override
public void setRows(@NotNull Table defaultValues, int[] rowArray, Map<String, Object>[] valueArray,
InputTableStatusListener listener) {
throw new UnsupportedOperationException();
}
private class Updater extends ArrayBackedInputTableUpdater {

@Override
public void validateDelete(Table tableToDelete) {
throw new UnsupportedOperationException("Table doesn't support delete operation");
}

@Override
public void addRows(Map<String, Object>[] valueArray, boolean allowEdits, InputTableStatusListener listener) {
if (allowEdits) {
throw new UnsupportedOperationException();
}
super.addRows(valueArray, allowEdits, listener);
}
}
}
Loading

0 comments on commit 1607606

Please sign in to comment.