Search in sources :

Example 1 with HashShuffle

use of org.apache.flink.table.planner.plan.nodes.exec.ExecEdge.HashShuffle in project flink by apache.

the class ShuffleJsonSerializer method serialize.

@Override
public void serialize(Shuffle shuffle, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
    jsonGenerator.writeStartObject();
    Shuffle.Type type = shuffle.getType();
    jsonGenerator.writeStringField("type", type.name());
    switch(type) {
        case ANY:
        case SINGLETON:
        case BROADCAST:
        case FORWARD:
            // do nothing, type name is enough
            break;
        case HASH:
            HashShuffle hashShuffle = (HashShuffle) shuffle;
            jsonGenerator.writeFieldName("keys");
            jsonGenerator.writeArray(hashShuffle.getKeys(), // offset
            0, hashShuffle.getKeys().length);
            break;
        default:
            throw new TableException("Unsupported shuffle type: " + type);
    }
    jsonGenerator.writeEndObject();
}
Also used : TableException(org.apache.flink.table.api.TableException) Shuffle(org.apache.flink.table.planner.plan.nodes.exec.ExecEdge.Shuffle) HashShuffle(org.apache.flink.table.planner.plan.nodes.exec.ExecEdge.HashShuffle) HashShuffle(org.apache.flink.table.planner.plan.nodes.exec.ExecEdge.HashShuffle)

Aggregations

TableException (org.apache.flink.table.api.TableException)1 HashShuffle (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge.HashShuffle)1 Shuffle (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge.Shuffle)1