Skip to content

Commit 017eb79

Browse files
committed
Fix
1 parent 3b31262 commit 017eb79

File tree

3 files changed

+36
-29
lines changed

3 files changed

+36
-29
lines changed

core/src/main/java/com/scalar/db/transaction/consensuscommit/Coordinator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ Put createPutWith(Coordinator.State state) {
342342
.condition(ConditionBuilder.putIfNotExists());
343343

344344
if (!childIds.isEmpty()) {
345-
builder.textValue(Attribute.CHILD_IDS, childIds);
345+
builder = builder.textValue(Attribute.CHILD_IDS, childIds);
346346
}
347347
return builder.build();
348348
}

core/src/main/java/com/scalar/db/transaction/consensuscommit/Snapshot.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.google.common.base.MoreObjects;
99
import com.google.common.collect.ComparisonChain;
1010
import com.google.common.collect.Iterators;
11-
import com.google.common.collect.Streams;
1211
import com.scalar.db.api.ConditionSetBuilder;
1312
import com.scalar.db.api.Delete;
1413
import com.scalar.db.api.DistributedStorage;
@@ -165,14 +164,16 @@ public void putIntoWriteSet(Key key, Put put) {
165164
// merge the previous put in the write set and the new put
166165
Put originalPut = writeSet.get(key);
167166
PutBuilder.BuildableFromExisting putBuilder = Put.newBuilder(originalPut);
168-
put.getColumns().values().forEach(putBuilder::value);
167+
for (Column<?> value : put.getColumns().values()) {
168+
putBuilder = putBuilder.value(value);
169+
}
169170

170171
// If the implicit pre-read is enabled for the new put, it should also be enabled for the
171172
// merged put. However, if the previous put is in insert mode, this doesn’t apply. This is
172173
// because, in insert mode, the read set is not used during the preparation phase. Therefore,
173174
// we only need to enable the implicit pre-read if the previous put is not in insert mode
174175
if (isImplicitPreReadEnabled(put) && !isInsertModeEnabled(originalPut)) {
175-
putBuilder.enableImplicitPreRead();
176+
putBuilder = putBuilder.enableImplicitPreRead();
176177
}
177178

178179
writeSet.put(key, putBuilder.build());
@@ -598,10 +599,12 @@ private void validateScanResults(
598599
ScanBuilder.BuildableScanOrScanAllFromExisting builder =
599600
Scan.newBuilder(scan).clearProjections().projection(Attribute.ID);
600601
TableMetadata tableMetadata = getTableMetadata(scan);
601-
Streams.concat(
602-
tableMetadata.getPartitionKeyNames().stream(),
603-
tableMetadata.getClusteringKeyNames().stream())
604-
.forEach(builder::projection);
602+
for (String partitionKeyName : tableMetadata.getPartitionKeyNames()) {
603+
builder = builder.projection(partitionKeyName);
604+
}
605+
for (String clusteringKeyName : tableMetadata.getClusteringKeyNames()) {
606+
builder = builder.projection(clusteringKeyName);
607+
}
605608
scan = builder.build();
606609

607610
if (scan.getLimit() == 0) {

core/src/main/java/com/scalar/db/util/ScalarDbUtils.java

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ public static Get copyAndSetTargetToIfNot(
7474
Get get, Optional<String> namespace, Optional<String> tableName) {
7575
GetBuilder.BuildableGetOrGetWithIndexFromExisting builder = Get.newBuilder(get); // copy
7676
if (!get.forNamespace().isPresent() && namespace.isPresent()) {
77-
builder.namespace(namespace.get());
77+
builder = builder.namespace(namespace.get());
7878
}
7979
if (!get.forTable().isPresent() && tableName.isPresent()) {
80-
builder.table(tableName.get());
80+
builder = builder.table(tableName.get());
8181
}
8282
Get ret = builder.build();
8383
checkIfTargetIsSet(ret);
@@ -88,10 +88,10 @@ public static Scan copyAndSetTargetToIfNot(
8888
Scan scan, Optional<String> namespace, Optional<String> tableName) {
8989
ScanBuilder.BuildableScanOrScanAllFromExisting builder = Scan.newBuilder(scan); // copy
9090
if (!scan.forNamespace().isPresent() && namespace.isPresent()) {
91-
builder.namespace(namespace.get());
91+
builder = builder.namespace(namespace.get());
9292
}
9393
if (!scan.forTable().isPresent() && tableName.isPresent()) {
94-
builder.table(tableName.get());
94+
builder = builder.table(tableName.get());
9595
}
9696
Scan ret = builder.build();
9797
checkIfTargetIsSet(ret);
@@ -118,10 +118,10 @@ public static Put copyAndSetTargetToIfNot(
118118
Put put, Optional<String> namespace, Optional<String> tableName) {
119119
PutBuilder.BuildableFromExisting builder = Put.newBuilder(put); // copy
120120
if (!put.forNamespace().isPresent() && namespace.isPresent()) {
121-
builder.namespace(namespace.get());
121+
builder = builder.namespace(namespace.get());
122122
}
123123
if (!put.forTable().isPresent() && tableName.isPresent()) {
124-
builder.table(tableName.get());
124+
builder = builder.table(tableName.get());
125125
}
126126
Put ret = builder.build();
127127
checkIfTargetIsSet(ret);
@@ -132,10 +132,10 @@ public static Delete copyAndSetTargetToIfNot(
132132
Delete delete, Optional<String> namespace, Optional<String> tableName) {
133133
DeleteBuilder.BuildableFromExisting builder = Delete.newBuilder(delete); // copy
134134
if (!delete.forNamespace().isPresent() && namespace.isPresent()) {
135-
builder.namespace(namespace.get());
135+
builder = builder.namespace(namespace.get());
136136
}
137137
if (!delete.forTable().isPresent() && tableName.isPresent()) {
138-
builder.table(tableName.get());
138+
builder = builder.table(tableName.get());
139139
}
140140
Delete ret = builder.build();
141141
checkIfTargetIsSet(ret);
@@ -146,10 +146,10 @@ public static Insert copyAndSetTargetToIfNot(
146146
Insert insert, Optional<String> namespace, Optional<String> tableName) {
147147
InsertBuilder.BuildableFromExisting builder = Insert.newBuilder(insert); // copy
148148
if (!insert.forNamespace().isPresent() && namespace.isPresent()) {
149-
builder.namespace(namespace.get());
149+
builder = builder.namespace(namespace.get());
150150
}
151151
if (!insert.forTable().isPresent() && tableName.isPresent()) {
152-
builder.table(tableName.get());
152+
builder = builder.table(tableName.get());
153153
}
154154
Insert ret = builder.build();
155155
checkIfTargetIsSet(ret);
@@ -160,10 +160,10 @@ public static Upsert copyAndSetTargetToIfNot(
160160
Upsert upsert, Optional<String> namespace, Optional<String> tableName) {
161161
UpsertBuilder.BuildableFromExisting builder = Upsert.newBuilder(upsert); // copy
162162
if (!upsert.forNamespace().isPresent() && namespace.isPresent()) {
163-
builder.namespace(namespace.get());
163+
builder = builder.namespace(namespace.get());
164164
}
165165
if (!upsert.forTable().isPresent() && tableName.isPresent()) {
166-
builder.table(tableName.get());
166+
builder = builder.table(tableName.get());
167167
}
168168
Upsert ret = builder.build();
169169
checkIfTargetIsSet(ret);
@@ -174,10 +174,10 @@ public static Update copyAndSetTargetToIfNot(
174174
Update update, Optional<String> namespace, Optional<String> tableName) {
175175
UpdateBuilder.BuildableFromExisting builder = Update.newBuilder(update); // copy
176176
if (!update.forNamespace().isPresent() && namespace.isPresent()) {
177-
builder.namespace(namespace.get());
177+
builder = builder.namespace(namespace.get());
178178
}
179179
if (!update.forTable().isPresent() && tableName.isPresent()) {
180-
builder.table(tableName.get());
180+
builder = builder.table(tableName.get());
181181
}
182182
Update ret = builder.build();
183183
checkIfTargetIsSet(ret);
@@ -316,9 +316,11 @@ public static Get copyAndPrepareForDynamicFiltering(Get get) {
316316
List<String> projections = get.getProjections();
317317
if (!projections.isEmpty()) {
318318
// Add columns in conditions into projections to use them in dynamic filtering
319-
ScalarDbUtils.getColumnNamesUsedIn(get.getConjunctions()).stream()
320-
.filter(columnName -> !projections.contains(columnName))
321-
.forEach(builder::projection);
319+
for (String columnName : getColumnNamesUsedIn(get.getConjunctions())) {
320+
if (!projections.contains(columnName)) {
321+
builder = builder.projection(columnName);
322+
}
323+
}
322324
}
323325
return builder.build();
324326
}
@@ -329,14 +331,16 @@ public static Scan copyAndPrepareForDynamicFiltering(Scan scan) {
329331
List<String> projections = scan.getProjections();
330332
if (!projections.isEmpty()) {
331333
// Add columns in conditions into projections to use them in dynamic filtering
332-
ScalarDbUtils.getColumnNamesUsedIn(scan.getConjunctions()).stream()
333-
.filter(columnName -> !projections.contains(columnName))
334-
.forEach(builder::projection);
334+
for (String columnName : getColumnNamesUsedIn(scan.getConjunctions())) {
335+
if (!projections.contains(columnName)) {
336+
builder = builder.projection(columnName);
337+
}
338+
}
335339
}
336340
return builder.build();
337341
}
338342

339-
public static Set<String> getColumnNamesUsedIn(Set<Conjunction> conjunctions) {
343+
private static Set<String> getColumnNamesUsedIn(Set<Conjunction> conjunctions) {
340344
Set<String> columns = new HashSet<>();
341345
conjunctions.forEach(
342346
conjunction ->

0 commit comments

Comments
 (0)