Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public abstract static class Builder<T extends Builder<T>> {

protected Builder(@Nonnull Subspace subspace) {
this.subspace = subspace;
this.serializationMode = SerializationMode.TO_OLD;
this.serializationMode = SerializationMode.TO_NEW;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public RecordQueryIndexPlan(@Nonnull final String indexName,
@Nonnull final Optional<? extends MatchCandidate> matchCandidateOptional,
@Nonnull final Type resultType,
@Nonnull final QueryPlanConstraint constraint) {
this(indexName, commonPrimaryKey, scanParameters, indexFetchMethod, fetchIndexRecords, reverse, strictlySorted, matchCandidateOptional, resultType, constraint, KeyValueCursorBase.SerializationMode.TO_OLD);
this(indexName, commonPrimaryKey, scanParameters, indexFetchMethod, fetchIndexRecords, reverse, strictlySorted, matchCandidateOptional, resultType, constraint, KeyValueCursorBase.SerializationMode.TO_NEW);
}

@VisibleForTesting
Expand Down Expand Up @@ -834,7 +834,7 @@ public byte[] toBytes() {
if (bytes == null) {
synchronized (this) {
if (bytes == null) {
bytes = KeyValueCursorBase.Continuation.getInnerContinuation(new KeyValueCursorBase.Continuation(KeyValueCursorBase.Continuation.getInnerContinuation(baseContinuation.toBytes()), prefixLength, serializationMode).toBytes());
bytes = new KeyValueCursorBase.Continuation(KeyValueCursorBase.Continuation.getInnerContinuation(baseContinuation.toBytes()), prefixLength, serializationMode).toBytes();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a mistake I made in the last PR. When we are in TO_OLD, it returns the same result as the modified version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that makes sense. And walking through this, this only affected producing new continuations, not reading new continuations, so we should still be good to update the behavior to TO_NEW in this PR

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void explainWithContinuationSerializedPlanTest() throws Exception {
final var continuationInfo = resultSet.getStruct(5);
org.junit.jupiter.api.Assertions.assertNotNull(continuationInfo);
final var assertStruct = RelationalStructAssert.assertThat(continuationInfo);
assertStruct.hasValue("EXECUTION_STATE", new byte[]{0, 21, 1, 21, 11});
assertStruct.hasValue("EXECUTION_STATE", new byte[]{10, 5, 0, 21, 1, 21, 11, 17, -84, -51, 115, -104, -35, 66, 0, 94});
assertStruct.hasValue("VERSION", 1);
assertStruct.hasValue("PLAN_HASH_MODE", "VC0");
assertStruct.hasValue("PLAN_HASH", -1635569052);
Expand Down Expand Up @@ -167,7 +167,7 @@ void explainWithContinuationSerializedPlanWithDifferentQueryTest() throws Except
final var continuationInfo = resultSet.getStruct(5);
org.junit.jupiter.api.Assertions.assertNotNull(continuationInfo);
final var assertStruct = RelationalStructAssert.assertThat(continuationInfo);
assertStruct.hasValue("EXECUTION_STATE", new byte[]{0, 21, 1, 21, 11});
assertStruct.hasValue("EXECUTION_STATE", new byte[]{10, 5, 0, 21, 1, 21, 11, 17, -84, -51, 115, -104, -35, 66, 0, 94});
assertStruct.hasValue("VERSION", 1);
assertStruct.hasValue("PLAN_HASH_MODE", "VC0");
assertStruct.hasValue("PLAN_HASH", -1635569052);
Expand Down Expand Up @@ -199,7 +199,7 @@ void explainExecuteStatementTest() throws Exception {
final var continuationInfo = resultSet.getStruct(5);
org.junit.jupiter.api.Assertions.assertNotNull(continuationInfo);
final var assertStruct = RelationalStructAssert.assertThat(continuationInfo);
assertStruct.hasValue("EXECUTION_STATE", new byte[]{0, 21, 1, 21, 11});
assertStruct.hasValue("EXECUTION_STATE", new byte[]{10, 5, 0, 21, 1, 21, 11, 17, -84, -51, 115, -104, -35, 66, 0, 94});
assertStruct.hasValue("VERSION", 1);
assertStruct.hasValue("PLAN_HASH_MODE", "VC0");
assertStruct.hasValue("PLAN_HASH", -1635569052);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package com.apple.foundationdb.relational.recordlayer.query;

import com.apple.foundationdb.relational.api.Continuation;
import com.apple.foundationdb.relational.api.exceptions.ContextualSQLException;
import com.apple.foundationdb.relational.recordlayer.EmbeddedRelationalExtension;
import com.apple.foundationdb.relational.recordlayer.RelationalConnectionRule;
import com.apple.foundationdb.relational.recordlayer.RelationalStatementRule;
Expand All @@ -31,7 +30,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -94,26 +92,7 @@ void setup() throws Exception {
statement.execute("delete from t3");
}

@ParameterizedTest
@MethodSource("failedQueries")
void testOldSerializationFails(String sql, long result) throws Exception {
Continuation continuation;
statement.setMaxRows(1);
try (var resultSet = statement.executeQuery(sql)) {
Assertions.assertTrue(resultSet.next());
Assertions.assertEquals(result, resultSet.getLong(1));
continuation = resultSet.getContinuation();
}
// old kvCursorContinuation cause continuation at beginning exception
try (final var preparedStatement = connection.prepareStatement("EXECUTE CONTINUATION ?param")) {
preparedStatement.setMaxRows(1);
preparedStatement.setBytes("param", continuation.serialize());
Assertions.assertThrows(ContextualSQLException.class, preparedStatement::executeQuery);
}
}

// disabled until SerializationMode = TO_NEW
@Disabled
@ParameterizedTest
@MethodSource("failedQueries")
void testNewSerialization(String sql, long result) throws Exception {
Expand Down
18 changes: 18 additions & 0 deletions yaml-tests/src/test/resources/aggregate-index-tests-count.yamsql
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ test_block:
# Cannot run with FORCE_CONTINUATIONS due to: https://github.com/FoundationDB/fdb-record-layer/issues/3206
- maxRows: 0
- result: [{4}]
-
- query: select count(*) from t1
- explain: "AISCAN(MV1 <,> BY_GROUP -> [_0: VALUE:[0]]) | MAP (_ AS _0) | ON EMPTY NULL | MAP (coalesce_long(_._0._0, promote(0l AS LONG)) AS _0)"
# https://github.com/FoundationDB/fdb-record-layer/issues/3206 is fixed since !current_version
- maxRows: 1
- initialVersionAtLeast: !current_version
- result: [{4}]
- result: []
- initialVersionLessThan: !current_version
-
- query: select count(*) from t1 group by col2
- explain: "AISCAN(MV2 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) | MAP (_._1 AS _0)"
Expand All @@ -60,6 +69,15 @@ test_block:
# Cannot run with FORCE_CONTINUATIONS due to: https://github.com/FoundationDB/fdb-record-layer/issues/3206
- maxRows: 0
- result: [{2}]
-
- query: select count(col1) from t1
- explain: "AISCAN(MV3 <,> BY_GROUP -> [_0: VALUE:[0]]) | MAP (_ AS _0) | ON EMPTY NULL | MAP (coalesce_long(_._0._0, promote(0l AS LONG)) AS _0)"
# https://github.com/FoundationDB/fdb-record-layer/issues/3206 is fixed since !current_version
- maxRows: 1
- initialVersionAtLeast: !current_version
- result: [{2}]
- result: []
- initialVersionLessThan: !current_version
-
- query: select count(col1) from t1 group by col2
- explain: "AISCAN(MV4 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) | MAP (_._1 AS _0)"
Expand Down
Loading