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


##########
modules/metastorage-api/src/main/java/org/apache/ignite/internal/metastorage/dsl/SimpleCondition.java:
##########
@@ -20,46 +20,101 @@
 /**
  * Represents a condition for a meta storage conditional update.
  */
-public final class SimpleCondition implements Condition {
-    /** Actual condition implementation. */
-    private final InnerCondition cond;
+public class SimpleCondition implements Condition {
+    /** Entry key. */
+    private final byte[] key;
 
     /**
-     * Constructs a condition, which wraps the actual condition implementation.
-     *
-     * @param cond The actual condition implementation.
+     * Condition type.
      */
-    SimpleCondition(InnerCondition cond) {
-        this.cond = cond;
+    private final ConditionType type;
+
+    private SimpleCondition(byte[] key, ConditionType type) {
+        this.key = key;
+        this.type = type;
     }
 
-    public InnerCondition inner() {
-        return cond;
+    /**
+     * Returns the key, which identifies an entry, which condition will be 
applied to.
+     *
+     * @return Key, which identifies an entry, which condition will be applied 
to.
+     */
+    public byte[] key() {
+        return key;
     }
 
+    /**
+     * Returns the condition type.
+     *
+     * @return Condition type.
+     */
     public ConditionType type() {
-        return cond.type();
+        return type;
     }
 
     /**
-     * Represents a condition on an entry revision. Only one type of condition 
could be applied to the one instance of a condition.
-     * Subsequent invocations of any method, which produces a condition will 
throw {@link IllegalStateException}.
+     * Creates a builder for a revision condition.
+     *
+     * @param key Key, which identifies an entry, which condition will be 
applied to.
+     * @return Builder for a revision condition.
+     * @see RevisionCondition
      */
-    public static final class RevisionCondition extends AbstractCondition {
-        /** The revision as the condition argument. */
-        private long rev;
+    public static RevisionConditionBuilder revision(byte[] key) {
+        return new RevisionConditionBuilder(key);
+    }
 
-        /**
-         * Constructs a condition by a revision for an entry identified by the 
given key.
-         *
-         * @param key Identifies an entry, which condition will be applied to.
-         */
-        RevisionCondition(byte[] key) {
-            super(key);
-        }
+    /**
+     * Creates a builder for a value condition.
+     *
+     * @param key Key, which identifies an entry, which condition will be 
applied to.
+     * @return Builder for a value condition.
+     * @see ValueCondition
+     */
+    public static ValueConditionBuilder value(byte[] key) {
+        return new ValueConditionBuilder(key);
+    }
 
-        public long revision() {
-            return rev;
+    /**
+     * Produces the condition of type {@link ConditionType#TOMBSTONE}. This 
condition tests that an entry's value, identified by the
+     * given key, is tombstone.
+     *
+     * @return The condition of type {@link ConditionType#TOMBSTONE}.
+     * @throws IllegalStateException In the case when the condition is already 
defined.
+     */
+    public static SimpleCondition tombstone(byte[] key) {
+        return new SimpleCondition(key, ConditionType.TOMBSTONE);
+    }
+
+    /**
+     * Produces the condition of type {@link ConditionType#KEY_EXISTS}. This 
condition tests the existence of an entry identified by the
+     * given key.
+     *
+     * @return The condition of type {@link ConditionType#KEY_EXISTS}.
+     * @throws IllegalStateException In the case when the condition is already 
defined.

Review Comment:
   Do we need this?



##########
modules/metastorage-api/src/main/java/org/apache/ignite/internal/metastorage/dsl/SimpleCondition.java:
##########
@@ -20,46 +20,101 @@
 /**
  * Represents a condition for a meta storage conditional update.
  */
-public final class SimpleCondition implements Condition {
-    /** Actual condition implementation. */
-    private final InnerCondition cond;
+public class SimpleCondition implements Condition {
+    /** Entry key. */
+    private final byte[] key;
 
     /**
-     * Constructs a condition, which wraps the actual condition implementation.
-     *
-     * @param cond The actual condition implementation.
+     * Condition type.
      */
-    SimpleCondition(InnerCondition cond) {
-        this.cond = cond;
+    private final ConditionType type;
+
+    private SimpleCondition(byte[] key, ConditionType type) {
+        this.key = key;
+        this.type = type;
     }
 
-    public InnerCondition inner() {
-        return cond;
+    /**
+     * Returns the key, which identifies an entry, which condition will be 
applied to.
+     *
+     * @return Key, which identifies an entry, which condition will be applied 
to.
+     */
+    public byte[] key() {
+        return key;
     }
 
+    /**
+     * Returns the condition type.
+     *
+     * @return Condition type.
+     */
     public ConditionType type() {
-        return cond.type();
+        return type;
     }
 
     /**
-     * Represents a condition on an entry revision. Only one type of condition 
could be applied to the one instance of a condition.
-     * Subsequent invocations of any method, which produces a condition will 
throw {@link IllegalStateException}.
+     * Creates a builder for a revision condition.
+     *
+     * @param key Key, which identifies an entry, which condition will be 
applied to.
+     * @return Builder for a revision condition.
+     * @see RevisionCondition
      */
-    public static final class RevisionCondition extends AbstractCondition {
-        /** The revision as the condition argument. */
-        private long rev;
+    public static RevisionConditionBuilder revision(byte[] key) {
+        return new RevisionConditionBuilder(key);
+    }
 
-        /**
-         * Constructs a condition by a revision for an entry identified by the 
given key.
-         *
-         * @param key Identifies an entry, which condition will be applied to.
-         */
-        RevisionCondition(byte[] key) {
-            super(key);
-        }
+    /**
+     * Creates a builder for a value condition.
+     *
+     * @param key Key, which identifies an entry, which condition will be 
applied to.
+     * @return Builder for a value condition.
+     * @see ValueCondition
+     */
+    public static ValueConditionBuilder value(byte[] key) {
+        return new ValueConditionBuilder(key);
+    }
 
-        public long revision() {
-            return rev;
+    /**
+     * Produces the condition of type {@link ConditionType#TOMBSTONE}. This 
condition tests that an entry's value, identified by the
+     * given key, is tombstone.
+     *
+     * @return The condition of type {@link ConditionType#TOMBSTONE}.
+     * @throws IllegalStateException In the case when the condition is already 
defined.

Review Comment:
   I don't see a possibility for this exception to be thrown. Why do we need 
this declaration?



##########
modules/metastorage-api/src/main/java/org/apache/ignite/internal/metastorage/dsl/SimpleCondition.java:
##########
@@ -91,15 +138,7 @@ public SimpleCondition eq(long rev) {
          * @throws IllegalStateException In the case when the condition is 
already defined.

Review Comment:
   Do we need this?



##########
modules/metastorage-api/src/main/java/org/apache/ignite/internal/metastorage/dsl/SimpleCondition.java:
##########
@@ -20,46 +20,101 @@
 /**
  * Represents a condition for a meta storage conditional update.
  */
-public final class SimpleCondition implements Condition {
-    /** Actual condition implementation. */
-    private final InnerCondition cond;
+public class SimpleCondition implements Condition {
+    /** Entry key. */
+    private final byte[] key;
 
     /**
-     * Constructs a condition, which wraps the actual condition implementation.
-     *
-     * @param cond The actual condition implementation.
+     * Condition type.
      */
-    SimpleCondition(InnerCondition cond) {
-        this.cond = cond;
+    private final ConditionType type;
+
+    private SimpleCondition(byte[] key, ConditionType type) {
+        this.key = key;
+        this.type = type;
     }
 
-    public InnerCondition inner() {
-        return cond;
+    /**
+     * Returns the key, which identifies an entry, which condition will be 
applied to.
+     *
+     * @return Key, which identifies an entry, which condition will be applied 
to.
+     */
+    public byte[] key() {
+        return key;
     }
 
+    /**
+     * Returns the condition type.
+     *
+     * @return Condition type.
+     */
     public ConditionType type() {
-        return cond.type();
+        return type;
     }
 
     /**
-     * Represents a condition on an entry revision. Only one type of condition 
could be applied to the one instance of a condition.
-     * Subsequent invocations of any method, which produces a condition will 
throw {@link IllegalStateException}.
+     * Creates a builder for a revision condition.
+     *
+     * @param key Key, which identifies an entry, which condition will be 
applied to.
+     * @return Builder for a revision condition.
+     * @see RevisionCondition
      */
-    public static final class RevisionCondition extends AbstractCondition {
-        /** The revision as the condition argument. */
-        private long rev;
+    public static RevisionConditionBuilder revision(byte[] key) {
+        return new RevisionConditionBuilder(key);
+    }
 
-        /**
-         * Constructs a condition by a revision for an entry identified by the 
given key.
-         *
-         * @param key Identifies an entry, which condition will be applied to.
-         */
-        RevisionCondition(byte[] key) {
-            super(key);
-        }
+    /**
+     * Creates a builder for a value condition.
+     *
+     * @param key Key, which identifies an entry, which condition will be 
applied to.
+     * @return Builder for a value condition.
+     * @see ValueCondition
+     */
+    public static ValueConditionBuilder value(byte[] key) {
+        return new ValueConditionBuilder(key);
+    }
 
-        public long revision() {
-            return rev;
+    /**
+     * Produces the condition of type {@link ConditionType#TOMBSTONE}. This 
condition tests that an entry's value, identified by the
+     * given key, is tombstone.
+     *
+     * @return The condition of type {@link ConditionType#TOMBSTONE}.
+     * @throws IllegalStateException In the case when the condition is already 
defined.
+     */
+    public static SimpleCondition tombstone(byte[] key) {
+        return new SimpleCondition(key, ConditionType.TOMBSTONE);
+    }
+
+    /**
+     * Produces the condition of type {@link ConditionType#KEY_EXISTS}. This 
condition tests the existence of an entry identified by the
+     * given key.
+     *
+     * @return The condition of type {@link ConditionType#KEY_EXISTS}.
+     * @throws IllegalStateException In the case when the condition is already 
defined.
+     */
+    public static SimpleCondition exists(byte[] key) {
+        return new SimpleCondition(key, ConditionType.KEY_EXISTS);
+    }
+
+    /**
+     * Produces the condition of type {@link ConditionType#KEY_NOT_EXISTS}. 
This condition tests the non-existence of an entry
+     * identified by the given key.
+     *
+     * @return The condition of type {@link ConditionType#KEY_NOT_EXISTS}.
+     * @throws IllegalStateException In the case when the condition is already 
defined.

Review Comment:
   Do we need this?



##########
modules/metastorage-api/src/main/java/org/apache/ignite/internal/metastorage/dsl/SimpleCondition.java:
##########
@@ -71,15 +126,7 @@ public long revision() {
          * @throws IllegalStateException In the case when the condition is 
already defined.

Review Comment:
   Do we need this?



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