Skip to content

Commit

Permalink
Records implementation (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelshreyak committed Feb 25, 2024
1 parent a69154d commit 899885a
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 171 deletions.
310 changes: 155 additions & 155 deletions .idea/artifacts/fast_data_analyzer_jar.xml → .idea/artifacts/edass.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: Main
Main-Class: com.edass.Main

13 changes: 5 additions & 8 deletions src/com/edass/Analysis/AnalysisEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,26 @@
import org.apache.spark.sql.SparkSession;
/**
* The main Analysis Engine powered by Apache Spark
* For efficiency it creates and persists the session
*/
public class AnalysisEngine {
private SparkSession spark;
private SparkSession spark; //For efficiency, it creates and persists the session
private Dataset<Row> df;
public void initSession(){
SparkSession session = SparkSession
this.spark = SparkSession
.builder()
.appName("Java Spark SQL CSV Reader")
.master("local")
.getOrCreate();
this.spark = session;
System.out.println("------EDASS Analysis Engine started-------");
}
public void loadDataFrame(String filePath,String format) {
try {
Dataset<Row> df = this.spark.read()
this.df = this.spark.read()
.format(format)
.option("header", "true") // Use first line of all files as header
.option("treatEmptyValuesAsNulls", "true")
.option("inferSchema", "true") // Automatically infer data types
.load(filePath);
this.df = df;
}
catch (Exception e){
System.out.println(e.getMessage());
Expand All @@ -43,7 +40,7 @@ public void stopSession(){
System.out.println("------EDASS Analysis Engine stopped-------");
}

public void descriptiveStats(){
this.df.describe().show();
public Dataset<Row> descriptiveStats(){
return this.df.describe();
}
}
3 changes: 1 addition & 2 deletions src/com/edass/Analysis/AnalysisUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;


public class AnalysisUtilities {
public static String[][] dataframeToRows(Dataset<Row> df,int preview_rows){
// Get all rows as a list
Expand Down
21 changes: 18 additions & 3 deletions src/com/edass/GUI/EdassGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

import com.edass.Analysis.AnalysisEngine;
import com.edass.Analysis.AnalysisUtilities;
import com.edass.Record.EdassRecord;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
* Handles all GUI operations on EDASS
*/
public class EdassGUI implements ActionListener {
JFrame frame;

Expand All @@ -18,6 +22,8 @@ public class EdassGUI implements ActionListener {

AnalysisEngine engine;

EdassRecord[] records;

public EdassGUI(AnalysisEngine analysis_engine){
JFrame frame = new JFrame("EDASS 1.0");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Expand Down Expand Up @@ -64,20 +70,29 @@ private void fileImport(){
}
}

private void analysisSummary(){
Dataset<Row> dataset_summary = engine.descriptiveStats();
showDataTable(dataset_summary);
}

public void actionPerformed(ActionEvent e) {
if(e.getSource() == file_import){
fileImport();
}
else if(e.getSource() == analysis_summary){
analysisSummary();
}
}

public void showDataTable(Dataset<Row> df){
String[][] rows = AnalysisUtilities.dataframeToRows(df,50);
String[] columns = engine.getDataFrame().columns();
JTable data_table = new JTable(rows,columns);
JFrame new_window = new JFrame("Data View");
new_window.setSize(400, 400);
data_table.setBounds(30,40,200,300);
JScrollPane sp=new JScrollPane(data_table);
frame.getContentPane().removeAll();
frame.getContentPane().add(sp);
frame.setVisible(true);
new_window.getContentPane().add(sp);
new_window.setVisible(true);
}
}
2 changes: 1 addition & 1 deletion src/Main.java → src/com/edass/Main.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.edass;
import com.edass.Analysis.AnalysisEngine;
import com.edass.GUI.EdassGUI;

Expand Down Expand Up @@ -29,7 +30,6 @@ public void windowClosing(WindowEvent e)
}
catch (Exception e){
System.out.println(e.getMessage());
System.out.println(e.toString());
}
}
}
18 changes: 18 additions & 0 deletions src/com/edass/Record/EdassRecord.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.edass.Record;

/**
* Represents an operation (Analysis, Transformation etc.) on EDASS which can be stored and executed at a later time
*/
public class EdassRecord {

}


class AnalysisRecord extends EdassRecord{

}


class TransformationRecord extends EdassRecord{

}
Binary file removed target/classes/Main$1.class
Binary file not shown.
Binary file removed target/classes/Main.class
Binary file not shown.
Binary file modified target/classes/com/edass/Analysis/AnalysisEngine.class
Binary file not shown.
Binary file modified target/classes/com/edass/GUI/EdassGUI.class
Binary file not shown.

0 comments on commit 899885a

Please sign in to comment.