From 1d6eba17a151d241218b4394ec69a0f846c73aed Mon Sep 17 00:00:00 2001 From: sadananda aithal <30702253+sadaaithal@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:32:58 -0700 Subject: [PATCH 1/5] Handle dos 8.3 short path notation Fixes dos short path issue from https://github.com/Eugene-Mark/bigdata-file-viewer/issues/43 --- .../java/org/eugene/controller/Renderer.java | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/eugene/controller/Renderer.java b/src/main/java/org/eugene/controller/Renderer.java index 9d840fe..8f1e861 100644 --- a/src/main/java/org/eugene/controller/Renderer.java +++ b/src/main/java/org/eugene/controller/Renderer.java @@ -2,6 +2,8 @@ import javafx.stage.FileChooser; import javafx.stage.Stage; + +import org.apache.commons.lang3.SystemUtils; import org.apache.hadoop.fs.Path; import org.eugene.core.common.AWSS3Reader; import org.eugene.model.CommonData; @@ -13,12 +15,16 @@ import org.eugene.ui.Main; import org.eugene.ui.Table; +import java.io.BufferedReader; import java.io.File; +import java.io.InputStreamReader; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; public class Renderer { @@ -85,11 +91,43 @@ public boolean loadAndShow(){ System.out.println("The location is empty"); } File selectedFile = filechooser.showOpenDialog(stage); - String absolutePath = selectedFile.getAbsolutePath(); + String absolutePath = resolveWindowsShortPath(selectedFile.getAbsolutePath()); PhysicalDB.getInstance().updateLocation(absolutePath); Path path = new Path(absolutePath); return load(path); } + + String resolveWindowsShortPath(String input) { + if (SystemUtils.IS_OS_WINDOWS) { + if (Paths.get(input).toAbsolutePath().toString().contains("~")) { + java.nio.file.Path inputPath = Paths.get(input); + String psDosToLongPathCmdFmt = "powershell \"(Get-Item -LiteralPath '" + inputPath.toAbsolutePath().toString() +"').FullName\""; + System.out.println("sada-fix: dos 8.3 input path: " + input); + System.out.println("sada-fix: running conversion cmd: " + psDosToLongPathCmdFmt); + try { + String output = ""; + int exitVal = 0; + try { + Process proc = Runtime.getRuntime().exec(psDosToLongPathCmdFmt); + output = new BufferedReader(new InputStreamReader(proc.getInputStream())) + .lines().collect(Collectors.joining(System.lineSeparator())); + proc.waitFor(); + exitVal = proc.exitValue(); + } catch(Exception e) { + e.printStackTrace(); + System.out.println("sada-fix: powershell cmd failed. Exit val " + exitVal); + System.out.println("sada-fix: revert to default path"); + output = input; + } + System.out.println("sada-fix: output: " + output); + return output; + } catch (Exception e) { + return input; + } + } + } + return input; + } private String getDirectory(String fullPath){ String regex = "(.*)[\\\\][.]*"; From bf049d20274be5259d47b09732413f4afcfbf620 Mon Sep 17 00:00:00 2001 From: sadananda aithal <30702253+sadaaithal@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:58:05 -0700 Subject: [PATCH 2/5] incorporating changes requested by eugene incorporating changes requested by eugene in https://github.com/Eugene-Mark/bigdata-file-viewer/pull/44/files/1d6eba17a151d241218b4394ec69a0f846c73aed --- .../java/org/eugene/controller/Renderer.java | 375 +++++++++--------- 1 file changed, 186 insertions(+), 189 deletions(-) diff --git a/src/main/java/org/eugene/controller/Renderer.java b/src/main/java/org/eugene/controller/Renderer.java index 8f1e861..7be9883 100644 --- a/src/main/java/org/eugene/controller/Renderer.java +++ b/src/main/java/org/eugene/controller/Renderer.java @@ -1,189 +1,186 @@ -package org.eugene.controller; - -import javafx.stage.FileChooser; -import javafx.stage.Stage; - -import org.apache.commons.lang3.SystemUtils; -import org.apache.hadoop.fs.Path; -import org.eugene.core.common.AWSS3Reader; -import org.eugene.model.CommonData; -import org.eugene.model.TableMeta; -import org.eugene.persistent.PhysicalDB; -import org.eugene.persistent.VirtualDB; -import org.eugene.ui.Constants; -import org.eugene.ui.Dashboard; -import org.eugene.ui.Main; -import org.eugene.ui.Table; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStreamReader; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -public class Renderer { - - private Stage stage; - private TableRenderer tableRenderer; - private DashboardRenderer dashboardRenderer; - - private List showingList; - - public Renderer(Stage stage){ - this.stage = stage; - tableRenderer = new TableRenderer(); - dashboardRenderer = new DashboardRenderer(); - } - - public void initUI(){ - Table table = new Table(stage, this); - Dashboard dashboard = new Dashboard(stage); - tableRenderer.setTable(table); - dashboardRenderer.setDashboard(dashboard); - Main main = new Main(stage, table, dashboard); - main.initUI(); - } - - private boolean load(Path path){ - DataParser dataParser; - if (path.toString().toLowerCase().endsWith("orc")){ - dataParser = new ORCDataParser(); - }else if(path.toString().toLowerCase().endsWith("avro")){ - dataParser = new AVRODataParser(); - }else{ - dataParser = new ParquetDataParser(); - } - boolean status = dataParser.parseData(path); - if (status) { - tableRenderer.init(); - CommonData commonData = VirtualDB.getInstance().getCommonData(); - TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); - showingList = new ArrayList(commonData.getColumnToType().keySet()); - dashboardRenderer.refreshMetaInfo(commonData.getSchema(), path.toString(), tableMeta.getRow(), tableMeta.getColumn(), true); - tableRenderer.refresh(showingList, showingList, tableMeta.getRow(), tableMeta.getColumn(), commonData.getData()); - } - return status; - } - - public boolean loadAndShow(Map map){ - AWSS3Reader awss3Reader = new AWSS3Reader(); - Path path = awss3Reader.read(map.get(Constants.BUCKET), map.get(Constants.FILE), map.get(Constants.REGION), map.get(Constants.ACCESSKEY), map.get(Constants.SECRETKEY)); - load(path); - return false; - } - - public boolean loadAndShow(Path path){ - return load(path); - } - - public boolean loadAndShow(){ - FileChooser filechooser = new FileChooser(); - String location = PhysicalDB.getInstance().getLocation(); - if(!location.equals("")){ - System.out.println("The location returned: " + location); - filechooser.setInitialDirectory(new File(getDirectory(location))); - }else{ - System.out.println("The location is empty"); - } - File selectedFile = filechooser.showOpenDialog(stage); - String absolutePath = resolveWindowsShortPath(selectedFile.getAbsolutePath()); - PhysicalDB.getInstance().updateLocation(absolutePath); - Path path = new Path(absolutePath); - return load(path); - } - - String resolveWindowsShortPath(String input) { - if (SystemUtils.IS_OS_WINDOWS) { - if (Paths.get(input).toAbsolutePath().toString().contains("~")) { - java.nio.file.Path inputPath = Paths.get(input); - String psDosToLongPathCmdFmt = "powershell \"(Get-Item -LiteralPath '" + inputPath.toAbsolutePath().toString() +"').FullName\""; - System.out.println("sada-fix: dos 8.3 input path: " + input); - System.out.println("sada-fix: running conversion cmd: " + psDosToLongPathCmdFmt); - try { - String output = ""; - int exitVal = 0; - try { - Process proc = Runtime.getRuntime().exec(psDosToLongPathCmdFmt); - output = new BufferedReader(new InputStreamReader(proc.getInputStream())) - .lines().collect(Collectors.joining(System.lineSeparator())); - proc.waitFor(); - exitVal = proc.exitValue(); - } catch(Exception e) { - e.printStackTrace(); - System.out.println("sada-fix: powershell cmd failed. Exit val " + exitVal); - System.out.println("sada-fix: revert to default path"); - output = input; - } - System.out.println("sada-fix: output: " + output); - return output; - } catch (Exception e) { - return input; - } - } - } - return input; - } - - private String getDirectory(String fullPath){ - String regex = "(.*)[\\\\][.]*"; - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(fullPath); - String directory = ""; - if(matcher.find()){ - directory = matcher.group(1); - } - return directory; - } - - public List> getData(){ - return VirtualDB.getInstance().getCommonData().getData(); - } - - public void refreshTable(){ - refreshTable(showingList); - } - - public void refreshTable(List showingList){ - CommonData commonData = VirtualDB.getInstance().getCommonData(); - TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); - tableRenderer.refresh(showingList, new ArrayList(commonData.getColumnToType().keySet()), tableMeta.getRow(), tableMeta.getColumn(), commonData.getData()); - } - - public void refreshAggregationPane(String columnName){ - CommonData commonData = VirtualDB.getInstance().getCommonData(); - List typeList = new ArrayList(); - typeList.add("INTEGER"); - typeList.add("INT"); - typeList.add("LONG"); - typeList.add("DOUBLE"); - typeList.add("FLOAT"); - typeList.add("UNION"); - if(!typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())){ - return; - }; - Map keyToValue = PhysicalDB.getInstance().getAggregation(columnName); - dashboardRenderer.refreshAggregationPane(columnName, keyToValue); - } - - public void refreshProportionPane(String columnName){ - CommonData commonData = VirtualDB.getInstance().getCommonData(); - List typeList = new ArrayList(); - typeList.add("INTEGER"); - typeList.add("INT"); - typeList.add("LONG"); - typeList.add("DOUBLE"); - typeList.add("FLOAT"); - typeList.add("UNION"); - if(typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())){ - return; - } - Map itemToCount = PhysicalDB.getInstance().getProportion(columnName); - dashboardRenderer.refreshProportionPane(columnName, itemToCount); - } - -} +package org.eugene.controller; + +import javafx.stage.FileChooser; +import javafx.stage.Stage; + +import org.apache.commons.lang3.SystemUtils; +import org.apache.hadoop.fs.Path; +import org.eugene.core.common.AWSS3Reader; +import org.eugene.model.CommonData; +import org.eugene.model.TableMeta; +import org.eugene.persistent.PhysicalDB; +import org.eugene.persistent.VirtualDB; +import org.eugene.ui.Constants; +import org.eugene.ui.Dashboard; +import org.eugene.ui.Main; +import org.eugene.ui.Table; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +public class Renderer { + + private Stage stage; + private TableRenderer tableRenderer; + private DashboardRenderer dashboardRenderer; + + private List showingList; + + public Renderer(Stage stage){ + this.stage = stage; + tableRenderer = new TableRenderer(); + dashboardRenderer = new DashboardRenderer(); + } + + public void initUI(){ + Table table = new Table(stage, this); + Dashboard dashboard = new Dashboard(stage); + tableRenderer.setTable(table); + dashboardRenderer.setDashboard(dashboard); + Main main = new Main(stage, table, dashboard); + main.initUI(); + } + + private boolean load(Path path){ + DataParser dataParser; + if (path.toString().toLowerCase().endsWith("orc")){ + dataParser = new ORCDataParser(); + }else if(path.toString().toLowerCase().endsWith("avro")){ + dataParser = new AVRODataParser(); + }else{ + dataParser = new ParquetDataParser(); + } + boolean status = dataParser.parseData(path); + if (status) { + tableRenderer.init(); + CommonData commonData = VirtualDB.getInstance().getCommonData(); + TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); + showingList = new ArrayList(commonData.getColumnToType().keySet()); + dashboardRenderer.refreshMetaInfo(commonData.getSchema(), path.toString(), tableMeta.getRow(), tableMeta.getColumn(), true); + tableRenderer.refresh(showingList, showingList, tableMeta.getRow(), tableMeta.getColumn(), commonData.getData()); + } + return status; + } + + public boolean loadAndShow(Map map){ + AWSS3Reader awss3Reader = new AWSS3Reader(); + Path path = awss3Reader.read(map.get(Constants.BUCKET), map.get(Constants.FILE), map.get(Constants.REGION), map.get(Constants.ACCESSKEY), map.get(Constants.SECRETKEY)); + load(path); + return false; + } + + public boolean loadAndShow(Path path){ + return load(path); + } + + public boolean loadAndShow(){ + FileChooser filechooser = new FileChooser(); + String location = PhysicalDB.getInstance().getLocation(); + if(!location.equals("")){ + System.out.println("The location returned: " + location); + filechooser.setInitialDirectory(new File(getDirectory(location))); + }else{ + System.out.println("The location is empty"); + } + File selectedFile = filechooser.showOpenDialog(stage); + String absolutePath = selectedFile.getAbsolutePath(); + if (SystemUtils.IS_OS_WINDOWS) { + absolutePath = resolveShortPath(selectedFile.getAbsolutePath()); + } + System.out.println("Updated location : " + absolutePath); + PhysicalDB.getInstance().updateLocation(absolutePath); + Path path = new Path(absolutePath); + return load(path); + } + + String resolveShortPath(String input) { + if (Paths.get(input).toAbsolutePath().toString().contains("~")) { + java.nio.file.Path inputPath = Paths.get(input); + String psDosToLongPathCmdFmt = "powershell \"(Get-Item -LiteralPath '" + inputPath.toAbsolutePath().toString() +"').FullName\""; + try { + String output = ""; + int exitVal = 0; + try { + Process proc = Runtime.getRuntime().exec(psDosToLongPathCmdFmt); + output = new BufferedReader(new InputStreamReader(proc.getInputStream())) + .lines().collect(Collectors.joining(System.lineSeparator())); + proc.waitFor(); + exitVal = proc.exitValue(); + } catch(Exception e) { + e.printStackTrace(); + output = input; + } + return output; + } catch (Exception e) { + return input; + } + } + return input; + } + + private String getDirectory(String fullPath){ + String regex = "(.*)[\\\\][.]*"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(fullPath); + String directory = ""; + if(matcher.find()){ + directory = matcher.group(1); + } + return directory; + } + + public List> getData(){ + return VirtualDB.getInstance().getCommonData().getData(); + } + + public void refreshTable(){ + refreshTable(showingList); + } + + public void refreshTable(List showingList){ + CommonData commonData = VirtualDB.getInstance().getCommonData(); + TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); + tableRenderer.refresh(showingList, new ArrayList(commonData.getColumnToType().keySet()), tableMeta.getRow(), tableMeta.getColumn(), commonData.getData()); + } + + public void refreshAggregationPane(String columnName){ + CommonData commonData = VirtualDB.getInstance().getCommonData(); + List typeList = new ArrayList(); + typeList.add("INTEGER"); + typeList.add("INT"); + typeList.add("LONG"); + typeList.add("DOUBLE"); + typeList.add("FLOAT"); + typeList.add("UNION"); + if(!typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())){ + return; + }; + Map keyToValue = PhysicalDB.getInstance().getAggregation(columnName); + dashboardRenderer.refreshAggregationPane(columnName, keyToValue); + } + + public void refreshProportionPane(String columnName){ + CommonData commonData = VirtualDB.getInstance().getCommonData(); + List typeList = new ArrayList(); + typeList.add("INTEGER"); + typeList.add("INT"); + typeList.add("LONG"); + typeList.add("DOUBLE"); + typeList.add("FLOAT"); + typeList.add("UNION"); + if(typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())){ + return; + } + Map itemToCount = PhysicalDB.getInstance().getProportion(columnName); + dashboardRenderer.refreshProportionPane(columnName, itemToCount); + } + +} From a90280dcd7abfc566877393072d262010d82722b Mon Sep 17 00:00:00 2001 From: sadananda aithal <30702253+sadaaithal@users.noreply.github.com> Date: Tue, 19 Mar 2024 10:17:48 -0700 Subject: [PATCH 3/5] resolving #44 --- src/main/java/org/eugene/controller/Renderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/eugene/controller/Renderer.java b/src/main/java/org/eugene/controller/Renderer.java index 7be9883..5152544 100644 --- a/src/main/java/org/eugene/controller/Renderer.java +++ b/src/main/java/org/eugene/controller/Renderer.java @@ -94,8 +94,8 @@ public boolean loadAndShow(){ String absolutePath = selectedFile.getAbsolutePath(); if (SystemUtils.IS_OS_WINDOWS) { absolutePath = resolveShortPath(selectedFile.getAbsolutePath()); + System.out.println("Updated location for windows : " + absolutePath); } - System.out.println("Updated location : " + absolutePath); PhysicalDB.getInstance().updateLocation(absolutePath); Path path = new Path(absolutePath); return load(path); From dc512c5352b12634d3d0bd842705bf94841182a9 Mon Sep 17 00:00:00 2001 From: sadananda aithal <30702253+sadaaithal@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:51:11 -0700 Subject: [PATCH 4/5] Add files via upload --- .../java/org/eugene/controller/Renderer.java | 354 +++++++++--------- 1 file changed, 187 insertions(+), 167 deletions(-) diff --git a/src/main/java/org/eugene/controller/Renderer.java b/src/main/java/org/eugene/controller/Renderer.java index 5152544..f94bf2a 100644 --- a/src/main/java/org/eugene/controller/Renderer.java +++ b/src/main/java/org/eugene/controller/Renderer.java @@ -1,8 +1,17 @@ package org.eugene.controller; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; import javafx.stage.FileChooser; import javafx.stage.Stage; - import org.apache.commons.lang3.SystemUtils; import org.apache.hadoop.fs.Path; import org.eugene.core.common.AWSS3Reader; @@ -15,172 +24,183 @@ import org.eugene.ui.Main; import org.eugene.ui.Table; -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStreamReader; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - public class Renderer { - private Stage stage; - private TableRenderer tableRenderer; - private DashboardRenderer dashboardRenderer; - - private List showingList; - - public Renderer(Stage stage){ - this.stage = stage; - tableRenderer = new TableRenderer(); - dashboardRenderer = new DashboardRenderer(); - } - - public void initUI(){ - Table table = new Table(stage, this); - Dashboard dashboard = new Dashboard(stage); - tableRenderer.setTable(table); - dashboardRenderer.setDashboard(dashboard); - Main main = new Main(stage, table, dashboard); - main.initUI(); - } - - private boolean load(Path path){ - DataParser dataParser; - if (path.toString().toLowerCase().endsWith("orc")){ - dataParser = new ORCDataParser(); - }else if(path.toString().toLowerCase().endsWith("avro")){ - dataParser = new AVRODataParser(); - }else{ - dataParser = new ParquetDataParser(); - } - boolean status = dataParser.parseData(path); - if (status) { - tableRenderer.init(); - CommonData commonData = VirtualDB.getInstance().getCommonData(); - TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); - showingList = new ArrayList(commonData.getColumnToType().keySet()); - dashboardRenderer.refreshMetaInfo(commonData.getSchema(), path.toString(), tableMeta.getRow(), tableMeta.getColumn(), true); - tableRenderer.refresh(showingList, showingList, tableMeta.getRow(), tableMeta.getColumn(), commonData.getData()); - } - return status; - } - - public boolean loadAndShow(Map map){ - AWSS3Reader awss3Reader = new AWSS3Reader(); - Path path = awss3Reader.read(map.get(Constants.BUCKET), map.get(Constants.FILE), map.get(Constants.REGION), map.get(Constants.ACCESSKEY), map.get(Constants.SECRETKEY)); - load(path); - return false; - } - - public boolean loadAndShow(Path path){ - return load(path); - } - - public boolean loadAndShow(){ - FileChooser filechooser = new FileChooser(); - String location = PhysicalDB.getInstance().getLocation(); - if(!location.equals("")){ - System.out.println("The location returned: " + location); - filechooser.setInitialDirectory(new File(getDirectory(location))); - }else{ - System.out.println("The location is empty"); - } - File selectedFile = filechooser.showOpenDialog(stage); - String absolutePath = selectedFile.getAbsolutePath(); - if (SystemUtils.IS_OS_WINDOWS) { - absolutePath = resolveShortPath(selectedFile.getAbsolutePath()); - System.out.println("Updated location for windows : " + absolutePath); - } - PhysicalDB.getInstance().updateLocation(absolutePath); - Path path = new Path(absolutePath); - return load(path); - } - - String resolveShortPath(String input) { - if (Paths.get(input).toAbsolutePath().toString().contains("~")) { - java.nio.file.Path inputPath = Paths.get(input); - String psDosToLongPathCmdFmt = "powershell \"(Get-Item -LiteralPath '" + inputPath.toAbsolutePath().toString() +"').FullName\""; - try { - String output = ""; - int exitVal = 0; - try { - Process proc = Runtime.getRuntime().exec(psDosToLongPathCmdFmt); - output = new BufferedReader(new InputStreamReader(proc.getInputStream())) - .lines().collect(Collectors.joining(System.lineSeparator())); - proc.waitFor(); - exitVal = proc.exitValue(); - } catch(Exception e) { - e.printStackTrace(); - output = input; - } - return output; - } catch (Exception e) { - return input; - } - } - return input; - } - - private String getDirectory(String fullPath){ - String regex = "(.*)[\\\\][.]*"; - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(fullPath); - String directory = ""; - if(matcher.find()){ - directory = matcher.group(1); - } - return directory; - } - - public List> getData(){ - return VirtualDB.getInstance().getCommonData().getData(); - } - - public void refreshTable(){ - refreshTable(showingList); - } - - public void refreshTable(List showingList){ - CommonData commonData = VirtualDB.getInstance().getCommonData(); - TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); - tableRenderer.refresh(showingList, new ArrayList(commonData.getColumnToType().keySet()), tableMeta.getRow(), tableMeta.getColumn(), commonData.getData()); - } - - public void refreshAggregationPane(String columnName){ - CommonData commonData = VirtualDB.getInstance().getCommonData(); - List typeList = new ArrayList(); - typeList.add("INTEGER"); - typeList.add("INT"); - typeList.add("LONG"); - typeList.add("DOUBLE"); - typeList.add("FLOAT"); - typeList.add("UNION"); - if(!typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())){ - return; - }; - Map keyToValue = PhysicalDB.getInstance().getAggregation(columnName); - dashboardRenderer.refreshAggregationPane(columnName, keyToValue); - } - - public void refreshProportionPane(String columnName){ - CommonData commonData = VirtualDB.getInstance().getCommonData(); - List typeList = new ArrayList(); - typeList.add("INTEGER"); - typeList.add("INT"); - typeList.add("LONG"); - typeList.add("DOUBLE"); - typeList.add("FLOAT"); - typeList.add("UNION"); - if(typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())){ - return; - } - Map itemToCount = PhysicalDB.getInstance().getProportion(columnName); - dashboardRenderer.refreshProportionPane(columnName, itemToCount); - } - + private Stage stage; + private TableRenderer tableRenderer; + private DashboardRenderer dashboardRenderer; + + private List showingList; + + public Renderer(Stage stage) { + this.stage = stage; + tableRenderer = new TableRenderer(); + dashboardRenderer = new DashboardRenderer(); + } + + public void initUI() { + Table table = new Table(stage, this); + Dashboard dashboard = new Dashboard(stage); + tableRenderer.setTable(table); + dashboardRenderer.setDashboard(dashboard); + Main main = new Main(stage, table, dashboard); + main.initUI(); + } + + private boolean load(Path path) { + DataParser dataParser; + if (path.toString().toLowerCase().endsWith("orc")) { + dataParser = new ORCDataParser(); + } else if (path.toString().toLowerCase().endsWith("avro")) { + dataParser = new AVRODataParser(); + } else { + dataParser = new ParquetDataParser(); + } + boolean status = dataParser.parseData(path); + if (status) { + tableRenderer.init(); + CommonData commonData = VirtualDB.getInstance().getCommonData(); + TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); + showingList = new ArrayList(commonData.getColumnToType().keySet()); + dashboardRenderer.refreshMetaInfo( + commonData.getSchema(), path.toString(), tableMeta.getRow(), tableMeta.getColumn(), true); + tableRenderer.refresh( + showingList, + showingList, + tableMeta.getRow(), + tableMeta.getColumn(), + commonData.getData()); + } + return status; + } + + public boolean loadAndShow(Map map) { + AWSS3Reader awss3Reader = new AWSS3Reader(); + Path path = + awss3Reader.read( + map.get(Constants.BUCKET), + map.get(Constants.FILE), + map.get(Constants.REGION), + map.get(Constants.ACCESSKEY), + map.get(Constants.SECRETKEY)); + load(path); + return false; + } + + public boolean loadAndShow(Path path) { + return load(path); + } + + public boolean loadAndShow() { + FileChooser filechooser = new FileChooser(); + String location = PhysicalDB.getInstance().getLocation(); + if (!location.equals("")) { + System.out.println("The location returned: " + location); + filechooser.setInitialDirectory(new File(getDirectory(location))); + } else { + System.out.println("The location is empty"); + } + File selectedFile = filechooser.showOpenDialog(stage); + String absolutePath = selectedFile.getAbsolutePath(); + if (SystemUtils.IS_OS_WINDOWS) { + absolutePath = resolveShortPath(selectedFile.getAbsolutePath()); + System.out.println("Updated location for windows : " + absolutePath); + } + PhysicalDB.getInstance().updateLocation(absolutePath); + Path path = new Path(absolutePath); + return load(path); + } + + String resolveShortPath(String input) { + if (Paths.get(input).toAbsolutePath().toString().contains("~")) { + java.nio.file.Path inputPath = Paths.get(input); + String psDosToLongPathCmdFmt = + "powershell \"(Get-Item -LiteralPath '" + + inputPath.toAbsolutePath().toString() + + "').FullName\""; + try { + String output = ""; + int exitVal = 0; + try { + Process proc = Runtime.getRuntime().exec(psDosToLongPathCmdFmt); + output = + new BufferedReader(new InputStreamReader(proc.getInputStream())) + .lines() + .collect(Collectors.joining(System.lineSeparator())); + proc.waitFor(); + exitVal = proc.exitValue(); + } catch (Exception e) { + e.printStackTrace(); + output = input; + } + return output; + } catch (Exception e) { + return input; + } + } + return input; + } + + private String getDirectory(String fullPath) { + String regex = "(.*)[\\\\][.]*"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(fullPath); + String directory = ""; + if (matcher.find()) { + directory = matcher.group(1); + } + return directory; + } + + public List> getData() { + return VirtualDB.getInstance().getCommonData().getData(); + } + + public void refreshTable() { + refreshTable(showingList); + } + + public void refreshTable(List showingList) { + CommonData commonData = VirtualDB.getInstance().getCommonData(); + TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); + tableRenderer.refresh( + showingList, + new ArrayList(commonData.getColumnToType().keySet()), + tableMeta.getRow(), + tableMeta.getColumn(), + commonData.getData()); + } + + public void refreshAggregationPane(String columnName) { + CommonData commonData = VirtualDB.getInstance().getCommonData(); + List typeList = new ArrayList(); + typeList.add("INTEGER"); + typeList.add("INT"); + typeList.add("LONG"); + typeList.add("DOUBLE"); + typeList.add("FLOAT"); + typeList.add("UNION"); + if (!typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())) { + return; + } + ; + Map keyToValue = PhysicalDB.getInstance().getAggregation(columnName); + dashboardRenderer.refreshAggregationPane(columnName, keyToValue); + } + + public void refreshProportionPane(String columnName) { + CommonData commonData = VirtualDB.getInstance().getCommonData(); + List typeList = new ArrayList(); + typeList.add("INTEGER"); + typeList.add("INT"); + typeList.add("LONG"); + typeList.add("DOUBLE"); + typeList.add("FLOAT"); + typeList.add("UNION"); + if (typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())) { + return; + } + Map itemToCount = PhysicalDB.getInstance().getProportion(columnName); + dashboardRenderer.refreshProportionPane(columnName, itemToCount); + } } From 03d96f03510531bf95034ce6434b50b1c9a75376 Mon Sep 17 00:00:00 2001 From: sadananda aithal <30702253+sadaaithal@users.noreply.github.com> Date: Wed, 20 Mar 2024 21:51:45 -0700 Subject: [PATCH 5/5] final commit (hopefully) set tab to 4 spaces. also had to configure the "java save action" on eclipse to use the new formatting option. this was missing. now tabs are 4 spaces. --- .../java/org/eugene/controller/Renderer.java | 324 +++++++++--------- 1 file changed, 155 insertions(+), 169 deletions(-) diff --git a/src/main/java/org/eugene/controller/Renderer.java b/src/main/java/org/eugene/controller/Renderer.java index f94bf2a..30f2f5a 100644 --- a/src/main/java/org/eugene/controller/Renderer.java +++ b/src/main/java/org/eugene/controller/Renderer.java @@ -10,8 +10,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import javafx.stage.FileChooser; -import javafx.stage.Stage; + import org.apache.commons.lang3.SystemUtils; import org.apache.hadoop.fs.Path; import org.eugene.core.common.AWSS3Reader; @@ -24,183 +23,170 @@ import org.eugene.ui.Main; import org.eugene.ui.Table; +import javafx.stage.FileChooser; +import javafx.stage.Stage; + public class Renderer { - private Stage stage; - private TableRenderer tableRenderer; - private DashboardRenderer dashboardRenderer; - - private List showingList; - - public Renderer(Stage stage) { - this.stage = stage; - tableRenderer = new TableRenderer(); - dashboardRenderer = new DashboardRenderer(); - } - - public void initUI() { - Table table = new Table(stage, this); - Dashboard dashboard = new Dashboard(stage); - tableRenderer.setTable(table); - dashboardRenderer.setDashboard(dashboard); - Main main = new Main(stage, table, dashboard); - main.initUI(); - } - - private boolean load(Path path) { - DataParser dataParser; - if (path.toString().toLowerCase().endsWith("orc")) { - dataParser = new ORCDataParser(); - } else if (path.toString().toLowerCase().endsWith("avro")) { - dataParser = new AVRODataParser(); - } else { - dataParser = new ParquetDataParser(); + private Stage stage; + private TableRenderer tableRenderer; + private DashboardRenderer dashboardRenderer; + + private List showingList; + + public Renderer(Stage stage) { + this.stage = stage; + tableRenderer = new TableRenderer(); + dashboardRenderer = new DashboardRenderer(); } - boolean status = dataParser.parseData(path); - if (status) { - tableRenderer.init(); - CommonData commonData = VirtualDB.getInstance().getCommonData(); - TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); - showingList = new ArrayList(commonData.getColumnToType().keySet()); - dashboardRenderer.refreshMetaInfo( - commonData.getSchema(), path.toString(), tableMeta.getRow(), tableMeta.getColumn(), true); - tableRenderer.refresh( - showingList, - showingList, - tableMeta.getRow(), - tableMeta.getColumn(), - commonData.getData()); + + public void initUI() { + Table table = new Table(stage, this); + Dashboard dashboard = new Dashboard(stage); + tableRenderer.setTable(table); + dashboardRenderer.setDashboard(dashboard); + Main main = new Main(stage, table, dashboard); + main.initUI(); } - return status; - } - - public boolean loadAndShow(Map map) { - AWSS3Reader awss3Reader = new AWSS3Reader(); - Path path = - awss3Reader.read( - map.get(Constants.BUCKET), - map.get(Constants.FILE), - map.get(Constants.REGION), - map.get(Constants.ACCESSKEY), - map.get(Constants.SECRETKEY)); - load(path); - return false; - } - - public boolean loadAndShow(Path path) { - return load(path); - } - - public boolean loadAndShow() { - FileChooser filechooser = new FileChooser(); - String location = PhysicalDB.getInstance().getLocation(); - if (!location.equals("")) { - System.out.println("The location returned: " + location); - filechooser.setInitialDirectory(new File(getDirectory(location))); - } else { - System.out.println("The location is empty"); + + private boolean load(Path path) { + DataParser dataParser; + if (path.toString().toLowerCase().endsWith("orc")) { + dataParser = new ORCDataParser(); + } else if (path.toString().toLowerCase().endsWith("avro")) { + dataParser = new AVRODataParser(); + } else { + dataParser = new ParquetDataParser(); + } + boolean status = dataParser.parseData(path); + if (status) { + tableRenderer.init(); + CommonData commonData = VirtualDB.getInstance().getCommonData(); + TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); + showingList = new ArrayList(commonData.getColumnToType().keySet()); + dashboardRenderer.refreshMetaInfo(commonData.getSchema(), path.toString(), tableMeta.getRow(), + tableMeta.getColumn(), true); + tableRenderer.refresh(showingList, showingList, tableMeta.getRow(), tableMeta.getColumn(), + commonData.getData()); + } + return status; + } + + public boolean loadAndShow(Map map) { + AWSS3Reader awss3Reader = new AWSS3Reader(); + Path path = awss3Reader.read(map.get(Constants.BUCKET), map.get(Constants.FILE), map.get(Constants.REGION), + map.get(Constants.ACCESSKEY), map.get(Constants.SECRETKEY)); + load(path); + return false; } - File selectedFile = filechooser.showOpenDialog(stage); - String absolutePath = selectedFile.getAbsolutePath(); - if (SystemUtils.IS_OS_WINDOWS) { - absolutePath = resolveShortPath(selectedFile.getAbsolutePath()); - System.out.println("Updated location for windows : " + absolutePath); + + public boolean loadAndShow(Path path) { + return load(path); } - PhysicalDB.getInstance().updateLocation(absolutePath); - Path path = new Path(absolutePath); - return load(path); - } - - String resolveShortPath(String input) { - if (Paths.get(input).toAbsolutePath().toString().contains("~")) { - java.nio.file.Path inputPath = Paths.get(input); - String psDosToLongPathCmdFmt = - "powershell \"(Get-Item -LiteralPath '" - + inputPath.toAbsolutePath().toString() - + "').FullName\""; - try { - String output = ""; - int exitVal = 0; - try { - Process proc = Runtime.getRuntime().exec(psDosToLongPathCmdFmt); - output = - new BufferedReader(new InputStreamReader(proc.getInputStream())) - .lines() - .collect(Collectors.joining(System.lineSeparator())); - proc.waitFor(); - exitVal = proc.exitValue(); - } catch (Exception e) { - e.printStackTrace(); - output = input; + + public boolean loadAndShow() { + FileChooser filechooser = new FileChooser(); + String location = PhysicalDB.getInstance().getLocation(); + if (!location.equals("")) { + System.out.println("The location returned: " + location); + filechooser.setInitialDirectory(new File(getDirectory(location))); + } else { + System.out.println("The location is empty"); + } + File selectedFile = filechooser.showOpenDialog(stage); + String absolutePath = selectedFile.getAbsolutePath(); + if (SystemUtils.IS_OS_WINDOWS) { + absolutePath = resolveShortPath(selectedFile.getAbsolutePath()); + System.out.println("Updated location: " + absolutePath); + } + PhysicalDB.getInstance().updateLocation(absolutePath); + Path path = new Path(absolutePath); + return load(path); + } + + String resolveShortPath(String input) { + if (Paths.get(input).toAbsolutePath().toString().contains("~")) { + java.nio.file.Path inputPath = Paths.get(input); + String psDosToLongPathCmdFmt = "powershell \"(Get-Item -LiteralPath '" + + inputPath.toAbsolutePath().toString() + "').FullName\""; + try { + String output = ""; + int exitVal = 0; + try { + Process proc = Runtime.getRuntime().exec(psDosToLongPathCmdFmt); + output = new BufferedReader(new InputStreamReader(proc.getInputStream())).lines() + .collect(Collectors.joining(System.lineSeparator())); + proc.waitFor(); + exitVal = proc.exitValue(); + } catch (Exception e) { + e.printStackTrace(); + output = input; + } + return output; + } catch (Exception e) { + return input; + } } - return output; - } catch (Exception e) { return input; - } } - return input; - } - - private String getDirectory(String fullPath) { - String regex = "(.*)[\\\\][.]*"; - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(fullPath); - String directory = ""; - if (matcher.find()) { - directory = matcher.group(1); + + private String getDirectory(String fullPath) { + String regex = "(.*)[\\\\][.]*"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(fullPath); + String directory = ""; + if (matcher.find()) { + directory = matcher.group(1); + } + return directory; + } + + public List> getData() { + return VirtualDB.getInstance().getCommonData().getData(); + } + + public void refreshTable() { + refreshTable(showingList); + } + + public void refreshTable(List showingList) { + CommonData commonData = VirtualDB.getInstance().getCommonData(); + TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); + tableRenderer.refresh(showingList, new ArrayList(commonData.getColumnToType().keySet()), + tableMeta.getRow(), tableMeta.getColumn(), commonData.getData()); } - return directory; - } - - public List> getData() { - return VirtualDB.getInstance().getCommonData().getData(); - } - - public void refreshTable() { - refreshTable(showingList); - } - - public void refreshTable(List showingList) { - CommonData commonData = VirtualDB.getInstance().getCommonData(); - TableMeta tableMeta = VirtualDB.getInstance().getTableMeta(); - tableRenderer.refresh( - showingList, - new ArrayList(commonData.getColumnToType().keySet()), - tableMeta.getRow(), - tableMeta.getColumn(), - commonData.getData()); - } - - public void refreshAggregationPane(String columnName) { - CommonData commonData = VirtualDB.getInstance().getCommonData(); - List typeList = new ArrayList(); - typeList.add("INTEGER"); - typeList.add("INT"); - typeList.add("LONG"); - typeList.add("DOUBLE"); - typeList.add("FLOAT"); - typeList.add("UNION"); - if (!typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())) { - return; + + public void refreshAggregationPane(String columnName) { + CommonData commonData = VirtualDB.getInstance().getCommonData(); + List typeList = new ArrayList(); + typeList.add("INTEGER"); + typeList.add("INT"); + typeList.add("LONG"); + typeList.add("DOUBLE"); + typeList.add("FLOAT"); + typeList.add("UNION"); + if (!typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())) { + return; + } + ; + Map keyToValue = PhysicalDB.getInstance().getAggregation(columnName); + dashboardRenderer.refreshAggregationPane(columnName, keyToValue); } - ; - Map keyToValue = PhysicalDB.getInstance().getAggregation(columnName); - dashboardRenderer.refreshAggregationPane(columnName, keyToValue); - } - - public void refreshProportionPane(String columnName) { - CommonData commonData = VirtualDB.getInstance().getCommonData(); - List typeList = new ArrayList(); - typeList.add("INTEGER"); - typeList.add("INT"); - typeList.add("LONG"); - typeList.add("DOUBLE"); - typeList.add("FLOAT"); - typeList.add("UNION"); - if (typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())) { - return; + + public void refreshProportionPane(String columnName) { + CommonData commonData = VirtualDB.getInstance().getCommonData(); + List typeList = new ArrayList(); + typeList.add("INTEGER"); + typeList.add("INT"); + typeList.add("LONG"); + typeList.add("DOUBLE"); + typeList.add("FLOAT"); + typeList.add("UNION"); + if (typeList.contains(commonData.getColumnToType().get(columnName).toUpperCase())) { + return; + } + Map itemToCount = PhysicalDB.getInstance().getProportion(columnName); + dashboardRenderer.refreshProportionPane(columnName, itemToCount); } - Map itemToCount = PhysicalDB.getInstance().getProportion(columnName); - dashboardRenderer.refreshProportionPane(columnName, itemToCount); - } + }