ibessonov commented on code in PR #787: URL: https://github.com/apache/ignite-3/pull/787#discussion_r858563335
########## modules/storage-api/src/main/java/org/apache/ignite/internal/storage/UuidIgniteRowId.java: ########## @@ -0,0 +1,155 @@ +/* + * 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.ignite.internal.storage; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.UUID; +import org.jetbrains.annotations.NotNull; + +/** + * UUID-based ignite row id implementation. + */ +public final class UuidIgniteRowId implements IgniteRowId { + /* + * The most significant 64 bits. + */ + private final long mostSigBits; + + /* + * The least significant 64 bits. + */ + private final long leastSigBits; + + /** + * Constructor. + * + * @param uuid UUID. + */ + public UuidIgniteRowId(UUID uuid) { + this(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits()); + } + + /** Private constructor. */ + private UuidIgniteRowId(long mostSigBits, long leastSigBits) { + this.mostSigBits = mostSigBits; + this.leastSigBits = leastSigBits; + } + + /** + * Returns {@link UuidIgniteRowId} instance based on {@link UUID#randomUUID()}. Highest two bytes of the most significant bits part will + * encode partition id. + * + * @param partitionId Partition id. + */ + public static IgniteRowId randomRowId(int partitionId) { Review Comment: I think I'll add TODO for it. Do we have JIRA issue for adapting newer UUID formats? I'd say that it is out of scope of current PR. Anyways, why are we so concerned about collisions in UUID v4? Are there any real world examples of this ever happening? Like, ever in the history of using secure random? -- 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]
