/
githubmirror
/
the-algorithm
Обзор
Документация
Войти
/
githubmirror
/
the-algorithm
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/scala/com/twitter/simclusters_v2/common/SimClustersEmbeddingIdCacheKeyBuilder.scala
19 строк
587 B
twitter-team
Twitter Recommendation Algorithm
01 апр 2023, 01:36
01 апр 2023, 01:36
ef4c5eb
Код
Авторство
О чём код?
package com.twitter.simclusters_v2.common import com.twitter.simclusters_v2.thriftscala.SimClustersEmbeddingId /** * A common library to construct Cache Key for SimClustersEmbeddingId. */ case class SimClustersEmbeddingIdCacheKeyBuilder( hash: Array[Byte] => Long, prefix: String = "") { // Example: "CR:SCE:1:2:1234567890ABCDEF" def apply(embeddingId: SimClustersEmbeddingId): String = { f"$prefix:SCE:${embeddingId.embeddingType.getValue()}%X:" + f"${embeddingId.modelVersion.getValue()}%X" + f":${hash(embeddingId.internalId.toString.getBytes)}%X" } }