Search in sources :

Example 1 with QueryRow

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());
}
Also used : GenericRow(io.confluent.ksql.GenericRow) QueryRow(io.confluent.ksql.physical.common.QueryRow) PullProcessingContext(io.confluent.ksql.execution.streams.materialization.PullProcessingContext)

Example 2 with QueryRow

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;
}
Also used : QueryRow(io.confluent.ksql.physical.common.QueryRow) ProcessingQueue(io.confluent.ksql.physical.scalablepush.ProcessingQueue)

Example 3 with QueryRow

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;
}
Also used : GenericRow(io.confluent.ksql.GenericRow) List(java.util.List) GenericRow(io.confluent.ksql.GenericRow) QueryRow(io.confluent.ksql.physical.common.QueryRow) GenericKey(io.confluent.ksql.GenericKey) GenericKey(io.confluent.ksql.GenericKey)

Example 4 with QueryRow

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();
}
Also used : QueryRow(io.confluent.ksql.physical.common.QueryRow)

Example 5 with QueryRow

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"));
}
Also used : QueryRow(io.confluent.ksql.physical.common.QueryRow) BufferedPublisher(io.confluent.ksql.reactive.BufferedPublisher) TransientQueryQueue(io.confluent.ksql.query.TransientQueryQueue) PushConnectionsHandle(io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Aggregations

QueryRow (io.confluent.ksql.physical.common.QueryRow)14 PullProcessingContext (io.confluent.ksql.execution.streams.materialization.PullProcessingContext)8 Test (org.junit.Test)8 QueryRowImpl (io.confluent.ksql.physical.common.QueryRowImpl)7 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)5 ArrayList (java.util.ArrayList)4 GenericRow (io.confluent.ksql.GenericRow)2 ProcessingQueue (io.confluent.ksql.physical.scalablepush.ProcessingQueue)2 List (java.util.List)2 ImmutableList (com.google.common.collect.ImmutableList)1 GenericKey (io.confluent.ksql.GenericKey)1 PushConnectionsHandle (io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle)1 TransientQueryQueue (io.confluent.ksql.query.TransientQueryQueue)1 BufferedPublisher (io.confluent.ksql.reactive.BufferedPublisher)1 PushOffsetRange (io.confluent.ksql.util.PushOffsetRange)1