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

3 4 5 6 7 8 9 10 11 12
## 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

13 14
- Operating system - **x86-64**: Windows, Linux, FreeBSD and OSX
- Java 11 64-bit
15 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
- 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

46 47 48
JAVA_HOME is required by Maven. It is possible to have multiple version of Java on the same platform. Please
set up JAVA_HOME to point to Java 11. Other versions of Java may not work. If you are new to Java please
check that JAVA_HOME is pointing to the root of Java directory: `C:\Users\me\dev\jdk-11.0.8` and *not* `C:\Users\me\dev\jdk-11.0.8\bin\java`.
49

50

51
Linux/OSX
52

53 54 55
```bash
export JAVA_HOME="/path/to/java/"
```
56

57
Windows
58

59 60 61
```bash
set JAVA_HOME="c:\path\to\java directory"
```
62

63
## Compiling Java and frontend code
64

65
Compiling the database + the web console can be done with:
66

67
```bash
68
mvn clean package -DskipTests -P build-web-console
69 70
```

71 72 73
You can then run QuestDB with:

```bash
74
java -p core/target/questdb-<version>-SNAPSHOT.jar -m io.questdb/io.questdb.ServerMain -d <root_dir>
75 76
```

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

79 80
## Compiling C-libraries

81 82
C-libraries will have to be compiled for each platform separately. Cmake will also need JAVA_HOME to be set. The following
commands will compile on Linux/OSX.
83 84 85 86 87 88

```text
cmake
make
```

89
For C development we use Intellij CLion. This IDEA "understands" cmake files and will make compilation easier.
90

91
The build will copy artifacts as follows:
92

93
```
94
core/src/main/c -> core/src/main/resources/io/questdb/bin
95
```
96

97
# Local setup for frontend development
98

99
## Development server
100

101 102
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`:
103

104 105 106 107
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 已提交
108

109 110
The web console should now be accessible at
[localhost:9999](http://localhost:9999)
T
TheTanc 已提交
111

112 113 114 115
Development server running on port 9999 will monitor for web console file changes and will rebuild/deploy on the fly. The 
web console front end will be connecting to QuestDB REST API on port 9000. Keep QuestDB server running. 

## Building web console bundle into questdb.jar
V
Vlad Ilyushchenko 已提交
116

117
Run the command:
V
Vlad Ilyushchenko 已提交
118

119
```bash
120
mvn clean package -DskipTests -P build-web-console
121
```
V
Vlad Ilyushchenko 已提交
122

123
The build will copy artifacts as follows:
V
Vlad Ilyushchenko 已提交
124

125
```
126
ui -> core/src/main/resources/io/questdb/site/public.zip
127 128 129 130 131 132 133
```

# 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
134
uncertain on how to test, or you think existing test is inadequate and should be
135 136 137 138 139
removed.

# Dependencies

QuestDB does not have dependencies. This may sound unorthodox but in reality we
140 141
try not to reinvent the wheel but rather than using libraries we implement algorithms on first principles
to ensure perfect fit with existing code. With that in mind
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
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 已提交
158

159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
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

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

This means that the web console artifacts are not present in
`core/src/main/resources/io/questdb/site/public.zip`. To fix this, you can simply run: 
188

189 190 191
```bash
mvn clean package -DskipTests -P build-web-console
```
192 193 194 195 196 197 198 199 200 201

#### 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
202
mvn clean package -DskipTests -P build-web-console,build-binaries,use-built-in-nodejs
203
```
V
Vlad Ilyushchenko 已提交
204

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