src/main/java/org/apache/graphframe/gfjex/GraphFramesAppStub.java
/**
     * Store a DataFrame as Parquet file in a temp folder with one partition.
     * 
     * @param df
     * @param label 
     */
Store a DataFrame as Parquet file in a temp folder with one partition.

@param df
@param label
Store a DataFrame as Parquet file in a temp folder with one partition . @param df @param label
public static void dumpDF( DataFrame df, String label) {
        long ts = System.currentTimeMillis();
        List<String> data = df.javaRDD().map(new Function<Row,String>() {
            public String call(Row row) {
                StringBuffer sb = new StringBuffer();
                int i = 0;
                while( i < row.length() ) {
                    if ( i > 0 ) sb.append(",");
                    sb.append( row.get(i));
                    i++;
                };
                return sb.toString();
            }
        }).collect();
        Iterator<String> list = data.iterator();
        System.out.println( "======================================================================" );
        System.out.println( "DataFrame: " + label );
        System.out.println( "======================================================================" );
        while( list.hasNext() ) {
            String n = list.next();
            System.out.println( n.substring(0, n.length()) );
        }
        System.out.println( "======================================================================" );
        df.coalesce(1).write().parquet( "temp/" + label + "-" + ts + ".parquet");
        System.out.println( "Path: " + "temp/" + label + "-" + ts + ".parquet" );
        System.out.println( "======================================================================\n\n" );
    }
public static void dumpDF ( DataFrame df , String label ) { long ts = System . currentTimeMillis ( ) ; List < String > data = df . javaRDD ( ) . map ( new Function < Row , String > ( ) { public String call ( Row row ) { StringBuffer sb = new StringBuffer ( ) ; int i = 0 ; while ( i < row . length ( ) ) { if ( i > 0 ) sb . append ( "," ) ; sb . append ( row . get ( i ) ) ; i ++ ; } ; return sb . toString ( ) ; } } ) . collect ( ) ; Iterator < String > list = data . iterator ( ) ; System . out . println ( "======================================================================" ) ; System . out . println ( "DataFrame: " + label ) ; System . out . println ( "======================================================================" ) ; while ( list . hasNext ( ) ) { String n = list . next ( ) ; System . out . println ( n . substring ( 0 , n . length ( ) ) ) ; } System . out . println ( "======================================================================" ) ; df . coalesce ( 1 ) . write ( ) . parquet ( "temp/" + label + "-" + ts + ".parquet" ) ; System . out . println ( "Path: " + "temp/" + label + "-" + ts + ".parquet" ) ; System . out . println ( "======================================================================\n\n" ) ; }
Store a DataFrame as Parquet file in a temp folder with one partition.
Store a DataFrame as Parquet file in a temp folder with one partition .