Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant Singh committed Mar 19, 2023
1 parent 69b1b5d commit ff3a9f7
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions core/src/main/java/org/apache/iceberg/LocationProviders.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.iceberg;

import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Map;
import org.apache.hadoop.fs.Path;
import org.apache.iceberg.common.DynConstructors;
Expand Down Expand Up @@ -105,10 +106,7 @@ public String newDataLocation(String filename) {

static class ObjectStoreLocationProvider implements LocationProvider {

private static final HashFunction HASH_FUNC = Hashing.sha1();

private static final String allChars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private static final HashFunction HASH_FUNC = Hashing.murmur3_32_fixed();
private final String storageLocation;
private final String context;

Expand Down Expand Up @@ -174,13 +172,9 @@ private static String computeHash(String fileName) {
Preconditions.checkState(fileName != null, "fileName cannot be null");
byte[] messageDigest =
HASH_FUNC.hashBytes(fileName.getBytes(StandardCharsets.UTF_8)).asBytes();
String hash = Base64.getUrlEncoder().encodeToString(messageDigest);

StringBuilder hash = new StringBuilder();
for (int i = 0; i < 8; ++i) {
hash.append(allChars.charAt((messageDigest[i] % 62 + 62) % 62));
}

return hash.toString();
return hash.substring(0, 8);
}
}
}

0 comments on commit ff3a9f7

Please sign in to comment.