Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Input Table Interface. #4923

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading