Github user jose-torres commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21428#discussion_r191618218
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/continuous/shuffle/RPCContinuousShuffleWriter.scala
 ---
    @@ -0,0 +1,54 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.execution.streaming.continuous.shuffle
    +
    +import org.apache.spark.Partitioner
    +import org.apache.spark.rpc.RpcEndpointRef
    +import org.apache.spark.sql.catalyst.expressions.UnsafeRow
    +
    +/**
    + * A [[ContinuousShuffleWriter]] sending data to 
[[RPCContinuousShuffleReader]] instances.
    + *
    + * @param writerId          The partition ID of this writer.
    + * @param outputPartitioner The partitioner on the reader side of the 
shuffle.
    + * @param endpoints         The [[RPCContinuousShuffleReader]] endpoints 
to write to. Indexed by
    + *                          partition ID within outputPartitioner.
    + */
    +class RPCContinuousShuffleWriter(
    +    writerId: Int,
    +    outputPartitioner: Partitioner,
    +    endpoints: Array[RpcEndpointRef]) extends ContinuousShuffleWriter {
    +
    +  if (outputPartitioner.numPartitions != 1) {
    +    throw new IllegalArgumentException("multiple readers not yet 
supported")
    +  }
    +
    +  if (outputPartitioner.numPartitions != endpoints.length) {
    +    throw new IllegalArgumentException(s"partitioner size 
${outputPartitioner.numPartitions} did " +
    +      s"not match endpoint count ${endpoints.length}")
    +  }
    +
    +  def write(epoch: Iterator[UnsafeRow]): Unit = {
    +    while (epoch.hasNext) {
    +      val row = epoch.next()
    +      
endpoints(outputPartitioner.getPartition(row)).ask[Unit](ReceiverRow(writerId, 
row))
    --- End diff --
    
    cc @zsxwing 
    
    It's my understanding that the RPC framework guarantees messages will be 
sent in the order that they're ask()ed, and that it's therefore not possible 
for a single row to fail to be sent while the ones before and after it succeed. 
If this is the case, then we don't need to handle it here - the query will just 
start failing to make progress.
    
    If it's not the case, we'll need a more clever solution. Maybe have the 
epoch marker message contain a count for the number of rows that are supposed 
to be in the epoch?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to