accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From keith-turner <...@git.apache.org>
Subject [GitHub] accumulo pull request #108: ACCUMULO-4326 Accept Text and CharSeq in Value
Date Thu, 02 Jun 2016 22:02:52 GMT
Github user keith-turner commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/108#discussion_r65626882
  
    --- Diff: core/src/main/java/org/apache/accumulo/core/data/Value.java ---
    @@ -48,6 +50,30 @@ public Value() {
       }
     
       /**
    +   * Creates a value using the UTF-8 encoding of the CharSequence
    +   *
    +   * @param cs
    +   *          may not be null
    +   *
    +   * @since 1.8.0
    +   */
    +  public Value(CharSequence cs) {
    +    this(cs.toString().getBytes(StandardCharsets.UTF_8));
    +  }
    +
    +  /**
    +   * Creates a Value using the bytes of the Text. Makes a copy, does not use the byte
array from the Text.
    +   *
    +   * @param text
    +   *          may not be null
    +   *
    +   * @since 1.8.0
    +   */
    +  public Value(Text text) {
    +    this(text.getBytes(), 0, text.getLength());
    --- End diff --
    
    I was not sure about copying this.  Could implement it such that if the byte array from
the text is the correct length, then a copy could be avoided.   I decided against for two
reasons.
    
     * Sometimes copying and sometimes referencing seems confusing
     * The Key constructors that take Text always copy.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message