[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224741116 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -456,21 +471,20 @@ public void close() throws Exception { FileUtils.deleteDirectory(getTmpJavaScriptDir()); } - private static final String FILE_CONTENT_FOOTER = "};"; - //Generate Options Description JavaScript private void generateOptionsDescriptionJSFile() throws IOException { //Obtain list of Options & their descriptions OptionManager optionManager = this.drillbit.getContext().getOptionManager(); OptionList publicOptions = optionManager.getPublicOptionList(); -List options = Lists.newArrayList(publicOptions); +List options = new ArrayList<>(publicOptions); Collections.sort(options); int numLeftToWrite = options.size(); //Template source Javascript file InputStream optionsDescripTemplateStream = Resource.newClassPathResource(OPTIONS_DESCRIBE_TEMPLATE_JS).getInputStream(); //Generated file File optionsDescriptionFile = new File(getTmpJavaScriptDir(), OPTIONS_DESCRIBE_JS); +final String FILE_CONTENT_FOOTER = "};"; Review comment: If variable is in method, then it is not necessary to keep its name in the upper case. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224741116 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -456,21 +471,20 @@ public void close() throws Exception { FileUtils.deleteDirectory(getTmpJavaScriptDir()); } - private static final String FILE_CONTENT_FOOTER = "};"; - //Generate Options Description JavaScript private void generateOptionsDescriptionJSFile() throws IOException { //Obtain list of Options & their descriptions OptionManager optionManager = this.drillbit.getContext().getOptionManager(); OptionList publicOptions = optionManager.getPublicOptionList(); -List options = Lists.newArrayList(publicOptions); +List options = new ArrayList<>(publicOptions); Collections.sort(options); int numLeftToWrite = options.size(); //Template source Javascript file InputStream optionsDescripTemplateStream = Resource.newClassPathResource(OPTIONS_DESCRIBE_TEMPLATE_JS).getInputStream(); //Generated file File optionsDescriptionFile = new File(getTmpJavaScriptDir(), OPTIONS_DESCRIBE_JS); +final String FILE_CONTENT_FOOTER = "};"; Review comment: If variable is in method, then it is not necessary to keep its name in upper case. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224742597 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -495,4 +509,50 @@ private void generateOptionsDescriptionJSFile() throws IOException { writer.flush(); } } + + //Generates ACE library javascript populated with list of available SQL functions + private void generateFunctionJS() throws IOException { +//Naturally ordered set of function names +TreeSet functionSet = new TreeSet<>(); +//Extracting ONLY builtIn functions (i.e those already available) +List builtInFuncHolderList = this.drillbit.getContext().getFunctionImplementationRegistry().getLocalFunctionRegistry() +.getAllJarsWithFunctionsHolders().get(LocalFunctionRegistry.BUILT_IN); + +//Build List of usable functions +int skipCount = 0; +for (FunctionHolder builtInFunctionHolder : builtInFuncHolderList) { + String name = builtInFunctionHolder.getName(); + if (!name.contains(" ") && name.matches("([a-z]|[A-Z])\\w+")) { +functionSet.add(name); + } else { +logger.debug("Non-alphabetic leading character. Function skipped : {} ", name); +skipCount++; + } +} +logger.debug("{} functions will not be available in WebUI : {} ", skipCount); + +//Generated file +File functionsListFile = new File(getTmpJavaScriptDir(), ACE_MODE_SQL_JS); +//Template source Javascript file +InputStream aceModeSqlTemplateStream = Resource.newClassPathResource(ACE_MODE_SQL_TEMPLATE_JS).getInputStream(); +functionsListFile.deleteOnExit(); +int numLeftToWrite = functionSet.size(); +//Create a copy of a template and write with that! +java.nio.file.Files.copy(aceModeSqlTemplateStream, functionsListFile.toPath()); +StringBuilder funcListBldr = new StringBuilder(); Review comment: More simple logic can be used here: you just append all functions with `|` and in the end if StringBuilder is not empty substract last char. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224741116 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -456,21 +471,20 @@ public void close() throws Exception { FileUtils.deleteDirectory(getTmpJavaScriptDir()); } - private static final String FILE_CONTENT_FOOTER = "};"; - //Generate Options Description JavaScript private void generateOptionsDescriptionJSFile() throws IOException { //Obtain list of Options & their descriptions OptionManager optionManager = this.drillbit.getContext().getOptionManager(); OptionList publicOptions = optionManager.getPublicOptionList(); -List options = Lists.newArrayList(publicOptions); +List options = new ArrayList<>(publicOptions); Collections.sort(options); int numLeftToWrite = options.size(); //Template source Javascript file InputStream optionsDescripTemplateStream = Resource.newClassPathResource(OPTIONS_DESCRIBE_TEMPLATE_JS).getInputStream(); //Generated file File optionsDescriptionFile = new File(getTmpJavaScriptDir(), OPTIONS_DESCRIBE_JS); +final String FILE_CONTENT_FOOTER = "};"; Review comment: If variable is in method, then it not necessary to keep its name in upper case. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224742597 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -495,4 +509,50 @@ private void generateOptionsDescriptionJSFile() throws IOException { writer.flush(); } } + + //Generates ACE library javascript populated with list of available SQL functions + private void generateFunctionJS() throws IOException { +//Naturally ordered set of function names +TreeSet functionSet = new TreeSet<>(); +//Extracting ONLY builtIn functions (i.e those already available) +List builtInFuncHolderList = this.drillbit.getContext().getFunctionImplementationRegistry().getLocalFunctionRegistry() +.getAllJarsWithFunctionsHolders().get(LocalFunctionRegistry.BUILT_IN); + +//Build List of usable functions +int skipCount = 0; +for (FunctionHolder builtInFunctionHolder : builtInFuncHolderList) { + String name = builtInFunctionHolder.getName(); + if (!name.contains(" ") && name.matches("([a-z]|[A-Z])\\w+")) { +functionSet.add(name); + } else { +logger.debug("Non-alphabetic leading character. Function skipped : {} ", name); +skipCount++; + } +} +logger.debug("{} functions will not be available in WebUI : {} ", skipCount); + +//Generated file +File functionsListFile = new File(getTmpJavaScriptDir(), ACE_MODE_SQL_JS); +//Template source Javascript file +InputStream aceModeSqlTemplateStream = Resource.newClassPathResource(ACE_MODE_SQL_TEMPLATE_JS).getInputStream(); +functionsListFile.deleteOnExit(); +int numLeftToWrite = functionSet.size(); +//Create a copy of a template and write with that! +java.nio.file.Files.copy(aceModeSqlTemplateStream, functionsListFile.toPath()); +StringBuilder funcListBldr = new StringBuilder(); Review comment: Much easier logic can be used here: you just append all functions with `|` and in the end of StringBuilder is not empty substract last char. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224741210 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -495,4 +509,50 @@ private void generateOptionsDescriptionJSFile() throws IOException { writer.flush(); } } + + //Generates ACE library javascript populated with list of available SQL functions + private void generateFunctionJS() throws IOException { Review comment: java-doc This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224741551 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -495,4 +509,50 @@ private void generateOptionsDescriptionJSFile() throws IOException { writer.flush(); } } + + //Generates ACE library javascript populated with list of available SQL functions + private void generateFunctionJS() throws IOException { +//Naturally ordered set of function names +TreeSet functionSet = new TreeSet<>(); +//Extracting ONLY builtIn functions (i.e those already available) +List builtInFuncHolderList = this.drillbit.getContext().getFunctionImplementationRegistry().getLocalFunctionRegistry() +.getAllJarsWithFunctionsHolders().get(LocalFunctionRegistry.BUILT_IN); + +//Build List of usable functions Review comment: Please explain what functions are considered to be "usable". This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224742597 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -495,4 +509,50 @@ private void generateOptionsDescriptionJSFile() throws IOException { writer.flush(); } } + + //Generates ACE library javascript populated with list of available SQL functions + private void generateFunctionJS() throws IOException { +//Naturally ordered set of function names +TreeSet functionSet = new TreeSet<>(); +//Extracting ONLY builtIn functions (i.e those already available) +List builtInFuncHolderList = this.drillbit.getContext().getFunctionImplementationRegistry().getLocalFunctionRegistry() +.getAllJarsWithFunctionsHolders().get(LocalFunctionRegistry.BUILT_IN); + +//Build List of usable functions +int skipCount = 0; +for (FunctionHolder builtInFunctionHolder : builtInFuncHolderList) { + String name = builtInFunctionHolder.getName(); + if (!name.contains(" ") && name.matches("([a-z]|[A-Z])\\w+")) { +functionSet.add(name); + } else { +logger.debug("Non-alphabetic leading character. Function skipped : {} ", name); +skipCount++; + } +} +logger.debug("{} functions will not be available in WebUI : {} ", skipCount); + +//Generated file +File functionsListFile = new File(getTmpJavaScriptDir(), ACE_MODE_SQL_JS); +//Template source Javascript file +InputStream aceModeSqlTemplateStream = Resource.newClassPathResource(ACE_MODE_SQL_TEMPLATE_JS).getInputStream(); +functionsListFile.deleteOnExit(); +int numLeftToWrite = functionSet.size(); +//Create a copy of a template and write with that! +java.nio.file.Files.copy(aceModeSqlTemplateStream, functionsListFile.toPath()); +StringBuilder funcListBldr = new StringBuilder(); Review comment: Much easier logic can be used here: you just append all functions with `|` and in the end if StringBuilder is not empty substract last char. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224742056 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -495,4 +509,50 @@ private void generateOptionsDescriptionJSFile() throws IOException { writer.flush(); } } + + //Generates ACE library javascript populated with list of available SQL functions + private void generateFunctionJS() throws IOException { +//Naturally ordered set of function names +TreeSet functionSet = new TreeSet<>(); +//Extracting ONLY builtIn functions (i.e those already available) +List builtInFuncHolderList = this.drillbit.getContext().getFunctionImplementationRegistry().getLocalFunctionRegistry() +.getAllJarsWithFunctionsHolders().get(LocalFunctionRegistry.BUILT_IN); + +//Build List of usable functions +int skipCount = 0; +for (FunctionHolder builtInFunctionHolder : builtInFuncHolderList) { + String name = builtInFunctionHolder.getName(); + if (!name.contains(" ") && name.matches("([a-z]|[A-Z])\\w+")) { +functionSet.add(name); + } else { +logger.debug("Non-alphabetic leading character. Function skipped : {} ", name); +skipCount++; + } +} +logger.debug("{} functions will not be available in WebUI : {} ", skipCount); + +//Generated file +File functionsListFile = new File(getTmpJavaScriptDir(), ACE_MODE_SQL_JS); +//Template source Javascript file +InputStream aceModeSqlTemplateStream = Resource.newClassPathResource(ACE_MODE_SQL_TEMPLATE_JS).getInputStream(); Review comment: Should we close the stream or `Files.copy` will do this for us? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224740139 ## File path: exec/java-exec/src/main/resources/ace.mode-sql.template.js ## @@ -0,0 +1,121 @@ +/** Review comment: 1. I suggest we keep js scripts / templates under one folder. Could you please move it rest/static/js folder? Also could you please do the same for options.dscribe.template.js 2. mode-sql.js has the same code, please factor out the same parts. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224742213 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -495,4 +509,50 @@ private void generateOptionsDescriptionJSFile() throws IOException { writer.flush(); } } + + //Generates ACE library javascript populated with list of available SQL functions + private void generateFunctionJS() throws IOException { +//Naturally ordered set of function names +TreeSet functionSet = new TreeSet<>(); +//Extracting ONLY builtIn functions (i.e those already available) +List builtInFuncHolderList = this.drillbit.getContext().getFunctionImplementationRegistry().getLocalFunctionRegistry() +.getAllJarsWithFunctionsHolders().get(LocalFunctionRegistry.BUILT_IN); + +//Build List of usable functions +int skipCount = 0; +for (FunctionHolder builtInFunctionHolder : builtInFuncHolderList) { + String name = builtInFunctionHolder.getName(); + if (!name.contains(" ") && name.matches("([a-z]|[A-Z])\\w+")) { +functionSet.add(name); + } else { +logger.debug("Non-alphabetic leading character. Function skipped : {} ", name); +skipCount++; + } +} +logger.debug("{} functions will not be available in WebUI : {} ", skipCount); + +//Generated file +File functionsListFile = new File(getTmpJavaScriptDir(), ACE_MODE_SQL_JS); +//Template source Javascript file +InputStream aceModeSqlTemplateStream = Resource.newClassPathResource(ACE_MODE_SQL_TEMPLATE_JS).getInputStream(); +functionsListFile.deleteOnExit(); Review comment: It's better to put `functionsListFile.deleteOnExit(); right after `File functionsListFile = new File(getTmpJavaScriptDir(), ACE_MODE_SQL_JS);` file creation for easier tracking. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete
arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show Drill functions in WebUI for autocomplete URL: https://github.com/apache/drill/pull/1491#discussion_r224741648 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java ## @@ -495,4 +509,50 @@ private void generateOptionsDescriptionJSFile() throws IOException { writer.flush(); } } + + //Generates ACE library javascript populated with list of available SQL functions + private void generateFunctionJS() throws IOException { +//Naturally ordered set of function names +TreeSet functionSet = new TreeSet<>(); +//Extracting ONLY builtIn functions (i.e those already available) +List builtInFuncHolderList = this.drillbit.getContext().getFunctionImplementationRegistry().getLocalFunctionRegistry() +.getAllJarsWithFunctionsHolders().get(LocalFunctionRegistry.BUILT_IN); + +//Build List of usable functions +int skipCount = 0; +for (FunctionHolder builtInFunctionHolder : builtInFuncHolderList) { + String name = builtInFunctionHolder.getName(); + if (!name.contains(" ") && name.matches("([a-z]|[A-Z])\\w+")) { +functionSet.add(name); + } else { +logger.debug("Non-alphabetic leading character. Function skipped : {} ", name); +skipCount++; + } +} +logger.debug("{} functions will not be available in WebUI : {} ", skipCount); Review comment: There are two `{}` but only one parameter. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services