You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/04/19 02:28:39 UTC

[GitHub] [shardingsphere] lwclover opened a new pull request, #16913: NonaId faster and shorter than uuid

lwclover opened a new pull request, #16913:
URL: https://github.com/apache/shardingsphere/pull/16913

   Fixes #16912.
   
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on pull request #16913: NonaId faster and shorter than uuid

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on PR #16913:
URL: https://github.com/apache/shardingsphere/pull/16913#issuecomment-1101949289

   It it better to compare UUID generated by ThreadLocalRandom with NanoId.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] lwclover commented on a diff in pull request #16913: NonaId faster and shorter than uuid

Posted by GitBox <gi...@apache.org>.
lwclover commented on code in PR #16913:
URL: https://github.com/apache/shardingsphere/pull/16913#discussion_r852565279


##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/NonaIdKeyGenerateAlgorithm.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.shardingsphere.sharding.algorithm.keygen;
+
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+
+import com.aventrix.jnanoid.jnanoid.NanoIdUtils;
+
+/**
+ * NonaId key generate algorithm.
+ */
+public final class NonaIdKeyGenerateAlgorithm implements KeyGenerateAlgorithm {

Review Comment:
   done



##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/NonaIdKeyGenerateAlgorithm.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.shardingsphere.sharding.algorithm.keygen;
+
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+
+import com.aventrix.jnanoid.jnanoid.NanoIdUtils;
+
+/**
+ * NonaId key generate algorithm.
+ */
+public final class NonaIdKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
+    
+    @Override
+    public void init() {
+    }
+    
+    @Override
+    public Comparable<?> generateKey() {
+        return NanoIdUtils.randomNanoId();
+    }
+    
+    @Override
+    public String getType() {
+        return "NONAID";

Review Comment:
   done



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] tuichenchuxin merged pull request #16913: NanoId faster and shorter than uuid

Posted by GitBox <gi...@apache.org>.
tuichenchuxin merged PR #16913:
URL: https://github.com/apache/shardingsphere/pull/16913


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] lwclover commented on pull request #16913: NonaId faster and shorter than uuid

Posted by GitBox <gi...@apache.org>.
lwclover commented on PR #16913:
URL: https://github.com/apache/shardingsphere/pull/16913#issuecomment-1102151645

   > It it better to perform a JMH test to compare UUID generated by ThreadLocalRandom with NanoId.
   
   <html>
   <body>
   <!--StartFragment--><div class="okr-block-clipboard" data-okr="%7B%22okrDelta%22%3A%5B%7B%22lineType%22%3A%22unsupport%22%2C%22lineOptions%22%3A%7B%7D%2C%22lineContent%22%3A%5B%5D%7D%5D%2C%22businessKey%22%3A%22lark-doc%22%7D"></div><div data-zone-id="0" data-line-index="0" style="white-space: pre;">
   
   Test case | nanoid(ms) | uuid(ms)
   -- | -- | --
   1 thread generate total 10000000 | 15252 | 12546
   1 thread generate total 10000000,and ThreadLocalRandom optimization | 3596 | 5824
   10 thread generate total 10000000 | 23909 | 15609
   10 thread generate total 10000000,and ThreadLocalRandom optimization | 4094 | 5521
   test environment:Linux version 3.10.0-1062.18.1.el7.x86_64,8c 16m  conclusion:Nanoid performs better than UUID when optimized using ThreadLocalRandom
   
   </div><!--EndFragment-->
   </body>
   </html>


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on a diff in pull request #16913: NonaId faster and shorter than uuid

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on code in PR #16913:
URL: https://github.com/apache/shardingsphere/pull/16913#discussion_r852563030


##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/NonaIdKeyGenerateAlgorithm.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.shardingsphere.sharding.algorithm.keygen;
+
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+
+import com.aventrix.jnanoid.jnanoid.NanoIdUtils;
+
+/**
+ * NonaId key generate algorithm.
+ */
+public final class NonaIdKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
+    
+    @Override
+    public void init() {
+    }
+    
+    @Override
+    public Comparable<?> generateKey() {
+        return NanoIdUtils.randomNanoId();
+    }
+    
+    @Override
+    public String getType() {
+        return "NONAID";

Review Comment:
   Same as above.



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on a diff in pull request #16913: NonaId faster and shorter than uuid

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on code in PR #16913:
URL: https://github.com/apache/shardingsphere/pull/16913#discussion_r852562795


##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/NonaIdKeyGenerateAlgorithm.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.shardingsphere.sharding.algorithm.keygen;
+
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+
+import com.aventrix.jnanoid.jnanoid.NanoIdUtils;
+
+/**
+ * NonaId key generate algorithm.
+ */
+public final class NonaIdKeyGenerateAlgorithm implements KeyGenerateAlgorithm {

Review Comment:
   `Nona` or `Nano`?



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org