Import org.apache.spark.SparkConf;
Import Org.apache.spark.api.java.JavaSparkContext;
Import Org.apache.spark.sql.DataFrame;
Import Org.apache.spark.sql.SQLContext;
Import Org.apache.spark.sql.SaveMode;
/**
* @author Administrator
* * *
/Public
class Genericloadsave {public
static void Main (string[) args) {
sparkconf conf = new sparkconf ()
. Setappname ("Genericloadsave")
. Setmaster ("local");
Javasparkcontext sc = new Javasparkcontext (conf);
SqlContext sqlcontext = new SqlContext (SC);
Parquet with table structure ...
dataframe usersdf = Sqlcontext.read (). Load ( "Hdfs://hadoop1:9000/input/users.parquet"); format is not specified is the data formatting written to disk defaults to parquet
usersdf.select ("name", "Favorite_Color"). Write (). Mode ( Savemode.overwrite). Save ("Hdfs://hadoop1:9000/output/namesandfavcolors_scala");
Dataframe PDF = Sqlcontext.read (). Parquet ("Hdfs://hadoop1:9000/output/namesandfavcolors_scala");
Pdf.show ();
}