use of com.google.api.ads.admanager.axis.v202105.ResultSet in project beam by apache.
the class SpannerChangeStreamErrorTest method mockInvalidChangeStreamRecordReceived.
private void mockInvalidChangeStreamRecordReceived(Timestamp now, Timestamp after3Seconds) {
Statement changeStreamQueryStatement = Statement.newBuilder("SELECT * FROM READ_my-change-stream( start_timestamp => @startTimestamp, end_timestamp => @endTimestamp, partition_token => @partitionToken, read_options => null, heartbeat_milliseconds => @heartbeatMillis)").bind("startTimestamp").to(now).bind("endTimestamp").to(after3Seconds).bind("partitionToken").to((String) null).bind("heartbeatMillis").to(500).build();
ResultSetMetadata readChangeStreamResultSetMetadata = ResultSetMetadata.newBuilder().setRowType(StructType.newBuilder().addFields(Field.newBuilder().setName("COL1").setType(Type.newBuilder().setCode(TypeCode.ARRAY).setArrayElementType(Type.newBuilder().setCode(TypeCode.STRUCT).setStructType(StructType.newBuilder().addFields(Field.newBuilder().setName("field_name").setType(Type.newBuilder().setCode(TypeCode.STRUCT).setStructType(StructType.newBuilder().addFields(Field.newBuilder().setType(Type.newBuilder().setCode(TypeCode.STRING))))))))))).build();
ResultSet readChangeStreamResultSet = ResultSet.newBuilder().addRows(ListValue.newBuilder().addValues(Value.newBuilder().setListValue(ListValue.newBuilder().addValues(Value.newBuilder().setListValue(ListValue.newBuilder().addValues(Value.newBuilder().setListValue(ListValue.newBuilder().addValues(Value.newBuilder().setStringValue("bad_value"))))))))).setMetadata(readChangeStreamResultSetMetadata).build();
mockSpannerService.putStatementResult(StatementResult.query(changeStreamQueryStatement, readChangeStreamResultSet));
}
use of com.google.api.ads.admanager.axis.v202105.ResultSet in project beam by apache.
the class SpannerChangeStreamErrorTest method testInvalidRecordReceived.
@Test
public void testInvalidRecordReceived() {
final Timestamp now = Timestamp.now();
final Timestamp after3Seconds = Timestamp.ofTimeSecondsAndNanos(now.getSeconds() + 3, now.getNanos());
mockTableExists();
ResultSet getPartitionResultSet = mockGetParentPartition(now, after3Seconds);
mockGetWatermark(now);
mockGetPartitionsAfter(Timestamp.ofTimeSecondsAndNanos(now.getSeconds(), now.getNanos() + 1000), getPartitionResultSet);
mockGetPartitionsAfter(Timestamp.ofTimeSecondsAndNanos(now.getSeconds(), now.getNanos() - 1000), getPartitionResultSet);
mockInvalidChangeStreamRecordReceived(now, after3Seconds);
try {
pipeline.apply(SpannerIO.readChangeStream().withSpannerConfig(getSpannerConfig()).withChangeStreamName(TEST_CHANGE_STREAM).withMetadataDatabase(TEST_DATABASE).withMetadataTable(TEST_TABLE).withInclusiveStartAt(now).withInclusiveEndAt(after3Seconds));
pipeline.run().waitUntilFinish();
} finally {
thrown.expect(PipelineExecutionException.class);
thrown.expectMessage("Field not found");
}
}
use of com.google.api.ads.admanager.axis.v202105.ResultSet in project beam by apache.
the class SpannerChangeStreamErrorTest method mockGetWatermark.
private void mockGetWatermark(Timestamp now) {
Statement watermarkStatement = Statement.newBuilder("SELECT Watermark FROM my-metadata-table WHERE State != @state ORDER BY Watermark ASC LIMIT 1").bind("state").to(State.FINISHED.name()).build();
ResultSetMetadata watermarkResultSetMetadata = ResultSetMetadata.newBuilder().setRowType(StructType.newBuilder().addFields(Field.newBuilder().setName("Watermark").setType(Type.newBuilder().setCode(TypeCode.TIMESTAMP).build()).build()).build()).build();
ResultSet watermarkResultSet = ResultSet.newBuilder().addRows(ListValue.newBuilder().addValues(Value.newBuilder().setStringValue(now.toString()).build()).build()).setMetadata(watermarkResultSetMetadata).build();
mockSpannerService.putStatementResult(StatementResult.query(watermarkStatement, watermarkResultSet));
}
use of com.google.api.ads.admanager.axis.v202105.ResultSet in project cassandra by apache.
the class BurnTestUtil method generateRows.
public static ResultMessage.Rows generateRows(int idx, SizeCaps sizeCaps) {
Random rnd = new Random(idx);
List<ColumnSpecification> columns = new ArrayList<>();
for (int i = 0; i < sizeCaps.columnCountCap; i++) {
columns.add(new ColumnSpecification("ks", "cf", new ColumnIdentifier(bytes(rnd, 5, 10), BytesType.instance), BytesType.instance));
}
List<List<ByteBuffer>> rows = new ArrayList<>();
int count = rnd.nextInt(sizeCaps.rowsCountCap);
for (int i = 0; i < count; i++) {
List<ByteBuffer> row = new ArrayList<>();
for (int j = 0; j < sizeCaps.columnCountCap; j++) row.add(bytes(rnd, sizeCaps.valueMinSize, sizeCaps.valueMaxSize));
rows.add(row);
}
ResultSet resultSet = new ResultSet(new ResultSet.ResultMetadata(columns), rows);
return new ResultMessage.Rows(resultSet);
}
use of com.google.api.ads.admanager.axis.v202105.ResultSet in project cassandra by apache.
the class ListUsersStatement method formatResults.
@Override
protected ResultMessage formatResults(List<RoleResource> sortedRoles) {
ResultSet.ResultMetadata resultMetadata = new ResultSet.ResultMetadata(metadata);
ResultSet result = new ResultSet(resultMetadata);
IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
INetworkAuthorizer networkAuthorizer = DatabaseDescriptor.getNetworkAuthorizer();
for (RoleResource role : sortedRoles) {
if (!roleManager.canLogin(role))
continue;
result.addColumnValue(UTF8Type.instance.decompose(role.getRoleName()));
result.addColumnValue(BooleanType.instance.decompose(Roles.hasSuperuserStatus(role)));
result.addColumnValue(UTF8Type.instance.decompose(networkAuthorizer.authorize(role).toString()));
}
return new ResultMessage.Rows(result);
}
Aggregations