costya
(costya)
December 29, 2014, 11:48am
1
Hi,
I would like to predict the shards routing of a set of keys as a function
of the number of shards,without defining the actual index.
Elasticsearch Version 1.4.2
How can i check which hash function is used for routing ? and how can i
check it inside my java program ?
Thanks,
Costya
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8410c34e-5ad7-4b6b-89b9-7cbf758010eb%40googlegroups.com .
For more options, visit https://groups.google.com/d/optout .
jprante
(Jörg Prante)
December 29, 2014, 3:18pm
2
For ES 1.4, see
}
protected IndexShardRoutingTable shards(ClusterState clusterState, String index, int shardId) {
IndexShardRoutingTable indexShard = indexRoutingTable(clusterState, index).shard(shardId);
if (indexShard == null) {
throw new IndexShardMissingException(new ShardId(index, shardId));
}
return indexShard;
}
private int shardId(ClusterState clusterState, String index, String type, @Nullable String id, @Nullable String routing) {
if (routing == null) {
if (!useType) {
return Math.abs(hash(id) % indexMetaData(clusterState, index).numberOfShards());
} else {
return Math.abs(hash(type, id) % indexMetaData(clusterState, index).numberOfShards());
}
}
return Math.abs(hash(routing) % indexMetaData(clusterState, index).numberOfShards());
}
and the hash function is
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.cluster.routing.operation.hash.djb;
This file has been truncated. show original
Note, the hash function will change in ES 2.0.
You can not check from outside what hash function ES uses, this is internal
use only.
Jörg
On Mon, Dec 29, 2014 at 12:48 PM, Costya Regev costya@totango.com wrote:
Hi,
I would like to predict the shards routing of a set of keys as a
function of the number of shards,without defining the actual index.
Elasticsearch Version 1.4.2
How can i check which hash function is used for routing ? and how can i
check it inside my java program ?
Thanks,
Costya
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com .
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/8410c34e-5ad7-4b6b-89b9-7cbf758010eb%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/8410c34e-5ad7-4b6b-89b9-7cbf758010eb%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout .
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGLciGr6QEKDy_PLAU2v68aXNGHXf5gmN1w9Xb8aq%2BtnQ%40mail.gmail.com .
For more options, visit https://groups.google.com/d/optout .