|
| 1 | +# Contributing |
| 2 | + |
| 3 | +We welcome all contributions! Please open a [pull request](https://github.com/cmu-db/benchbase/pulls). Common contributions may include: |
| 4 | + |
| 5 | +- Adding support for a new DBMS. |
| 6 | +- Adding more tests of existing benchmarks. |
| 7 | +- Fixing any bugs or known issues. |
| 8 | + |
| 9 | +## Contents |
| 10 | + |
| 11 | +<!-- TOC --> |
| 12 | + |
| 13 | +- [Contributing](#contributing) |
| 14 | + - [Contents](#contents) |
| 15 | + - [IDE](#ide) |
| 16 | + - [Adding a new DBMS](#adding-a-new-dbms) |
| 17 | + - [Java Development Notes](#java-development-notes) |
| 18 | + - [Avoid var keyword](#avoid-var-keyword) |
| 19 | + - [Compiler Warnings](#compiler-warnings) |
| 20 | + - [Alternatives to arrays of generics](#alternatives-to-arrays-of-generics) |
| 21 | + |
| 22 | +<!-- /TOC --> |
| 23 | + |
| 24 | +## IDE |
| 25 | + |
| 26 | +Although you can use any IDE you prefer, there are some configurations for [VSCode](https://code.visualstudio.com/) that you may find useful included in the repository, including [Github Codespaces](https://github.com/features/codespaces) and [VSCode devcontainer](https://code.visualstudio.com/docs/remote/containers) support to automatically handle dependencies, environment setup, code formatting, and more. |
| 27 | + |
| 28 | +## Adding a new DBMS |
| 29 | + |
| 30 | +Please see the existing MySQL and PostgreSQL code for an example. |
| 31 | + |
| 32 | +## Java Development Notes |
| 33 | + |
| 34 | +### Compiler Warnings |
| 35 | + |
| 36 | +In an effort to enforce clean, safe, maintainable code, [PR #413](https://github.com/cmu-db/benchbase/pull/413) enabled the `-Werror` and `-Xlint:all` options for the `javac` compiler. |
| 37 | + |
| 38 | +This means that any compiler warnings will cause the build to fail. |
| 39 | + |
| 40 | +If you are seeing a build failure due to a compiler warning, please fix the warning or (on rare occassions) add an exception to the line causing the issue. |
| 41 | + |
| 42 | +### Avoid `var` keyword |
| 43 | + |
| 44 | +In general, we prefer to avoid the `var` keyword in favor of explicit types. |
| 45 | + |
| 46 | +#### Alternatives to arrays of generics |
| 47 | + |
| 48 | +Per the [Java Language Specification](https://docs.oracle.com/javase/tutorial/java/generics/restrictions.html#createArrays), arrays of generic types are not allowed and will cause compiler warnings (e.g., `unchecked cast`) |
| 49 | + |
| 50 | +In some cases, you can extend a generic type to create a non-generic type that can be used in an array. |
| 51 | + |
| 52 | +For instance, |
| 53 | + |
| 54 | +```java |
| 55 | +// Simple generic class overload to avoid some cast warnings. |
| 56 | +class SomeTypeList extends LinkedList<SomeType> {} |
| 57 | + |
| 58 | +SomeTypeList[] someTypeLists = new SomeTypeList[] { |
| 59 | + new SomeTypeList(), |
| 60 | + new SomeTypeList(), |
| 61 | + new SomeTypeList(), |
| 62 | +}; |
| 63 | +``` |
| 64 | + |
| 65 | +#### `this-escape` warnings |
| 66 | + |
| 67 | +`possible 'this' escape before subclass is fully initialized` |
| 68 | + |
| 69 | +The `this-escape` warning above is caused by passing using `this.someOverridableMethod()` in a constructor. |
| 70 | +This could in theory cause problems with a subclass not being fully initialized when the method is called. |
| 71 | + |
| 72 | +Since many of our classes are not designed to be subclassed, we can safely ignore this warning by marking the class as `final` rather than completely rewrite the class initialization. |
0 commit comments