A framework for mediation analysis with massive data