Suppose I get a stream after a keyed process.
DataStream<T> stream= sourceStream.keyBy(key).window(window).apply(function);
Is the resulting stream still keyed? Can I use some Keyed state in that stream?
That's correct, the output of a keyed window or a keyed process function is no longer a keyed stream. Flink has no way of knowing whether the computation you have performed will have preserved the partitioning that was in place beforehand.
To use keyed state, you will need to either re-key the stream, or if you are certain that the original keying has been preserved, you can use reinterpretAsKeyedStream to inform Flink that the stream is still keyed.