Skip to content

Commit

Permalink
Add analytis a configurable module and can be enabled by passing para…
Browse files Browse the repository at this point in the history
…meter like '-a'
  • Loading branch information
Eugene-Mark committed Oct 5, 2021
1 parent 713f790 commit 8d17f65
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 5 deletions.
22 changes: 22 additions & 0 deletions src/main/java/org/eugene/App.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.eugene;

import javafx.application.Application;
import org.apache.commons.cli.*;
import org.eugene.config.Config;

/**
* Hello big data!
Expand All @@ -9,6 +11,26 @@
public class App
{
public static void main(String[] args) {
Options options = new Options();

Option analytics = new Option("a","analytics",false,"Enable analytics");
analytics.setRequired(false);
options.addOption(analytics);

CommandLineParser parser = new PosixParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd = null;

try{
cmd = parser.parse(options,args);
}catch(ParseException e){
System.out.println(e.getMessage());
formatter.printHelp("utility-name",options);
System.exit(1);
}

boolean enableAnalytics=(cmd.hasOption("analytics")||cmd.hasOption("a"));
Config.getInstance().setAnalytics(enableAnalytics);
Application.launch(FXApplication.class, args);
}
}
24 changes: 24 additions & 0 deletions src/main/java/org/eugene/config/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.eugene.config;

public class Config{
private Config(){
}

private static Config instance;
private boolean statistics;

public static Config getInstance(){
if(instance==null){
instance = new Config();
}
return instance;
}

public boolean enableAnalytics(){
return statistics;
}

public void setAnalytics(boolean statistics){
this.statistics = statistics;
}
}
5 changes: 4 additions & 1 deletion src/main/java/org/eugene/controller/DataParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.avro.Schema;
import org.apache.hadoop.fs.Path;
import org.eugene.config.Config;
import org.eugene.model.CommonData;
import org.eugene.model.TableMeta;
import org.eugene.persistent.PhysicalDB;
Expand Down Expand Up @@ -29,7 +30,9 @@ void persistData(Schema schema, Map<String, String> columnToType, List<List<Stri
VirtualDB.getInstance().setCommonData(commonData);
VirtualDB.getInstance().setTableMeta(tableMeta);

PhysicalDB.getInstance().persist(commonData);
if(Config.getInstance().enableAnalytics()){
PhysicalDB.getInstance().persist(commonData);
}
}
private String getName(Path path){
String regex = ".*[\\/|\\\\]([\\w]+)[.]?";
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/eugene/core/orc/ORCReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.hadoop.hive.ql.io.orc.RecordReader;
import org.apache.hadoop.hive.serde2.objectinspector.StructField;
import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.eugene.config.Config;
import org.eugene.model.CommonData;
import org.eugene.model.TableMeta;
import org.eugene.persistent.PhysicalDB;
Expand Down Expand Up @@ -67,7 +68,9 @@ public boolean read(Path path){
tableMeta.setRow(data.size());
VirtualDB.getInstance().setCommonData(commonData);
VirtualDB.getInstance().setTableMeta(tableMeta);
PhysicalDB.getInstance().persist(commonData);
if(Config.getInstance().enableAnalytics()){
PhysicalDB.getInstance().persist(commonData);
}
return true;
}catch(Exception e){
e.printStackTrace();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/eugene/persistent/PhysicalDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static PhysicalDB getInstance(){
public boolean persist(CommonData commonData){
this.commonData = commonData;
sqlliteWrapper.persistData(commonData);
return false;
return true;
}

public void updateLocation(String path){
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/eugene/ui/Dashboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import org.eugene.config.Config;
import org.eugene.persistent.SqlliteWrapper;
import org.eugene.persistent.VirtualDB;

Expand All @@ -38,8 +39,10 @@ public void refresh(String schema, String path, int rowNumber, int columnNumber,
accordion = new Accordion();
refreshSummaryPane(path, rowNumber, columnNumber, accordion);
refreshMetaPane(schema, accordion);
refreshAggregationPane(accordion, "", null, init);
refreshProportionPane(accordion, "", null, init);
if(Config.getInstance().enableAnalytics()){
refreshAggregationPane(accordion, "", null, init);
refreshProportionPane(accordion, "", null, init);
}
vBox.getChildren().add(accordion);
}

Expand Down

0 comments on commit 8d17f65

Please sign in to comment.