-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
227 additions
and
113 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
engine/table/src/test/java/io/deephaven/engine/table/impl/DummyTableLocation.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,131 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.engine.table.impl; | ||
|
||
import io.deephaven.api.SortColumn; | ||
import io.deephaven.chunk.attributes.Values; | ||
import io.deephaven.engine.table.BasicDataIndex; | ||
import io.deephaven.engine.table.ColumnDefinition; | ||
import io.deephaven.engine.table.impl.locations.ColumnLocation; | ||
import io.deephaven.engine.table.impl.locations.TableKey; | ||
import io.deephaven.engine.table.impl.locations.TableLocation; | ||
import io.deephaven.engine.table.impl.locations.TableLocationKey; | ||
import io.deephaven.engine.table.impl.locations.impl.AbstractTableLocation; | ||
import io.deephaven.engine.table.impl.sources.regioned.ColumnRegionByte; | ||
import io.deephaven.engine.table.impl.sources.regioned.ColumnRegionChar; | ||
import io.deephaven.engine.table.impl.sources.regioned.ColumnRegionDouble; | ||
import io.deephaven.engine.table.impl.sources.regioned.ColumnRegionFloat; | ||
import io.deephaven.engine.table.impl.sources.regioned.ColumnRegionInt; | ||
import io.deephaven.engine.table.impl.sources.regioned.ColumnRegionLong; | ||
import io.deephaven.engine.table.impl.sources.regioned.ColumnRegionObject; | ||
import io.deephaven.engine.table.impl.sources.regioned.ColumnRegionShort; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
|
||
public final class DummyTableLocation extends AbstractTableLocation { | ||
|
||
public DummyTableLocation(@NotNull final TableKey tableKey, | ||
@NotNull final TableLocationKey tableLocationKey) { | ||
super(tableKey, tableLocationKey, false); | ||
} | ||
|
||
@Override | ||
public void refresh() {} | ||
|
||
@Override | ||
public @NotNull List<SortColumn> getSortedColumns() { | ||
return List.of(); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public List<String[]> getDataIndexColumns() { | ||
return List.of(); | ||
} | ||
|
||
@Override | ||
public boolean hasDataIndex(@NotNull final String... columns) { | ||
return false; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
protected ColumnLocation makeColumnLocation(@NotNull final String name) { | ||
return new ColumnLocation() { | ||
@NotNull | ||
@Override | ||
public TableLocation getTableLocation() { | ||
return DummyTableLocation.this; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public boolean exists() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ColumnRegionChar<Values> makeColumnRegionChar( | ||
@NotNull final ColumnDefinition<?> columnDefinition) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ColumnRegionByte<Values> makeColumnRegionByte( | ||
@NotNull final ColumnDefinition<?> columnDefinition) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ColumnRegionShort<Values> makeColumnRegionShort( | ||
@NotNull final ColumnDefinition<?> columnDefinition) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ColumnRegionInt<Values> makeColumnRegionInt( | ||
@NotNull final ColumnDefinition<?> columnDefinition) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ColumnRegionLong<Values> makeColumnRegionLong( | ||
@NotNull final ColumnDefinition<?> columnDefinition) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ColumnRegionFloat<Values> makeColumnRegionFloat( | ||
@NotNull final ColumnDefinition<?> columnDefinition) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ColumnRegionDouble<Values> makeColumnRegionDouble( | ||
@NotNull final ColumnDefinition<?> columnDefinition) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public <TYPE> ColumnRegionObject<TYPE, Values> makeColumnRegionObject( | ||
@NotNull final ColumnDefinition<TYPE> columnDefinition) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
}; | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public BasicDataIndex loadDataIndex(@NotNull final String... columns) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
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
96 changes: 96 additions & 0 deletions
96
...ble/src/test/java/io/deephaven/engine/table/impl/locations/impl/TestTableDataService.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,96 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.engine.table.impl.locations.impl; | ||
|
||
import io.deephaven.engine.table.impl.DummyTableLocation; | ||
import io.deephaven.engine.table.impl.locations.TableDataException; | ||
import io.deephaven.engine.table.impl.locations.TableDataService; | ||
import io.deephaven.engine.table.impl.locations.TableKey; | ||
import io.deephaven.engine.table.impl.locations.TableLocation; | ||
import io.deephaven.engine.table.impl.locations.TableLocationKey; | ||
import io.deephaven.engine.table.impl.locations.TableLocationProvider; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class TestTableDataService { | ||
@Test | ||
public void testGetRawTableDataService() { | ||
final Map<String, Comparable<?>> partitions1 = new HashMap<>(); | ||
partitions1.put("Part", "A"); | ||
final Map<String, Comparable<?>> partitions2 = new HashMap<>(); | ||
partitions2.put("Part", "B"); | ||
final Map<String, Comparable<?>> partitions3 = new HashMap<>(); | ||
partitions3.put("Part", "C"); | ||
|
||
TableLocationKey tlk1 = new SimpleTableLocationKey(partitions1); | ||
TableLocationKey tlk2 = new SimpleTableLocationKey(partitions2); | ||
TableLocationKey tlk3 = new SimpleTableLocationKey(partitions3); | ||
|
||
// No table location overlap | ||
final CompositeTableDataService ctds1 = | ||
new CompositeTableDataService("ctds1", new DummyServiceSelector(tlk1, tlk2)); | ||
Assert.assertNotNull(ctds1.getRawTableLocationProvider(StandaloneTableKey.getInstance(), tlk1)); | ||
Assert.assertNull(ctds1.getRawTableLocationProvider(StandaloneTableKey.getInstance(), tlk3)); | ||
|
||
// Table location overlap | ||
final CompositeTableDataService ctds2 = | ||
new CompositeTableDataService("ctds2", new DummyServiceSelector(tlk1, tlk1)); | ||
Assert.assertThrows(TableDataException.class, | ||
() -> ctds2.getRawTableLocationProvider(StandaloneTableKey.getInstance(), tlk1)); | ||
Assert.assertNull(ctds2.getRawTableLocationProvider(StandaloneTableKey.getInstance(), tlk3)); | ||
} | ||
|
||
private static class DummyTableDataService extends AbstractTableDataService { | ||
final TableLocation tableLocation; | ||
|
||
private DummyTableDataService(@NotNull final String name, @NotNull final TableLocation tableLocation) { | ||
super(name); | ||
this.tableLocation = tableLocation; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
protected TableLocationProvider makeTableLocationProvider(@NotNull TableKey tableKey) { | ||
return new SingleTableLocationProvider(tableLocation); | ||
} | ||
} | ||
|
||
private static class DummyServiceSelector implements CompositeTableDataService.ServiceSelector { | ||
final TableDataService[] tableDataServices; | ||
|
||
private DummyServiceSelector(final TableLocationKey tlk1, final TableLocationKey tlk2) { | ||
final FilteredTableDataService.LocationKeyFilter dummyFilter = (tlk) -> true; | ||
tableDataServices = new TableDataService[] { | ||
new FilteredTableDataService(new DummyTableDataService("dummyTds1", | ||
new DummyTableLocation(StandaloneTableKey.getInstance(), tlk1)), dummyFilter), | ||
new FilteredTableDataService(new DummyTableDataService("dummyTds2", | ||
new DummyTableLocation(StandaloneTableKey.getInstance(), tlk2)), dummyFilter) | ||
}; | ||
// Init table locations | ||
tableDataServices[0].getTableLocationProvider(StandaloneTableKey.getInstance()) | ||
.getTableLocationIfPresent(tlk1); | ||
tableDataServices[1].getTableLocationProvider(StandaloneTableKey.getInstance()) | ||
.getTableLocationIfPresent(tlk2); | ||
} | ||
|
||
@Override | ||
public TableDataService[] call(@NotNull TableKey tableKey) { | ||
return tableDataServices; | ||
} | ||
|
||
@Override | ||
public void resetServices() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void resetServices(@NotNull TableKey key) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} | ||
} |