mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-13 06:38:52 +02:00
ef4c5eb65e
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
17 lines
580 B
Scala
17 lines
580 B
Scala
package com.twitter.graph_feature_service.server.stores
|
|
|
|
import com.twitter.graph_feature_service.common.Configs.RandomSeed
|
|
import com.twitter.graph_feature_service.thriftscala.FeatureType
|
|
import scala.util.hashing.MurmurHash3
|
|
|
|
object FeatureTypesEncoder {
|
|
|
|
def apply(featureTypes: Seq[FeatureType]): String = {
|
|
val byteArray = featureTypes.flatMap { featureType =>
|
|
Array(featureType.leftEdgeType.getValue.toByte, featureType.rightEdgeType.getValue.toByte)
|
|
}.toArray
|
|
(MurmurHash3.bytesHash(byteArray, RandomSeed) & 0x7fffffff).toString // keep positive
|
|
}
|
|
|
|
}
|