CONTRIBUTING.md 6.5 KB
Newer Older
1 2
## Contributing to QuestDB

3 4 5 6 7 8 9 10 11 12 13 14
## Raise an Issue

Raising **[issues](https://github.com/questdb/questdb/issues)** is welcome. We
aim to respond quickly and thoughtfully. This is a good place to start before
deep diving into the code base.

## Contribute a PR

### Requirements

- Operating system - **x86-64**: Windows, Linux, FreeBSD and OSX / **ARM
  (AArch64/A64)**: Linux
15
- Java 11 64-bit. We recommend Oracle Java 11, but OpenJDK 11 will also work
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
  (although a little slower)
- Maven 3 (from your package manager on Linux / OSX
  ([Homebrew](https://github.com/Homebrew/brew)) or
  [from the jar](https://maven.apache.org/install.html) for any OS)
- Node.js 12 / npm 6 (to manage your Node.js versions we recommend
  [nvm](https://github.com/nvm-sh/nvm) for OSX/Linux/windows WSL, and
  [nvm-windows](https://github.com/coreybutler/nvm-windows) for Windows) -
  OPTIONAL
- C-compiler, CMake - to contribute to C libraries - OPTIONAL

## Repository overview

- QuestDB database and libraries source in Java:
  [`core/src/main/java/`](https://github.com/questdb/questdb/tree/master/core/src/main/java)
- QuestDB database tests:
  [`core/src/test/java/`](https://github.com/questdb/questdb/tree/master/core/src/test/java)
- QuestDB libraries in C:
  [`core/src/main/c/`](https://github.com/questdb/questdb/tree/master/core/src/main/c)
- QuestDB Windows service wrapper:
  [`win64svc/`](https://github.com/questdb/questdb/tree/master/win64svc/)
- QuestDB web console (frontend):
  [`ui/`](https://github.com/questdb/questdb/tree/master/ui/)
- Micro benchmarks:
  [`benchmarks/`](https://github.com/questdb/questdb/tree/master/benchmarks/)

Compiled binaries (for C libraries and Windows service wrapper) are committed to
git to make build of development process Java-centric and simplified.

# Local setup

## Setup Java and JAVA_HOME

Java versions above 8 are not yet supported. It is possible to build QuestDB
with Java 11, but this requires backward incompatible changes. If your java
version is above 8 you can download & install JDK8 and use the absolute path to
the java executable instead of "`java`".

53
Unless your default Java is 11 you may want to set `JAVA_HOME` to the Java 11
54
directory before running `maven`:
55

56
Linux/OSX
57

58 59 60
```bash
export JAVA_HOME="/path/to/java/"
```
61

62
Windows
63

64 65 66
```bash
set JAVA_HOME="c:\path\to\java directory"
```
67

68
## Compiling Java and frontend code
69

70
Compiling the database + the web console is done with:
71

72
```bash
73 74 75
mvn clean package
```

76 77 78 79
You can then run QuestDB with:

```bash
java -cp core/target/core-4.2.1-SNAPSHOT.jar io.questdb.ServerMain -d <root_dir>
80 81
```

82 83
The web console will available at [localhost:9000](http://localhost:9000).

84 85
## Compiling C-libraries

86 87
C-libraries will have to be compiled for each platform separately. The following
commands will compile on Linux/OSX:
88 89 90 91 92 93 94 95

```text
cmake
make
```

on Windows we use Intellij CLion, which can open cmake files.

96
The artifacts are distributed as follow:
97

98 99 100
```
core/src/main/c -> core/src/main/resources/binaries
```
101

102
# Local setup for frontend development
103

104
## Development server
105

106 107
This is useful when you want to work on the web console without having to
rebuild the artifacts and restart QuestDB. Instead, we use `webpack-dev-server`:
108

109 110 111 112
0. Make sure QuestDB is running
1. `cd ui/`
2. Install the dependencies with `npm install`
3. Start the development web server with `npm start`
T
TheTanc 已提交
113

114 115
The web console should now be accessible at
[localhost:9999](http://localhost:9999)
T
TheTanc 已提交
116

117
## Building the artifacts
V
Vlad Ilyushchenko 已提交
118

119
Run the command:
V
Vlad Ilyushchenko 已提交
120

121 122 123
```bash
mvn clean package
```
V
Vlad Ilyushchenko 已提交
124

125
The artifacts are distributed as follow:
V
Vlad Ilyushchenko 已提交
126

127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
```
ui -> core/src/main/resources/site/public
```

# Testing

We have a lot of unit tests, most of which are of "integration" type, e.g. test
starts a server, interacts with it and asserts the outcome. We expect all
contributors to submit PRs with tests. Please reach out to us via slack if you
uncertain on how to test or you think existing test is inadequate and should be
removed.

# Dependencies

QuestDB does not have dependencies. This may sound unorthodox but in reality we
try not to reinvent the wheel but rather than using libraries we implement best
algorithms ourselves to ensure perfect fit with existing code. With that in mind
we expect contributions that do not add third-party dependencies.

# Allocations, "new" operator and garbage collection

QuestDB is zero-GC along data pipelines. We expect contributions not to allocate
if possible. That said we would like to help you to contribute zero-GC code, do
not hesitate to reach out!

# Committing

We use [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to
auto-generate release notes. We require all commit comments to conform. To that
end, commits have to be granular enough to be successfully described using this
method.

# Squashing commits
V
Vlad Ilyushchenko 已提交
160

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
When submitting a pull request to QuestDB, we ask that you squash your commits
before we merge.

Some applications that interact with git repos will provide a user interface for
squashing. Refer to your application's document for more information.

If you're familiar with the terminal, you can do the following:

- Make sure your branch is up to date with the master branch.
- Run `git rebase -i master`.
- You should see a list of commits, each commit starting with the word "pick".
- Make sure the first commit says "pick" and change the rest from "pick" to
  "squash". -- This will squash each commit into the previous commit, which will
  continue until every commit is squashed into the first commit.
- Save and close the editor.
- It will give you the opportunity to change the commit message.
- Save and close the editor again.
- Then you have to force push the final, squashed commit:
  `git push --force-with-lease origin`.

Squashing commits can be a tricky process but once you figure it out, it is
really helpful and keeps our repository concise and clean.

# FAQ

#### Everything works fine but I get a `404` on [localhost:9000](http://localhost:9000)

This means that the frontend artifacts are not present in
`core/src/main/resources/site/public`. To fix this, you can simply run `mvn
clean package#.

#### I do not want to install `Node.js` and/or it is clashing with my system installation of `Node.js`

You can use [nvm](https://github.com/nvm-sh/nvm) for OSX/Linux/windows WSL, and
[nvm-windows](https://github.com/coreybutler/nvm-windows) for Windows. To have
multiple active versions.

Otherwise, you can use the dedicated `maven` profile to build the code:

```bash
mvn clean package -Dprofile.install-local-nodejs
```
V
Vlad Ilyushchenko 已提交
203

204 205
That way, `maven` will install `node` on the fly in `ui/node` so you don't have
to install it locall.