All languages:

C++

See the C++ Style Guide

Java

Thrift

We don't have a formal style guide, but we do adhere to a few conventions:

Here's an example:

service MetadataRepositoryService {
  TRegisterResponse Register(1: TRegisterRequest request);
}

struct TRegisterRequest {
  1: required list<string> applicationIds
  2: required TNetworkAddress address
}

struct TRegisterResponse {
  1: required set<TMetadatum> metadata
}

 

Python

When editing existing code, you should follow existing code style in the file you are editing. In general, our code tries to follow PEP8 style with some exceptions:

We automatically run flake8-diff on jobs pre-commit to report style violations on lines that patches modify. It is configured using setup.cfg in the Impala repository.

You can run flake8 in several ways. Note that a lot of existing Python code in Impala doesn't meet our current style standards. We fix such issues incrementally when we modify the code.

# Works in an Impala development environment. Lists all violations for a file or subdirectory.
impala-flake8 <path to file>

# Show newly introduced violations for your current HEAD commit in git.
# Requires you to install flake8-diff separately.
flake8-diff HEAD^ HEAD

# Generate the same violations as the Impala jenkins bot for your current HEAD commit in git.
./bin/jenkins/critique-gerrit-review.py --dryrun


The following tools have also been found useful by developers to scan and/or automatically fix formatting issues:

All tools above can be used with the same configuration file. As a starting point, consider using this one:

[pep8]
# E101 - Reindent all lines.
# E111 - indentation is not a multiple of four
# E114 - indentation is not a multiple of four (comment)
# E251 - Remove whitespace around parameter '=' sign.
# E301 - Add missing blank line.
ignore = E101,E111,E114,E251,E301
max-line-length = 90