rpuch commented on code in PR #814:
URL: https://github.com/apache/ignite-3/pull/814#discussion_r878030139


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/RowVersion.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.pagememory.mv;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.pagememory.StorableBase;
+import org.apache.ignite.internal.pagememory.io.AbstractDataPageIo;
+import org.apache.ignite.internal.pagememory.io.IoVersions;
+import org.apache.ignite.internal.storage.pagememory.mv.io.RowVersionDataIo;
+import org.apache.ignite.internal.tx.Timestamp;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Represents row version inside row version chain.
+ */
+public class RowVersion extends StorableBase {
+    /**
+     * A 'timestamp' representing absense of a timestamp.
+     */
+    public static final Timestamp NULL_TIMESTAMP = new 
Timestamp(Long.MIN_VALUE, Long.MIN_VALUE);
+    /**
+     * Represents an absent partitionless link.
+     */
+    public static final long NULL_LINK = 0;
+
+    @Nullable
+    private final Timestamp timestamp;
+    private final long nextLink;
+    private final int valueSize;
+    private final ByteBuffer value;
+
+    /**
+     * Constructor.
+     */
+    public RowVersion(int partitionId, long nextLink, ByteBuffer value) {
+        this(partitionId, 0, null, nextLink, value);
+    }
+
+    /**
+     * Constructor.
+     */
+    public RowVersion(int partitionId, long link, @Nullable Timestamp 
timestamp, long nextLink, ByteBuffer value) {
+        super(partitionId);
+        link(link);
+
+        assert !NULL_TIMESTAMP.equals(timestamp) : "Null timestamp provided";
+
+        this.timestamp = timestamp;
+        this.nextLink = nextLink;
+        this.valueSize = value.limit();
+        this.value = value;
+    }
+
+    @Nullable
+    public Timestamp timestamp() {
+        return timestamp;
+    }
+
+    public Timestamp timestampForStorage() {
+        return timestamp == null ? NULL_TIMESTAMP : timestamp;
+    }
+
+    /**
+     * Returns partitionless link of the next version or {@code 0} if this 
version is the last in the chain (i.e. it's the oldest version).
+     *
+     * @return partitionless link of the next version or {@code 0} if this 
version is the last in the chain
+     */
+    public long nextLink() {
+        return nextLink;
+    }
+
+    public int valueSize() {
+        return valueSize;
+    }
+
+    public ByteBuffer value() {
+        return value;
+    }
+
+    public boolean hasNextLink() {
+        return nextLink != NULL_LINK;
+    }
+
+    boolean isTombstone() {
+        return valueSize() == 0;
+    }
+
+    boolean isUncommitted() {
+        return timestamp == null;
+    }
+
+    boolean isCommitted() {
+        return timestamp != null;
+    }
+
+    @Override
+    public int size() {
+        return timestampStoreSize() + nextLinkStoreSize() + valueStoreSize();
+    }
+
+    private int timestampStoreSize() {

Review Comment:
   Please disregard the previous comment, I re-read your comment and understood 
that I was fighting windmills. I changed it to constants (where it's possible).



-- 
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]

Reply via email to