Skip to content

Commit f09c894

Browse files
lavrukovAlexander Lavrukovnvamelichev
authored
#77: Remove deprecation from user-visible parts of the Projections API (for now) + Improve messages for dry-run mode transactions
We remove `@Deprecated` annotation and deprecation warning logs from user-visible parts of the Projections API: `t.y.y.r.d.{Entity.createProjections, EntityList}`, `t.y.y.r.d.projection.*` (except for `@InternalApi`s). We add concrete docs on which parts of the APIs will be moved to a different library and/or package, and which internal Projection-related APIs will be removed entirely (or at least *may* be.) Drive-by change: Improve transaction log message and ordinary log message when we roll back a dry-run transaction. It's not caused by any "inconsistency", and is in fact entirely normal and indended. Co-authored-by: Alexander Lavrukov <[email protected]> Co-authored-by: Nikolai Amelichev <[email protected]>
1 parent c57f881 commit f09c894

File tree

13 files changed

+39
-46
lines changed

13 files changed

+39
-46
lines changed

databind/src/main/java/tech/ydb/yoj/databind/schema/Schema.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@ public void setName(String newName) {
577577
}
578578

579579
/**
580-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
580+
* @deprecated Projections will be moved from the core YOJ API in 3.0.0 to an optional module.
581+
* The {@code getRawPath()} method is only used by projection logic, and will most likely be removed.
581582
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
582583
*/
583584
@Deprecated(forRemoval = true)
@@ -586,7 +587,8 @@ public String getRawPath() {
586587
}
587588

588589
/**
589-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
590+
* @deprecated Projections will be moved from the core YOJ API in 3.0.0 to an optional module.
591+
* The {@code getRawSubPath(int)} method is only used by projection logic, and will most likely be removed.
590592
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
591593
*/
592594
@Deprecated(forRemoval = true)

repository/src/main/java/tech/ydb/yoj/repository/db/Entity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ default E preSave() {
2323
}
2424

2525
/**
26-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
26+
* <strong>Warning!</strong> Projections will be moved to a separate YOJ module in YOJ 3.0.0.
27+
* The {@code Entity.createProjections()} method will be moved to a subinterface of {@code Entity}
28+
* in a separate library.
2729
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
2830
*/
29-
@Deprecated(forRemoval = true)
3031
default List<Entity<?>> createProjections() {
3132
return List.of();
3233
}

repository/src/main/java/tech/ydb/yoj/repository/db/EntityList.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
import java.util.stream.Stream;
77

88
/**
9+
* <strong>Warning!</strong> Projections will be moved to a separate YOJ library in YOJ 3.0.0.
10+
* The {@code EntityList} class will be moved to {@code tech.ydb.yoj.repository.db.projection} package in
11+
* a separate library.
912
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
10-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
1113
*/
12-
@Deprecated(forRemoval = true)
1314
public class EntityList extends LinkedList<Entity<?>> {
1415
public static EntityList create() {
1516
return new EntityList();

repository/src/main/java/tech/ydb/yoj/repository/db/StdTxManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ public boolean isFirstLevelCache() {
337337
return options.isFirstLevelCache();
338338
}
339339

340+
@Override
341+
public boolean isDryRun() {
342+
return options.isDryRun();
343+
}
344+
340345
@Nullable
341346
@Override
342347
public IsolationLevel getIsolationLevel() {

repository/src/main/java/tech/ydb/yoj/repository/db/TxImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ private <R> R runImpl(Supplier<R> supplier) {
8686
}
8787

8888
if (dryRun) {
89-
doRollback(true,
90-
String.format("[%s] runInTx(): Rollback because dry-run transaction read inconsistent data", sw));
91-
log.debug("[{}] runInTx(): Rollback due to dry-run mode {}", sw, formatExecutionLogMultiline("# "));
89+
doRollback(true, String.format("[%s] runInTx(): Rollback due to DRY-RUN mode", sw));
90+
log.debug("[{}] runInTx(): Rollback due to DRY-RUN mode {}", sw, formatExecutionLogMultiline("# "));
9291
return res;
9392
}
9493

repository/src/main/java/tech/ydb/yoj/repository/db/TxManagerState.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ public interface TxManagerState {
1919
boolean isScan();
2020

2121
boolean isFirstLevelCache();
22+
23+
boolean isDryRun();
2224
}

repository/src/main/java/tech/ydb/yoj/repository/db/cache/TransactionLocal.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public <X> X instance(@NonNull Supplier<X> supplier) {
4747
* <strong>Warning:</strong> Unlike {@link #log()}, this method is not intended to be used by end-users,
4848
* only by the YOJ implementation itself.
4949
*
50-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
50+
* @deprecated Projections will be moved from the core YOJ API in 3.0.0 to an optional module.
51+
* The {@code projectionCache()} method is an implementation detail, and will be removed.
5152
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
5253
*/
5354
@InternalApi

repository/src/main/java/tech/ydb/yoj/repository/db/projection/ProjectionCache.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package tech.ydb.yoj.repository.db.projection;
22

3-
43
import tech.ydb.yoj.InternalApi;
54
import tech.ydb.yoj.repository.db.Entity;
65
import tech.ydb.yoj.repository.db.RepositoryTransaction;
76

87
/**
9-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
8+
* @deprecated Projections will be moved from the core YOJ API in 3.0.0 to an optional module.
9+
* The {@code ProjectionCache} interface is an implementation detail, and will be removed or moved to an internal package.
1010
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
1111
*/
1212
@InternalApi

repository/src/main/java/tech/ydb/yoj/repository/db/projection/ProjectionMappings.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.google.common.collect.HashBiMap;
66
import lombok.NonNull;
77
import lombok.RequiredArgsConstructor;
8-
import tech.ydb.yoj.DeprecationWarnings;
98
import tech.ydb.yoj.databind.schema.Schema;
109
import tech.ydb.yoj.repository.db.Entity;
1110
import tech.ydb.yoj.repository.db.EntityIdSchema;
@@ -24,10 +23,10 @@
2423
import static lombok.AccessLevel.PRIVATE;
2524

2625
/**
26+
* <strong>Warning!</strong> Projections will be moved to a separate YOJ module in YOJ 3.0.0.
27+
* The {@code ProjectionMappings} class will be moved to a separate library.
2728
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
28-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
2929
*/
30-
@Deprecated(forRemoval = true)
3130
public final class ProjectionMappings {
3231
private ProjectionMappings() {
3332
}
@@ -96,9 +95,6 @@ public static <P extends Entity<P>, T extends Entity<T>> Map<String, String> len
9695
@NonNull
9796
public static <P extends Entity<P>, T extends Entity<T>> Map<String, String> strictFieldMapping(
9897
@NonNull Class<P> projectionType, @NonNull Class<T> entityType) {
99-
DeprecationWarnings.warnOnce("ProjectionMappings.*fieldMapping", "You are using ProjectionMappings.{lenient,strict}FieldMapping(). "
100-
+ "Projections will be removed from YOJ core in YOJ 3.0.0. See https://github.com/ydb-platform/yoj-project/issues/77");
101-
10298
EntitySchema<T> entitySchema = EntitySchema.of(entityType);
10399
Class<?> entityIdType = entitySchema.getIdSchema().getType();
104100
List<Schema.JavaField> projectionIdFields = EntityIdSchema.ofEntity(projectionType).getFields();
@@ -153,16 +149,14 @@ private static Schema.JavaField getMatchingIdField(@NonNull Schema.JavaField pro
153149

154150
@NonNull
155151
public static <P extends Entity<P>> ListViaProjection<P> listViaProjection(@NonNull Class<P> projectionType) {
156-
DeprecationWarnings.warnOnce("ProjectionMappings.listViaProjection", "You are using ProjectionMappings.listViaProjection(). "
157-
+ "Projections will be removed from YOJ core in YOJ 3.0.0. See https://github.com/ydb-platform/yoj-project/issues/77");
158152
return new ListViaProjection<>(projectionType);
159153
}
160154

161155
/**
156+
* <strong>Warning!</strong> Projections will be moved to a separate YOJ module in YOJ 3.0.0.
157+
* The {@code ProjectionMappings.ListViaProjection} class will be moved to a separate library.
162158
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
163-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
164159
*/
165-
@Deprecated(forRemoval = true)
166160
@RequiredArgsConstructor(access = PRIVATE)
167161
public static final class ListViaProjection<P extends Entity<P>> {
168162
private final Class<P> projectionType;
@@ -193,10 +187,10 @@ public <T extends Entity<T>> Listing<T, P> entities(@NonNull ListRequest<T> requ
193187
}
194188

195189
/**
190+
* <strong>Warning!</strong> Projections will be moved to a separate YOJ module in YOJ 3.0.0.
191+
* The {@code ProjectionMappings.Listing} class will be moved to a separate library.
196192
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
197-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
198193
*/
199-
@Deprecated(forRemoval = true)
200194
@RequiredArgsConstructor(access = PRIVATE)
201195
public static final class Listing<T extends Entity<T>, P extends Entity<P>> {
202196
private final ListRequest<T> request;
@@ -214,10 +208,10 @@ public ListResult<P> run(@NonNull Function<ListRequest<P>, ListResult<P>> listFu
214208
}
215209

216210
/**
211+
* <strong>Warning!</strong> Projections will be moved to a separate YOJ module in YOJ 3.0.0.
212+
* The {@code ProjectionMappings.TransformedListing} class will be moved to a separate library.
217213
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
218-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
219214
*/
220-
@Deprecated(forRemoval = true)
221215
@RequiredArgsConstructor(access = PRIVATE)
222216
public static final class TransformedListing<T extends Entity<T>, P extends Entity<P>> {
223217
private final Listing<T, P> listing;

repository/src/main/java/tech/ydb/yoj/repository/db/projection/Projections.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import java.lang.annotation.Target;
99

1010
/**
11-
* @deprecated Projections will be removed from the core YOJ API in 3.0.0 and possibly reintroduced as an optional module.
11+
* <strong>Warning!</strong> Projections will be moved to a separate YOJ module in YOJ 3.0.0.
12+
* The {@code Projections} annotation interface will be moved to a separate library.
1213
* @see <a href="https://github.com/ydb-platform/yoj-project/issues/77">#77</a>
1314
*/
14-
@Deprecated(forRemoval = true)
1515
@Target(ElementType.TYPE)
1616
@Retention(RetentionPolicy.RUNTIME)
1717
public @interface Projections {

0 commit comments

Comments
 (0)