Java Code Examples for com.google.common.primitives.Longs.hashCode()

The following are Jave code examples for showing how to use hashCode() of the com.google.common.primitives.Longs class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: sstable-adaptor   File: Murmur3Partitioner.java   View Source Code Vote up 4 votes
public int hashCode()
{
    return Longs.hashCode(token);
}
 
Example 2
Project: GitHub   File: TimeInstant.java   View Source Code Vote up 4 votes
@Override
public int hashCode() {
  return Longs.hashCode(value);
}
 
Example 3
Project: Elasticsearch   File: RandomScoreFunctionParser.java   View Source Code Vote up 4 votes
@Override
public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException {

    int seed = -1;

    String currentFieldName = null;
    XContentParser.Token token;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (token.isValue()) {
            if ("seed".equals(currentFieldName)) {
                if (token == XContentParser.Token.VALUE_NUMBER) {
                    if (parser.numberType() == XContentParser.NumberType.INT) {
                        seed = parser.intValue();
                    } else if (parser.numberType() == XContentParser.NumberType.LONG) {
                        seed = Longs.hashCode(parser.longValue());
                    } else {
                        throw new QueryParsingException(parseContext, "random_score seed must be an int, long or string, not '"
                                + token.toString() + "'");
                    }
                } else if (token == XContentParser.Token.VALUE_STRING) {
                    seed = parser.text().hashCode();
                } else {
                    throw new QueryParsingException(parseContext, "random_score seed must be an int/long or string, not '"
                            + token.toString() + "'");
                }
            } else {
                throw new QueryParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
            }
        }
    }

    final MappedFieldType fieldType = SearchContext.current().mapperService().smartNameFieldType("_uid");
    if (fieldType == null) {
        // mapper could be null if we are on a shard with no docs yet, so this won't actually be used
        return new RandomScoreFunction();
    }

    if (seed == -1) {
        seed = Longs.hashCode(parseContext.nowInMillis());
    }
    final ShardId shardId = SearchContext.current().indexShard().shardId();
    final int salt = (shardId.index().name().hashCode() << 10) | shardId.id();
    final IndexFieldData<?> uidFieldData = SearchContext.current().fieldData().getForField(fieldType);

    return new RandomScoreFunction(seed, salt, uidFieldData);
}
 
Example 4
Project: Lagerta   File: TransactionalKafkaProducer.java   View Source Code Vote up 4 votes
private Integer partition(Message msg) {
    return Longs.hashCode(msg.metadata.getTransactionId()) % partitions;
}
 
Example 5
Project: Lagerta   File: AccountTransactionKey.java   View Source Code Vote up 4 votes
public int hashCode() {
    return Longs.hashCode(transactionId);
}
 
Example 6
Project: Lagerta   File: TransactionMessageUtil.java   View Source Code Vote up 4 votes
public static int partitionFor(long transactionId, int partitions) {
    return Longs.hashCode(transactionId) % partitions;
}
 
Example 7
Project: Lagerta   File: AccountTransactionKey.java   View Source Code Vote up 4 votes
public int hashCode() {
    return Longs.hashCode(transactionId);
}