Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameterised log message, final variable migration, removing unused methods #60

Merged
merged 1 commit into from
Jun 29, 2021

Conversation

nischalkumar
Copy link
Contributor

Small refactor to improve code quality. This pr includes three things

  • migrating logs to parameterized slf4j error messages
  • removing unused methods
  • optimizing imports
  • a few attributes could be final

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 24, 2021

CLA Signed

The committers are authorized under a signed CLA.

@@ -15,8 +15,6 @@
package org.janusgraph.diskstorage.foundationdb;

import com.apple.foundationdb.KeyValue;
import com.apple.foundationdb.LocalityUtil;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing ununsed imports

@@ -74,11 +71,6 @@ private static FoundationDBTx getTransaction(StoreTransaction txh) {

@Override
public synchronized void close() throws BackendException {
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

redundant code as nothing was inside try catch. also no 82-83 do not call foundation db.

@@ -167,7 +159,7 @@ public void insert(StaticBuffer key, StaticBuffer value, StoreTransaction txh, I

return new FoundationDBRecordAsyncIterator(db, tx, rangeQuery, result, query.getKeySelector());
} catch (Exception e) {
log.error("getSliceAsync db=%s, tx=%s with exception", name, txh, e);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

migrating to slf4j parameterized logging

@@ -257,13 +249,6 @@ public void delete(StaticBuffer key, StoreTransaction txh) throws BackendExcepti
throw new PermanentBackendException(e);
}
}
public List<StaticBuffer> getBoundaryKeys() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unused method

Copy link
Contributor

Choose a reason for hiding this comment

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

This method was introduced by @ruweih and they stated the reason for its existence here. Instead of removing it, you could add a comment that says why it's there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved. Please let me know if i need to. update the comment.

@@ -25,10 +25,10 @@
*/
public class FoundationDBRangeQuery {

private KVQuery originalQuery;
private final KVQuery originalQuery;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

both these attributes could be final

@@ -52,19 +52,19 @@

private final Database db;

private List<Insert> inserts = Collections.synchronizedList(new ArrayList<>());
private List<byte[]> deletions = Collections.synchronizedList(new ArrayList<>());
private final List<Insert> inserts = Collections.synchronizedList(new ArrayList<>());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all these attributes can be final

@@ -149,7 +149,7 @@ public synchronized void rollback() throws BackendException {


private void logFDBException(Throwable t) {
if (t != null && t instanceof FDBException) {
if (t instanceof FDBException) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

t!=null was redundant as t instanceof FDBException checks for null case as well

@@ -449,8 +449,8 @@ public void clear(final byte[] key) {


private class Insert {
private byte[] key;
private byte[] value;
private final byte[] key;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

both the attributes could be final

Copy link
Contributor

@rngcntr rngcntr left a comment

Choose a reason for hiding this comment

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

Thank you very much for cleaning up @nischalkumar, I appreciate that!
I have one remark, otherwise this PR looks good to me.

@@ -257,13 +249,6 @@ public void delete(StaticBuffer key, StoreTransaction txh) throws BackendExcepti
throw new PermanentBackendException(e);
}
}
public List<StaticBuffer> getBoundaryKeys() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method was introduced by @ruweih and they stated the reason for its existence here. Instead of removing it, you could add a comment that says why it's there.

Copy link
Contributor

@rngcntr rngcntr left a comment

Choose a reason for hiding this comment

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

That looks good, thanks!
Would you please squash your commits into a single one and resolve merge conflicts?

Edit: I just found out about the problems with our testing environment. I will try to go ahead and fix it so that CI will execute correctly.

@rngcntr
Copy link
Contributor

rngcntr commented Jun 29, 2021

Blocked on #61

…methods

Signed-off-by: Nischal Kumar <nischalkumarsagar@gmail.com>
@nischalkumar
Copy link
Contributor Author

nischalkumar commented Jun 29, 2021

That looks good, thanks!
Would you please squash your commits into a single one and resolve merge conflicts?

Edit: I just found out about the problems with our testing environment. I will try to go ahead and fix it so that CI will execute correctly.

@rngcntr I have squashed all commits into one. Conflicts are also resolved.

@rngcntr
Copy link
Contributor

rngcntr commented Jun 29, 2021

@nischalkumar Very nice, thanks a lot for your contribution!

@rngcntr rngcntr merged commit b308e33 into JanusGraph:master Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: external Externally-managed CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants