Skip to content

Commit 2be0e0b

Browse files
committed
Handle Get and Scan with conjunctions correctly in Consensus Commit (#2786)
1 parent 918cd8a commit 2be0e0b

File tree

5 files changed

+1550
-98
lines changed

5 files changed

+1550
-98
lines changed

core/src/main/java/com/scalar/db/api/ConditionBuilder.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@ public static ConditionalExpression buildConditionalExpression(
135135
return new ConditionalExpression(column, operator);
136136
}
137137

138+
/**
139+
* Builds a like expression with the specified column, operator, and escape character.
140+
*
141+
* <p>This method is primarily for internal use. Breaking changes can and will be introduced to
142+
* this method. Users should not depend on it.
143+
*
144+
* @param column a target text column used to compare
145+
* @param operator an operator used to compare the target column. The operator must be either LIKE
146+
* or NOT_LIKE.
147+
* @param escape an escape character for the like operator
148+
* @return a conditional expression
149+
*/
150+
public static ConditionalExpression buildLikeExpression(
151+
TextColumn column, Operator operator, String escape) {
152+
return new LikeExpression(column, operator, escape);
153+
}
154+
138155
/**
139156
* Returns a builder object for a condition expression for PutIf/DeleteIf
140157
*
@@ -352,6 +369,7 @@ public ConditionalExpression isNotEqualToBlob(byte[] value) {
352369
public ConditionalExpression isNotEqualToBlob(ByteBuffer value) {
353370
return new ConditionalExpression(columnName, value, Operator.NE);
354371
}
372+
355373
/**
356374
* Creates a 'not equal' conditional expression for a DATE value.
357375
*
@@ -391,6 +409,7 @@ public ConditionalExpression isNotEqualToTimestamp(LocalDateTime value) {
391409
public ConditionalExpression isNotEqualToTimestampTZ(Instant value) {
392410
return new ConditionalExpression(TimestampTZColumn.of(columnName, value), Operator.NE);
393411
}
412+
394413
/**
395414
* Creates a 'greater than' conditional expression for a BOOLEAN value.
396415
*
@@ -590,6 +609,7 @@ public ConditionalExpression isGreaterThanOrEqualToBlob(byte[] value) {
590609
public ConditionalExpression isGreaterThanOrEqualToBlob(ByteBuffer value) {
591610
return new ConditionalExpression(columnName, value, Operator.GTE);
592611
}
612+
593613
/**
594614
* Creates a 'greater than or equal' conditional expression for a DATE value.
595615
*
@@ -709,6 +729,7 @@ public ConditionalExpression isLessThanBlob(byte[] value) {
709729
public ConditionalExpression isLessThanBlob(ByteBuffer value) {
710730
return new ConditionalExpression(columnName, value, Operator.LT);
711731
}
732+
712733
/**
713734
* Creates a 'less than' conditional expression for a DATE value.
714735
*
@@ -748,6 +769,7 @@ public ConditionalExpression isLessThanTimestamp(LocalDateTime value) {
748769
public ConditionalExpression isLessThanTimestampTZ(Instant value) {
749770
return new ConditionalExpression(TimestampTZColumn.of(columnName, value), Operator.LT);
750771
}
772+
751773
/**
752774
* Creates a 'less than or equal' conditional expression for a BOOLEAN value.
753775
*
@@ -1029,6 +1051,7 @@ public ConditionalExpression isNotNullText() {
10291051
public ConditionalExpression isNotNullBlob() {
10301052
return new ConditionalExpression(BlobColumn.ofNull(columnName), Operator.IS_NOT_NULL);
10311053
}
1054+
10321055
/**
10331056
* Creates an 'is not null' conditional expression for a DATE value.
10341057
*

core/src/main/java/com/scalar/db/api/LikeExpression.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ public class LikeExpression extends ConditionalExpression {
1616
* Constructs a {@code LikeExpression} with the specified column and operator. For the escape
1717
* character, the default one ("\", i.e., backslash) is used.
1818
*
19-
* @param column a target column used to compare
20-
* @param operator an operator used to compare the target column
19+
* @param column a target text column used to compare
20+
* @param operator an operator used to compare the target text column. The operator must be either
21+
* LIKE or NOT_LIKE.
2122
*/
2223
LikeExpression(TextColumn column, Operator operator) {
2324
this(column, operator, DEFAULT_ESCAPE_CHAR);
@@ -28,8 +29,9 @@ public class LikeExpression extends ConditionalExpression {
2829
* The escape character must be a string of a single character or an empty string. If an empty
2930
* string is specified, the escape character is disabled.
3031
*
31-
* @param column a target column used to compare
32-
* @param operator an operator used to compare the target column
32+
* @param column a target text column used to compare
33+
* @param operator an operator used to compare the target text column. The operator must be either
34+
* LIKE or NOT_LIKE.
3335
* @param escape an escape character for the like operator
3436
*/
3537
LikeExpression(TextColumn column, Operator operator, String escape) {
@@ -75,6 +77,11 @@ private void check(String pattern, Operator operator, String escape) {
7577
}
7678
}
7779

80+
@Override
81+
public TextColumn getColumn() {
82+
return (TextColumn) super.getColumn();
83+
}
84+
7885
/**
7986
* Returns the escape character for LIKE operator.
8087
*

0 commit comments

Comments
 (0)