Skip to content

Commit 21dff7c

Browse files
committed
noticket: [repository-inmemory] Deprecate DbMemory for removal
1 parent 7e056b6 commit 21dff7c

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

repository-inmemory/src/main/java/tech/ydb/yoj/repository/test/inmemory/InMemoryRepositoryTransaction.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.common.base.Stopwatch;
44
import com.google.common.collect.Iterables;
55
import lombok.Getter;
6+
import tech.ydb.yoj.DeprecationWarnings;
67
import tech.ydb.yoj.repository.BaseDb;
78
import tech.ydb.yoj.repository.db.Entity;
89
import tech.ydb.yoj.repository.db.RepositoryTransaction;
@@ -57,16 +58,21 @@ private long getVersion() {
5758

5859
@Override
5960
public <T extends Entity<T>> Table<T> table(Class<T> c) {
60-
return new InMemoryTable<>(getMemory(c));
61+
return new InMemoryTable<>(this, c);
6162
}
6263

6364
@Override
6465
public <T extends Entity<T>> Table<T> table(TableDescriptor<T> tableDescriptor) {
6566
return new InMemoryTable<>(this, tableDescriptor);
6667
}
6768

68-
@Deprecated // use other constructor of InMemoryTable
69+
/**
70+
* @deprecated {@code DbMemory} and this method will be removed in YOJ 2.7.0.
71+
*/
72+
@Deprecated(forRemoval = true)
6973
public final <T extends Entity<T>> InMemoryTable.DbMemory<T> getMemory(Class<T> c) {
74+
DeprecationWarnings.warnOnce("InMemoryTable.getMemory(Class)",
75+
"InMemoryTable.getMemory(Class<T>) will be removed in YOJ 2.7.0. Please stop using this method");
7076
return new InMemoryTable.DbMemory<>(c, this);
7177
}
7278

repository-inmemory/src/main/java/tech/ydb/yoj/repository/test/inmemory/InMemoryTable.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.common.base.Preconditions;
44
import com.google.common.collect.Iterables;
55
import com.google.common.collect.Sets;
6+
import tech.ydb.yoj.DeprecationWarnings;
67
import tech.ydb.yoj.databind.expression.FilterExpression;
78
import tech.ydb.yoj.databind.expression.OrderExpression;
89
import tech.ydb.yoj.databind.schema.ObjectSchema;
@@ -38,9 +39,15 @@ public class InMemoryTable<T extends Entity<T>> implements Table<T> {
3839
private final TableDescriptor<T> tableDescriptor;
3940
private final InMemoryRepositoryTransaction transaction;
4041

41-
@Deprecated // Don't use DbMemory, use other constructor instead
42+
/**
43+
* @deprecated {@code DbMemory} and this {@code InMemoryTable} constructor will be removed in YOJ 2.7.0.
44+
* Please use other {@code InMemoryTable} constructors instead.
45+
*/
46+
@Deprecated(forRemoval = true)
4247
public InMemoryTable(DbMemory<T> memory) {
4348
this(memory.transaction(), memory.type());
49+
DeprecationWarnings.warnOnce("new InMemoryTable(DbMemory)",
50+
"Please do not use the InMemoryTable(DbMemory<T>) constructor, it will be removed in YOJ 2.7.0");
4451
}
4552

4653
public InMemoryTable(InMemoryRepositoryTransaction transaction, Class<T> type) {
@@ -586,8 +593,12 @@ private static <V extends Table.View, T extends Entity<T>> V toView(
586593
return Columns.fromEntity(schema, entity).toSchema(viewSchema);
587594
}
588595

589-
590-
@Deprecated // Legacy. Using only for creating InMemoryTable. Use constructor of InMemoryTable instead
596+
/**
597+
* @deprecated Legacy class, used only for creating {@code InMemoryTable}.
598+
* This class will be removed in YOJ 2.7.0.
599+
* Please use the {@code InMemoryTable(InMemoryRepositoryTransaction, Class)} constructor instead of {@code InMemoryTable(DbMemory)} constructor.
600+
*/
601+
@Deprecated(forRemoval = true)
591602
public record DbMemory<T extends Entity<T>>(
592603
Class<T> type,
593604
InMemoryRepositoryTransaction transaction

repository-inmemory/src/test/java/tech/ydb/yoj/repository/test/inmemory/TestInMemoryRepository.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import tech.ydb.yoj.repository.test.sample.TestEntityOperations.BubbleTable;
1212
import tech.ydb.yoj.repository.test.sample.TestEntityOperations.ComplexTable;
1313
import tech.ydb.yoj.repository.test.sample.TestEntityOperations.IndexedTable;
14+
import tech.ydb.yoj.repository.test.sample.TestEntityOperations.Supabubble2Table;
1415
import tech.ydb.yoj.repository.test.sample.model.Bubble;
1516
import tech.ydb.yoj.repository.test.sample.model.Complex;
1617
import tech.ydb.yoj.repository.test.sample.model.DetachedEntity;
@@ -105,7 +106,7 @@ public SupabubbleTable supabubbles() {
105106

106107
@Override
107108
public Supabubble2Table supabubbles2() {
108-
return new Supabubble2InMemoryTable(getMemory(Supabubble2.class));
109+
return new Supabubble2InMemoryTable(table(Supabubble2.class));
109110
}
110111

111112
@Override
@@ -144,9 +145,9 @@ public Table<MultiWrappedEntity2> multiWrappedEntities2() {
144145
}
145146
}
146147

147-
private static class Supabubble2InMemoryTable extends InMemoryTable<Supabubble2> implements TestEntityOperations.Supabubble2Table {
148-
public Supabubble2InMemoryTable(DbMemory<Supabubble2> memory) {
149-
super(memory);
148+
private static class Supabubble2InMemoryTable extends AbstractDelegatingTable<Supabubble2> implements Supabubble2Table {
149+
public Supabubble2InMemoryTable(Table<Supabubble2> target) {
150+
super(target);
150151
}
151152
}
152153

0 commit comments

Comments
 (0)