You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/08/13 15:55:12 UTC

[GitHub] keith-turner commented on a change in pull request #590: ACCUMULO-4746 Fluent API for Mutation

keith-turner commented on a change in pull request #590: ACCUMULO-4746 Fluent API for Mutation
URL: https://github.com/apache/accumulo/pull/590#discussion_r209660195
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/data/Mutation.java
 ##########
 @@ -853,6 +853,475 @@ public void putDelete(byte[] columnFamily, byte[] columnQualifier,
         EMPTY_BYTES);
   }
 
+  /**
+   * Provides methods for setting the column family of a Mutation. The user can provide the family
+   * name as a byte array, CharSequence, ByteBuffer, or Text object instance and the backend will do
+   * the necessary transformation.
+   *
+   * All FamilyOptions methods return an instance derived from the QualifierOptions interface,
+   * allowing the methods to be semantically chained.
+   *
+   * @since 2.0.0
+   */
+  public interface FamilyOptions extends QualifierOptions {
+    QualifierOptions family(byte[] colFam);
+
+    QualifierOptions family(ByteBuffer colFam);
+
+    QualifierOptions family(CharSequence colFam);
+
+    QualifierOptions family(Text colFam);
+  }
+
+  /**
+   * Provides methods for setting the column qualifier of a Mutation. The user can provide the
+   * qualifier name as a byte array, CharSequence, ByteBuffer, or Text object instance and the
+   * backend will do the necessary transformation.
+   *
+   * All QualifierOptions methods return an instance derived from the VisibilityOptions interface,
+   * allowing the methods to be semantically chained.
+   *
+   * @since 2.0.0
+   */
+  public interface QualifierOptions extends VisibilityOptions {
+    VisibilityOptions qualifier(byte[] colQual);
+
+    VisibilityOptions qualifier(ByteBuffer colQual);
+
+    VisibilityOptions qualifier(CharSequence colQual);
+
+    VisibilityOptions qualifier(Text colQual);
+  }
+
+  /**
+   * Provides methods for setting the column visibility of a Mutation. The user can provide the
+   * visibility as a byte array or {@link org.apache.accumulo.core.security.ColumnVisibility} object
+   * instance and the backend will do the necessary transformation.
+   *
+   * All QualifierOptions methods return an instance derived from the VisibilityOptions interface,
+   * allowing the methods to be semantically chained.
+   *
+   * @since 2.0.0
+   */
+  public interface VisibilityOptions extends TimestampOptions {
+    TimestampOptions visibility(byte[] colVis);
+
+    TimestampOptions visibility(ByteBuffer colVis);
+
+    TimestampOptions visibility(CharSequence colVis);
+
+    TimestampOptions visibility(ColumnVisibility colVis);
+
+    TimestampOptions visibility(Text colVis);
+  }
+
+  /**
+   * Provides methods for setting the timestamp of a Mutation. The user must provide the timestamp
+   * as a long.
+   *
+   * All TimestampOptions methods return an instance derived from the MutationOptions interface,
+   * allowing the methods to be semantically chained.
+   *
+   * @since 2.0.0
+   */
+  public interface TimestampOptions extends MutationOptions {
+    MutationOptions timestamp(long ts);
+  }
+
+  /**
+   * Provides methods for setting the value of a Mutation. The user can provide the value as a byte
+   * array, Value, or ByteBuffer object instance and the backend will do the necessary
+   * transformation.
+   *
+   * All MutationOptions methods complete a fluent Mutation API method chain.
+   *
+   * @since 2.0.0
+   */
+  public interface MutationOptions {
+    Mutation put(byte[] val);
+
+    Mutation put(ByteBuffer val);
+
+    Mutation put(CharSequence val);
+
+    Mutation put(Text val);
+
+    Mutation put(Value val);
+
+    Mutation delete();
+  }
+
+  /**
+   * Fluent API for putting or deleting to a Mutation that makes it easy use different types
+   * (i.e byte[], CharSequence, etc) when specifying the family, qualifier, value, etc.
+   *
+   * <p>
+   * Methods are optional but must follow this order: family, qualifier, visibility, timestamp.
+   *
+   * <p>
+   * The put and delete methods end the chain and finalize the Mutation by filling Mutation's
+   * UnsynchronizedBuffer.
+   *
+   * @return a new FamilyOptions object, advancing the method chain
 
 Review comment:
   Changing advancing to starting or beginning makes more sense to me.  But I am also ok with current wording.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services