iGIS-SDE开发 ============================== 因为presto对代码书写格式和代码开发有着很强的限制, 并且presto是不支持直接在windows上进行编译的, 如果在windows环境下开发,则需要对项目和环境进行配置修改。 配置后可以实现presto项目代码编译,并运行presto-main工程进行代码修改调试。 一、presto代码编译 ------------------------- 1. 配置git代码签出时的换行符为LF(\n):git config --global core.autocrlf input #. 修改idea的换行符为\n:Setting->Editor->Code Style->Line separator->Unix and macOS(\n) #. Git拉取代码,并在windows上面共享presto工程代码和maven本地仓库所在目录 #. 在linux上挂载windows共享的目录,将linux下maven本地仓库地址配置为windows的maven本地仓库目录地址 #. 在linux上命令行的方式对需要编译的目录进行编译打包等操作 二、presto-main代码调试运行 --------------------------------------------------------------------------------------------------------------------------------------- :: ps:以下修改的代码和配置文件仅为了方便在windows上进行presto-main项目运行,千万不要将非开发代码提交 1. 运行presto-main前需要对presto工程整体进行一次打包 #. 修改com.facebook.presto.server.PluginDiscovery,修改代码 .. code:: java File file = artifact.getFile(); if (!file.getPath().endsWith("/target/classes")) { throw new RuntimeException("Unexpected file for main artifact: " + file); } 为 .. code:: java File file = artifact.getFile(); String filePath = file.getPath().replaceAll("\\\\", "/"); if (!filePath.endsWith("/target/classes")) { throw new RuntimeException("Unexpected file for main artifact: " + file); } 3. 修改PrestoSystemRequirements 注释代码 .. code:: java failRequirement("Presto requires Linux or Mac OS X (found %s)", osName); 修改代码 .. code:: java Object maxFileDescriptorCount = mbeanServer.getAttribute(ObjectName.getInstance(OPERATING_SYSTEM_MXBEAN_NAME), "MaxFileDescriptorCount"); 为 .. code:: java Object maxFileDescriptorCount = 10000; 4. 因为presto对代码书写格式校验比较严格,如果进行代码开发或修改后,需要对代码格式进行格式化和对代码进行重新导报.在README.md中找到Code Style地址下载相关代码格式模板 #. 在idea配置下载好的模板:Setting->Editor->Code Style->Java->Scheme->点击设置按钮->Import Scheme -> InttliJ Idea code style XML #. Idea安装ANTLR插件ANTLR v4 grammar plugin,在运行项目的时候,出现例如在presto-parser模块Cannot resolve symbol 'SqlBaseParser缺少代码的错误,这是因为源码不带anltr4的生成代码。可以在根目录运行生成anltr4代码的命令:**mvn antlr4:antlr4** #. 在执行命令完成后,错误依旧没有消失,我们可以看看项目的结构.File -> Project Structure -> Modules -> presto-parser,将presto-parser的target -> generated-sources ->anltr4设置为Sources因为presto对代码书写格式和代码开发有着很强的限制,并且presto是不支持直接在windows上进行编译的,如果在windows环境下开发,则需要对项目和环境进行配置修改.配置后可以实现presto项目代码编译,并运行presto-main工程进行代码修改调试.