Skip to content

Commit

Permalink
Merge pull request #208 from lavrukov/read_table_batch_limits
Browse files Browse the repository at this point in the history
Read table batch limits settings
  • Loading branch information
alex268 authored Dec 27, 2023
2 parents 79d2b73 + 853ba42 commit 855ba5c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<properties>
<ydb-auth-api.version>1.0.0</ydb-auth-api.version>
<ydb-proto-api.version>1.5.0</ydb-proto-api.version>
<ydb-proto-api.version>1.5.2</ydb-proto-api.version>
<yc-auth.version>2.1.0</yc-auth.version>
</properties>

Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/tech/ydb/core/StatusCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public enum StatusCode {
UNDETERMINED(SERVER_STATUSES_FIRST + 170),
UNSUPPORTED(SERVER_STATUSES_FIRST + 180),
SESSION_BUSY(SERVER_STATUSES_FIRST + 190),
EXTERNAL_ERROR(SERVER_STATUSES_FIRST + 200),

// Client statuses
/** Cannot connect or unrecoverable network error. (map from gRPC UNAVAILABLE) */
Expand Down Expand Up @@ -124,6 +125,7 @@ public static StatusCode fromProto(StatusIds.StatusCode code) {
case UNDETERMINED: return UNDETERMINED;
case UNSUPPORTED: return UNSUPPORTED;
case SESSION_BUSY: return SESSION_BUSY;
case EXTERNAL_ERROR: return EXTERNAL_ERROR;
default:
return UNUSED_STATUS;
}
Expand Down
4 changes: 3 additions & 1 deletion table/src/main/java/tech/ydb/table/impl/BaseSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,9 @@ public GrpcReadStream<ReadTablePart> executeReadTable(String tablePath, ReadTabl
.setSessionId(id)
.setPath(tablePath)
.setOrdered(settings.isOrdered())
.setRowLimit(settings.getRowLimit());
.setRowLimit(settings.getRowLimit())
.setBatchLimitBytes(settings.batchLimitBytes())
.setBatchLimitRows(settings.batchLimitRows());

Value<?> fromKey = settings.getFromKey();
if (fromKey != null) {
Expand Down
24 changes: 24 additions & 0 deletions table/src/main/java/tech/ydb/table/settings/ReadTableSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class ReadTableSettings extends BaseRequestSettings {
private final boolean toInclusive;
private final int rowLimit;
private final ImmutableList<String> columns;
private final int batchLimitBytes;
private final int batchLimitRows;

private ReadTableSettings(Builder builder) {
super(builder);
Expand All @@ -39,6 +41,8 @@ private ReadTableSettings(Builder builder) {
this.toInclusive = builder.toInclusive;
this.rowLimit = builder.rowLimit;
this.columns = ImmutableList.copyOf(builder.columns);
this.batchLimitBytes = builder.batchLimitBytes;
this.batchLimitRows = builder.batchLimitRows;
}

public static Builder newBuilder() {
Expand Down Expand Up @@ -75,6 +79,14 @@ public ImmutableList<String> getColumns() {
return columns;
}

public int batchLimitBytes() {
return batchLimitBytes;
}

public int batchLimitRows() {
return batchLimitRows;
}

/**
* BUILDER
*/
Expand All @@ -86,6 +98,8 @@ public static final class Builder extends BaseBuilder<Builder> {
private boolean toInclusive = false;
private int rowLimit = 0;
private List<String> columns = Collections.emptyList();
private int batchLimitBytes = 0;
private int batchLimitRows = 0;

public Builder orderedRead(boolean ordered) {
this.ordered = ordered;
Expand Down Expand Up @@ -160,6 +174,16 @@ public Builder column(String column) {
return this;
}

public Builder batchLimitBytes(int batchLimitBytes) {
this.batchLimitBytes = batchLimitBytes;
return this;
}

public Builder batchLimitRows(int batchLimitRows) {
this.batchLimitRows = batchLimitRows;
return this;
}

@Override
public ReadTableSettings build() {
return new ReadTableSettings(this);
Expand Down

0 comments on commit 855ba5c

Please sign in to comment.