[SPARK-2314][SQL] Override collect and take in python library, and count in java library, with optimized versions.