JackieTien97 commented on code in PR #12426:
URL: https://github.com/apache/iotdb/pull/12426#discussion_r1598002956
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/executor/HashExecutor.java:
##########
@@ -16,28 +16,35 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.iotdb.commons.partition.executor.hash;
+
+package org.apache.iotdb.commons.partition.executor;
import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
-import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor;
-public class BKDRHashExecutor extends SeriesPartitionExecutor {
+import org.apache.tsfile.file.metadata.IDeviceID;
+
+public class HashExecutor extends SeriesPartitionExecutor {
private static final int SEED = 131;
+ private static final char PATH_SEPARATOR = '.';
- public BKDRHashExecutor(int deviceGroupCount) {
+ public HashExecutor(int deviceGroupCount) {
super(deviceGroupCount);
}
@Override
- public TSeriesPartitionSlot getSeriesPartitionSlot(String device) {
- int hash = 0;
-
- for (int i = 0; i < device.length(); i++) {
- hash = hash * SEED + (int) device.charAt(i);
+ public TSeriesPartitionSlot getSeriesPartitionSlot(IDeviceID deviceID) {
+ int hash = 0, segmentNum = deviceID.segmentNum();
+ for (int segmentID = 0; segmentID < segmentNum; segmentID++) {
+ String segment = (String) deviceID.segment(segmentID);
Review Comment:
But for now, this may be already enough.
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/executor/HashExecutor.java:
##########
@@ -16,28 +16,35 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.iotdb.commons.partition.executor.hash;
+
+package org.apache.iotdb.commons.partition.executor;
import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
-import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor;
-public class BKDRHashExecutor extends SeriesPartitionExecutor {
+import org.apache.tsfile.file.metadata.IDeviceID;
+
+public class HashExecutor extends SeriesPartitionExecutor {
private static final int SEED = 131;
+ private static final char PATH_SEPARATOR = '.';
- public BKDRHashExecutor(int deviceGroupCount) {
+ public HashExecutor(int deviceGroupCount) {
super(deviceGroupCount);
}
@Override
- public TSeriesPartitionSlot getSeriesPartitionSlot(String device) {
- int hash = 0;
-
- for (int i = 0; i < device.length(); i++) {
- hash = hash * SEED + (int) device.charAt(i);
+ public TSeriesPartitionSlot getSeriesPartitionSlot(IDeviceID deviceID) {
+ int hash = 0, segmentNum = deviceID.segmentNum();
+ for (int segmentID = 0; segmentID < segmentNum; segmentID++) {
+ String segment = (String) deviceID.segment(segmentID);
Review Comment:
Directly convert to String is not extensible, we may have other types for
ID Column in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]