Skip to content

Commit 3b4cd80

Browse files
committed
Added StoreType to TableDescription
1 parent 446bd2d commit 3b4cd80

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

table/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
<plugin>
4848
<groupId>org.apache.maven.plugins</groupId>
4949
<artifactId>maven-surefire-plugin</artifactId>
50-
<version>3.1.0</version>
5150
<configuration>
5251
<environmentVariables>
5352
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>

table/src/main/java/tech/ydb/table/description/TableDescription.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
* @author Sergey Polovko
2525
*/
2626
public class TableDescription {
27+
public enum StoreType {
28+
ROWS,
29+
COLUMNS
30+
}
2731

32+
private final StoreType storeType;
2833
private final List<String> primaryKeys;
2934
private final List<TableColumn> columns;
3035
private final List<TableIndex> indexes;
@@ -42,6 +47,7 @@ public class TableDescription {
4247
private final TableTtl tableTtl;
4348

4449
private TableDescription(Builder builder) {
50+
this.storeType = builder.storeType;
4551
this.primaryKeys = ImmutableList.copyOf(builder.primaryKeys);
4652
this.columns = builder.buildColumns();
4753
this.indexes = ImmutableList.copyOf(builder.indexes);
@@ -59,6 +65,10 @@ public static Builder newBuilder() {
5965
return new Builder();
6066
}
6167

68+
public StoreType getStoreType() {
69+
return storeType;
70+
}
71+
6272
public List<String> getPrimaryKeys() {
6373
return primaryKeys;
6474
}
@@ -105,7 +115,7 @@ public List<ChangefeedDescription> getChangefeeds() {
105115
* BUILDER
106116
*/
107117
public static class Builder {
108-
118+
private StoreType storeType = StoreType.ROWS;
109119
private List<String> primaryKeys = Collections.emptyList();
110120
private final LinkedHashMap<String, TypeAndFamily> columns = new LinkedHashMap<>();
111121
private final List<TableIndex> indexes = new ArrayList<>();
@@ -118,6 +128,11 @@ public static class Builder {
118128
private TableTtl ttlSettings = TableTtl.notSet();
119129
private final List<ChangefeedDescription> changefeeds = new ArrayList<>();
120130

131+
public Builder withStoreType(StoreType storeType) {
132+
this.storeType = storeType;
133+
return this;
134+
}
135+
121136
public Builder addNonnullColumn(String name, Type type) {
122137
return addNonnullColumn(name, type, null);
123138
}

table/src/main/java/tech/ydb/table/impl/BaseSession.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,17 @@ public CompletableFuture<Status> createTable(
362362
.setOperationParams(Operation.buildParams(settings.toOperationSettings()))
363363
.addAllPrimaryKey(description.getPrimaryKeys());
364364

365+
switch (description.getStoreType()) {
366+
case ROWS:
367+
request.setStoreType(YdbTable.StoreType.STORE_TYPE_ROW);
368+
break;
369+
case COLUMNS:
370+
request.setStoreType(YdbTable.StoreType.STORE_TYPE_COLUMN);
371+
break;
372+
default:
373+
break;
374+
}
375+
365376
for (ColumnFamily family: description.getColumnFamilies()) {
366377
request.addColumnFamilies(buildColumnFamity(family));
367378
}
@@ -726,6 +737,19 @@ private static TableDescription mapDescribeTable(
726737
DescribeTableSettings describeTableSettings
727738
) {
728739
TableDescription.Builder description = TableDescription.newBuilder();
740+
switch (result.getStoreType()) {
741+
case STORE_TYPE_ROW:
742+
description = description.withStoreType(TableDescription.StoreType.ROWS);
743+
break;
744+
case STORE_TYPE_COLUMN:
745+
description = description.withStoreType(TableDescription.StoreType.COLUMNS);
746+
break;
747+
case UNRECOGNIZED:
748+
case STORE_TYPE_UNSPECIFIED:
749+
default:
750+
break;
751+
}
752+
729753
for (int i = 0; i < result.getColumnsCount(); i++) {
730754
YdbTable.ColumnMeta column = result.getColumns(i);
731755
description.addNonnullColumn(column.getName(), ProtoType.fromPb(column.getType()), column.getFamily());

0 commit comments

Comments
 (0)