use of io.confluent.ksql.physical.common.QueryRow in project ksql by confluentinc.
the class ProjectOperator method next.
@Override
public Object next() {
final QueryRow row = (QueryRow) child.next();
if (row == null) {
return null;
}
if (row.getOffsetRange().isPresent()) {
return row;
}
final GenericRow intermediate = PhysicalOperatorUtil.getIntermediateRow(row, logicalNode.getAddAdditionalColumnsToIntermediateSchema());
if (logicalNode.getIsSelectStar()) {
return QueryRowImpl.of(logicalNode.getSchema(), GenericKey.genericKey(), Optional.empty(), GenericRow.fromList(createRowForSelectStar(intermediate)), row.rowTime());
}
final GenericRow mapped = transformer.transform(row.key(), intermediate, new PullProcessingContext(row.rowTime()));
validateProjection(mapped, logicalNode.getSchema());
return QueryRowImpl.of(logicalNode.getSchema(), GenericKey.genericKey(), Optional.empty(), GenericRow.fromList(mapped.values()), row.rowTime());
}
use of io.confluent.ksql.physical.common.QueryRow in project ksql by confluentinc.
the class ScalablePushConsumer method handleRow.
private boolean handleRow(final Object key, final GenericRow value, final long timestamp) {
// We don't currently handle null in either field
if ((key == null && !logicalSchema.key().isEmpty()) || value == null) {
return false;
}
numRowsReceived.incrementAndGet();
for (ProcessingQueue queue : processingQueues.values()) {
try {
// The physical operators may modify the keys and values, so we make a copy to ensure
// that there's no cross-query interference.
final QueryRow row = RowUtil.createRow(key, value, timestamp, windowed, logicalSchema);
queue.offer(row);
afterOfferedRow(queue);
} catch (final Throwable t) {
LOG.error("Error while offering row", t);
}
}
return false;
}
use of io.confluent.ksql.physical.common.QueryRow in project ksql by confluentinc.
the class PhysicalOperatorUtil method getIntermediateRow.
static GenericRow getIntermediateRow(final QueryRow row, final boolean additionalColumnsNeeded) {
if (!additionalColumnsNeeded) {
return row.value();
}
final GenericKey key = row.key();
final GenericRow value = row.value();
final List<?> keyFields = key.values();
value.ensureAdditionalCapacity(// ROWTIME
1 + keyFields.size() + row.window().map(w -> 2).orElse(0));
value.append(row.rowTime());
value.appendAll(keyFields);
row.window().ifPresent(window -> {
value.append(window.start().toEpochMilli());
value.append(window.end().toEpochMilli());
});
return value;
}
use of io.confluent.ksql.physical.common.QueryRow in project ksql by confluentinc.
the class SelectOperator method next.
@Override
public Object next() {
Optional<QueryRow> result = Optional.empty();
while (result.equals(Optional.empty())) {
final QueryRow row = (QueryRow) child.next();
if (row == null) {
return null;
}
if (row.getOffsetRange().isPresent()) {
return row;
}
result = transformRow(row);
}
return result.get();
}
use of io.confluent.ksql.physical.common.QueryRow in project ksql by confluentinc.
the class PushRoutingTest method shouldFail_hitRequestLimitLocal.
@Test
public void shouldFail_hitRequestLimitLocal() throws ExecutionException, InterruptedException {
// Given:
transientQueryQueue = new TransientQueryQueue(OptionalInt.empty(), 1, 100);
when(pushRoutingOptions.getHasBeenForwarded()).thenReturn(true);
final PushRouting routing = new PushRouting();
BufferedPublisher<QueryRow> localPublisher = new BufferedPublisher<>(context);
when(pushPhysicalPlanManager.execute()).thenReturn(localPublisher);
// When:
final PushConnectionsHandle handle = handlePushRouting(routing);
context.runOnContext(v -> {
localPublisher.accept(LOCAL_ROW1);
localPublisher.accept(LOCAL_ROW2);
});
// Then:
Set<List<?>> rows = waitOnRows(1);
handle.close();
assertThat(rows.contains(LOCAL_ROW1.value().values()), is(true));
assertThat(handle.getError().getMessage(), containsString("Hit limit of request queue"));
}
Aggregations