private int createStateInputStreamExecutors(StateElement stateElement, Partition partition, MetaStateEvent
            metaEvent, List<VariableExpressionExecutor> executors,
                                                int executorIndex, SiddhiQueryContext siddhiQueryContext) {

        if (stateElement instanceof EveryStateElement) {
            return createStateInputStreamExecutors(((EveryStateElement) stateElement).getStateElement(), partition,
                    metaEvent, executors, executorIndex, siddhiQueryContext);
        } else if (stateElement instanceof NextStateElement) {
            executorIndex = createStateInputStreamExecutors(((NextStateElement) stateElement).getStateElement(),
                    partition, metaEvent, executors, executorIndex, siddhiQueryContext);
            return createStateInputStreamExecutors(((NextStateElement) stateElement).getNextStateElement(),
                    partition, metaEvent, executors, executorIndex, siddhiQueryContext);
        } else if (stateElement instanceof LogicalStateElement) {
            executorIndex = createStateInputStreamExecutors(((LogicalStateElement) stateElement)
                            .getStreamStateElement1(), partition, metaEvent, executors, executorIndex,
                    siddhiQueryContext);
            return createStateInputStreamExecutors(((LogicalStateElement) stateElement).getStreamStateElement2(),
                    partition, metaEvent, executors, executorIndex, siddhiQueryContext);
        } else if (stateElement instanceof CountStateElement) {
            return createStateInputStreamExecutors(((CountStateElement) stateElement).getStreamStateElement(),
                    partition, metaEvent, executors, executorIndex, siddhiQueryContext);
        } else {  //when stateElement is an instanceof StreamStateElement
            int size = executors.size();
            createExecutors(((StreamStateElement) stateElement).getBasicSingleInputStream(), partition, metaEvent
                    .getMetaStreamEvent(executorIndex), executors, siddhiQueryContext);
            for (int j = size; j < executors.size(); j++) {
                executors.get(j).getPosition()[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX] = executorIndex;
            }
            return ++executorIndex;
        }
    }
create PartitionExecutors to be used to get partitioning key
modules/siddhi-core/src/main/java/io/siddhi/core/partition/StreamPartitioner.java