You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2022/01/05 23:00:51 UTC

[GitHub] [bookkeeper] dlg99 commented on a change in pull request #2975: Changing the routing of ledgers to journal directories

dlg99 commented on a change in pull request #2975:
URL: https://github.com/apache/bookkeeper/pull/2975#discussion_r779193772



##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieImpl.java
##########
@@ -1259,7 +1261,17 @@ LedgerDescriptor getLedgerForEntry(ByteBuf entry, final byte[] masterKey)
     }
 
     private Journal getJournal(long ledgerId) {
-        return journals.get(MathUtils.signSafeMod(ledgerId, journals.size()));
+        String dividendString = Double.toString(ledgerId);
+        byte[] secretBytes = null;
+        int index = 0;
+        try {
+            secretBytes = MessageDigest.getInstance("md5").digest(dividendString.getBytes());
+            BigInteger md5Code = new BigInteger(1, secretBytes);

Review comment:
       +1 for the performance concern.
   
   Would something like
   ```
   final int PRIME = 31;
   return journals.get(MathUtils.signSafeMod(ledgerId, PRIME * journals.size()));
   ```
   work well enough? 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org