bda-datastore/src/main/java/gr/ntua/ece/cslab/selis/bda/datastore/connectors/DatastoreLocalFSConnector.java
public void put(MasterData masterData) throws Exception {
        for (DimensionTable table: masterData.getTables()) {
            String output = table.getName() + ".csv"; // save in csv
            FileWriter fw = new FileWriter(conn.getFS() + '/' + output);
            BufferedWriter bw = new BufferedWriter(fw);

            List<Tuple> data = table.getData();
            // write column names
            List<KeyValue> fields = data.get(0).getTuple();
            for (KeyValue element : fields)
                bw.write(element.getKey() + "\t");
            bw.newLine();
            // fill-in column values
            for (Tuple tuple : data) {
                for (KeyValue element : tuple.getTuple())
                    bw.write(element.getValue() + "\t");
                bw.newLine();
            }
            bw.close();
            fw.close();
        }
    }
// Create table, populate it and store it in csv file
Create table, populate it and store it in csv file
Create table populate it and store it in csv file
public void put(MasterData masterData) throws Exception {
        for (DimensionTable table: masterData.getTables()) {
            String output = table.getName() + ".csv"; 
            FileWriter fw = new FileWriter(conn.getFS() + '/' + output);
            BufferedWriter bw = new BufferedWriter(fw);
            List<Tuple> data = table.getData();
            List<KeyValue> fields = data.get(0).getTuple();
            for (KeyValue element : fields)
                bw.write(element.getKey() + "\t");
            bw.newLine();
            for (Tuple tuple : data) {
                for (KeyValue element : tuple.getTuple())
                    bw.write(element.getValue() + "\t");
                bw.newLine();
            }
            bw.close();
            fw.close();
        }
    }
public void put ( MasterData masterData ) throws Exception { for ( DimensionTable table : masterData . getTables ( ) ) { String output = table . getName ( ) + ".csv" ; FileWriter fw = new FileWriter ( conn . getFS ( ) + '/' + output ) ; BufferedWriter bw = new BufferedWriter ( fw ) ; List < Tuple > data = table . getData ( ) ; List < KeyValue > fields = data . get ( 0 ) . getTuple ( ) ; for ( KeyValue element : fields ) bw . write ( element . getKey ( ) + "\t" ) ; bw . newLine ( ) ; for ( Tuple tuple : data ) { for ( KeyValue element : tuple . getTuple ( ) ) bw . write ( element . getValue ( ) + "\t" ) ; bw . newLine ( ) ; } bw . close ( ) ; fw . close ( ) ; } }
Create table, populate it and store it in csv file
Create table populate it and store it in csv file
// save in csv // write column names // fill-in column values