dcapwell commented on code in PR #4328:
URL: https://github.com/apache/cassandra/pull/4328#discussion_r2294628650
##########
test/distributed/org/apache/cassandra/distributed/test/cql3/StatefulASTBase.java:
##########
@@ -686,82 +699,7 @@ protected ByteBuffer[][] executeQuery(IInstance instance,
int fetchSize, Consist
instance.executeInternal(stmt.toCQL(), (Object[])
stmt.bindsEncoded());
return new ByteBuffer[0][];
}
- else
- {
- SimpleStatement ss = new SimpleStatement(stmt.toCQL(),
(Object[]) stmt.bindsEncoded());
- if (fetchSize != Integer.MAX_VALUE)
- ss.setFetchSize(fetchSize);
- if (stmt.kind() == Statement.Kind.MUTATION)
- {
- switch (cl)
- {
- case SERIAL:
- ss.setSerialConsistencyLevel(toDriverCL(cl));
-
ss.setConsistencyLevel(com.datastax.driver.core.ConsistencyLevel.QUORUM);
- break;
- case LOCAL_SERIAL:
- ss.setSerialConsistencyLevel(toDriverCL(cl));
-
ss.setConsistencyLevel(com.datastax.driver.core.ConsistencyLevel.LOCAL_QUORUM);
- break;
- default:
- ss.setConsistencyLevel(toDriverCL(cl));
- }
- }
- else
- {
- ss.setConsistencyLevel(toDriverCL(cl));
- }
-
- InetSocketAddress broadcastAddress =
instance.config().broadcastAddress();
- var host = client.getMetadata().getAllHosts().stream()
- .filter(h ->
h.getBroadcastSocketAddress().getAddress().equals(broadcastAddress.getAddress()))
- .filter(h ->
h.getBroadcastSocketAddress().getPort() == broadcastAddress.getPort())
- .findAny()
- .get();
- ss.setHost(host);
- ResultSet result;
- try
- {
- result = session.execute(ss);
- }
- catch (ReadFailureException t)
- {
- throw new AssertionError("failed from=" +
Maps.transformValues(t.getFailuresMap(), BaseState::safeErrorCode), t);
- }
- catch (WriteFailureException t)
- {
- throw new AssertionError("failed from=" +
Maps.transformValues(t.getFailuresMap(), BaseState::safeErrorCode), t);
- }
- return getRowsAsByteBuffer(result);
- }
- }
-
- private static String safeErrorCode(Integer code)
- {
- try
- {
- return RequestFailureReason.fromCode(code).name();
- }
- catch (IllegalArgumentException e)
- {
- return "Unexpected code " + code + ": " + e.getMessage();
- }
- }
-
- @VisibleForTesting
- static ByteBuffer[][] getRowsAsByteBuffer(ResultSet result)
- {
- ColumnDefinitions columns = result.getColumnDefinitions();
- List<ByteBuffer[]> ret = new ArrayList<>();
- for (Row rowVal : result)
- {
- ByteBuffer[] row = new ByteBuffer[columns.size()];
- for (int i = 0; i < columns.size(); i++)
- row[i] = rowVal.getBytesUnsafe(i);
- ret.add(row);
- }
- ByteBuffer[][] a = new ByteBuffer[ret.size()][];
- return ret.toArray(a);
+ return DriverUtils.executeQuery(session, instance, fetchSize, cl,
stmt);
Review Comment:
this isn't required but its been something i wanted to do for awhile. I
started with the thinking i would create a new test, but then ended up just
reusing the existing tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]