Hierarchical subspace sampling: a unified framework for high dimensional data reduction, selectivity estimation and nearest neig