Skip to content

Conversation

@sagar0
Copy link
Contributor

@sagar0 sagar0 commented Feb 26, 2019

Ran make format to fix lint issue. There are no other changes in this PR other than the ones done by make format.
Most were pointed by the internal linter for #4833, but there were too many to just fix/point out in that great contribution to get RocksJava API on par with the C++ API. Hence fixing separately.

Test Plan:

  • make check
  • make rocksdbjava jtest

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sagar0 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@sagar0 sagar0 requested a review from miasantreble February 26, 2019 22:18
Add newlines to end of 7 files to pacify Lint.
*/
void Java_org_rocksdb_CompactionJobInfo_disposeInternal(
JNIEnv*, jobject, jlong jhandle) {
void Java_org_rocksdb_CompactionJobInfo_disposeInternal(JNIEnv*, jobject,
Copy link
Contributor

@adamretter adamretter Feb 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sagar0 I really dislike this style of indenting on the JNI signature declarations. I am not sure it makes sense as the method names will always be very very long. Ultimately this leads to the downside of having one variable per line, difficult to read code and no benefit.

Is there any chance to get an exclusion for this rule for CPP code inside java/rocksjni?

Copy link
Contributor Author

@sagar0 sagar0 Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamretter We are just using the clang formatter. make format uses format-diff.sh which internally calls clang-format. (Our internal linter is much more stricter than the formatter, whining on other rules.)
While we could potentially have an exclusion for the files under java directory, we will lose the efficiency of formatting everything with a tool, leading to many different formatting styles from different contributors based on personal preferences. I am open to suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure it makes sense as the method names will always be very very long. Ultimately this leads to the downside of having one variable per line, difficult to read code and no benefit.

Clang format does not always put one arg per line (if this is your main concern). You can see that when there are many params, clang chooses a different style of putting multiple args on the same line. Example:

rocksdb/db/builder.cc

Lines 65 to 82 in bb474e9

Status BuildTable(
const std::string& dbname, Env* env, const ImmutableCFOptions& ioptions,
const MutableCFOptions& mutable_cf_options, const EnvOptions& env_options,
TableCache* table_cache, InternalIterator* iter,
std::vector<std::unique_ptr<FragmentedRangeTombstoneIterator>>
range_del_iters,
FileMetaData* meta, const InternalKeyComparator& internal_comparator,
const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
int_tbl_prop_collector_factories,
uint32_t column_family_id, const std::string& column_family_name,
std::vector<SequenceNumber> snapshots,
SequenceNumber earliest_write_conflict_snapshot,
SnapshotChecker* snapshot_checker, const CompressionType compression,
const CompressionOptions& compression_opts, bool paranoid_file_checks,
InternalStats* internal_stats, TableFileCreationReason reason,
EventLogger* event_logger, int job_id, const Env::IOPriority io_priority,
TableProperties* table_properties, int level, const uint64_t creation_time,
const uint64_t oldest_key_time, Env::WriteLifeTimeHint write_hint) {

Copy link
Contributor

@adamretter adamretter Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point was that it does put each variable on a separate line when the method name is very very long which is typically only the case in the JNI C++ code. The example you provided doesn't show this because the method name is very short.

I don't want to turn off formatting for the JNI C++ code, I just want to tweak it for that folder so that we have sensible formatting that is both readable and usable. Is it possible to configure the clang format rules for RocksDB or add exceptions for only certain rules?

Copy link
Contributor Author

@sagar0 sagar0 Feb 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still not convinced that we should tweak the formatting for the JNI code. There are many places in the current C++ API code where each variable is placed on a separate line, as the method name sometimes becomes long when prefixed with the class name; granted it could be a little more so in the JNI C++ code. But the actual style rule causing this seems sane enough to me

In case if it is decided to tweak, AlignAfterOpenBracket could be set to DontAlign or AlwaysBreak for JNI files in our .clang-format, I believe (I am not an expert on style-rules, just googled my way to it).

@facebook-github-bot
Copy link
Contributor

@sagar0 has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sagar0 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@siying
Copy link
Contributor

siying commented Sep 6, 2019

Do we plan to move forward, or do we plan to abandon it?

@sagar0 sagar0 closed this Sep 6, 2019
@sagar0
Copy link
Contributor Author

sagar0 commented Sep 6, 2019

Abandoned, as there was no consensus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants