Skip to content

Commit 1a9843d

Browse files
committed
Add note about MD5 hash implementation source
1 parent 60227d7 commit 1a9843d

File tree

1 file changed

+3
-0
lines changed
  • ch07-graph/src/main/scala/com/cloudera/datascience/graph

1 file changed

+3
-0
lines changed

ch07-graph/src/main/scala/com/cloudera/datascience/graph/RunGraph.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ object RunGraph extends Serializable {
197197
}
198198

199199
def hashId(str: String): Long = {
200+
// This is effectively the same implementation as in Guava's Hashing, but 'inlined'
201+
// to avoid a dependency on Guava just for this. It creates a long from the first 8 bytes
202+
// of the (16 byte) MD5 hash, with first byte as least-significant byte in the long.
200203
val bytes = MessageDigest.getInstance("MD5").digest(str.getBytes(StandardCharsets.UTF_8))
201204
(bytes(0) & 0xFFL) |
202205
((bytes(1) & 0xFFL) << 8) |

0 commit comments

Comments
 (0)