presto-native-execution/presto_cpp/docs/develop/setup-install.rst
Presto Native Execution - Getting Started
Prerequisites #############
We will be using JDK8 for Presto.
oracle.com <http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html>_Open JDK 11 <https://adoptopenjdk.net/>_.. code-block:: bash
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0)
Ensure you have access to the following repositories:
Presto <https://github.com/prestodb/presto>_Presto_cpp <https://github.com/facebookexternal/presto_cpp>_Velox <https://github.com/facebookincubator/velox>_Presto #########
It is assumed that the reader has some familiarity with Presto, if not please readup on basic terms and architecture
here <https://prestodb.io/docs/current/overview/concepts.html>_.
.. image:: images/presto.png :align: center
We will setup Java based Presto co-ordinator and a C++ based Presto worker using the Velox library.
Setup Presto #############
prestodb/presto <https://github.com/prestodb/presto>_ repository by clicking on the "Fork" button... image:: images/fork.png :align: center
.. code-block:: bash
git clone https://github.com/<YOUR_GITHUB_USERNAME>/presto.git
Then ensure you set the right upstream.
.. code-block:: bash
git remote add upstream [email protected]:prestodb/presto.git
3. Setup Maven
If you are on Windows or Linux, look up in the maven docs on how to get maven running on your platform.
If you are on a Mac, use Homebrew <http://brew.sh/>_
.. code-block:: bash
brew install maven
mvn --version # Should be 3.5.0
4. Build Presto
Go to presto directory and build:
.. code-block:: bash
cd presto
./mvnw clean install -DskipTests
5. Install IntelliJ
Download and install IntellliJ You can also use any other IDE however the instructions in this document will only concern IntelliJ.
Setup IntelliJ ###############
com.facebook.presto.hive.HiveQueryRunner
c. VM options: -ea -Xmx2G -XX:+ExitOnOutOfMemoryError -Duser.timezone=America/Bahia_Banderas -Dhive.security=legacy
d. Working directory: $MODULE_DIR$
e. Use classpath of module: presto-hive.. image:: images/intelij_setup.png :align: center
Upon running this you should see something like the following:
.. image:: images/intelij_run_presto.png :align: center
Setup presto_cpp #################
here <https://github.com/facebookexternal/presto_cpp>_Personal Access Token <https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token>_.. code-block:: bash
git submodule update --init --recursive
# Let's ensure we can build presto_cpp
$cd ../presto_cpp
$./scripts/setup-macos.sh
$ make debug
5. Load the project in CLion and build it. Make sure you check the option for CMake project. You should see a build directory like this :
.. image:: images/cmake_clion.png :align: center
Setup Velox ############
Note: For the purpose of this document, we will just use the submodule inside presto_cpp. Typically though you would checkout Velox independently and carry your work there.
.. code-block:: bash
$ cd velox
$ ./scripts/setup-macos.sh
2. Also add the following in your ~/.profile
.. code-block:: bash
export PATH=$HOME/bin:$HOME/Library/Python/3.7/bin:$PATH
3. Now lets build the project
.. code-block:: bash
$ make debug
#[Optional] Run unit tests
$ make unittest
End to End Run ###############
Let us now try and make a minor modification in Velox and call it from Presto.
changes here <https://github.com/facebookincubator/velox/pull/37/files>_. Add a similar function, say bitwise_xor.presto_cpp.We will add presto_cpp as a module to Presto.
presto_cpp/java/presto-native-tests/pom.xml.. image:: images/add_presto_cpp_to_presto.png :align: center
Env Variables: PRESTO_SERVER=<YOUR_PATH_TO_PRESTO_CPP>/cmake-build-debug/presto_cpp/main/presto_server;DATA_DIR=/Users/<YOUR_USER_NAME>/Desktop;WORKER_COUNT=0
VM Options:
-ea -Xmx2G -XX:+ExitOnOutOfMemoryError -Duser.timezone=America/Bahia_Banderas -Dhive.security=legacy
Your run configuration should look something like below :
.. image:: images/run_configuration.png :align: center
NOTE:
* WORKER_COUNT is the number of workers to be launched along with the coordinator. In this case we put 0 as we want to externally launch our own CPP worker from CLion.
* Use classpath of module: presto-native-tests
* Launch the HiveExternalQueryRunner.
* Note discovery URI. Something like http://127.0.0.1:54557. Use the last discovery URI in the InteliJ logs
.. image:: images/ip_logs.png :align: center
a. Use discovery URI from the logs above and update the config.properties
.. image:: images/config_properties.png :align: center
b. Now create a run configuration for prestoserver like below:
.. image:: images/run_configuration2.png :align: center
Note the program arguments are as below:
--logtostderr=1 --v=1 --etc_dir=/Users/<PATH_TO_YOUR>/presto_cpp
Then start the presto_server executable. If all goes well you should see the server connect to the coordinator and see logs like so :
.. image:: images/connect_logs.png :align: center
.. code-block:: bash
$ cd presto/presto-cli/target # Java presto repo
$ java -jar presto-cli-0.257-SNAPSHOT-executable.jar --catalog hive --schema tpch
Note that 0.257 may change, pick the one exists in this directory You should be able to connect and run a query from the command line now.