D2KE: From Distance to Kernel and Embedding