You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "Josh Elser (JIRA)" <ji...@apache.org> on 2015/04/09 06:27:12 UTC

[jira] [Comment Edited] (ACCUMULO-3718) not possible to create a Mutation object from scala w/o some extra helper code

    [ https://issues.apache.org/jira/browse/ACCUMULO-3718?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14486666#comment-14486666 ] 

Josh Elser edited comment on ACCUMULO-3718 at 4/9/15 4:26 AM:
--------------------------------------------------------------

bq. Seems like a real bad code smell to have Mutation#hashCode mutate the object.

+1

Maybe just use the Object's hashCode implementation? I can't think of a practical use where a user would strongly benefit from that accurate of a hashCode? Probably can't do that in 1.5 or 1.6 though. A simple fix would be to get a copy of the bytes, do the toThrift and hashCode that way instead of relying on serialize().


was (Author: elserj):
bq. Seems like a real bad code smell to have Mutation#hashCode mutate the object.

+1

Maybe just use the Object's hashCode implementation? I can't think of a practical use where a user would strongly benefit from that accurate of a hashCode? Probably can't do that in 1.5 or 1.6 though.

> not possible to create a Mutation object from scala w/o some extra helper code
> ------------------------------------------------------------------------------
>
>                 Key: ACCUMULO-3718
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-3718
>             Project: Accumulo
>          Issue Type: Bug
>    Affects Versions: 1.5.2, 1.6.2
>            Reporter: David Holiday
>            Priority: Minor
>
> issue: 
> it's not possible to create a Mutation object from scala without employing a standalone java jar wrapper. the preferred method for creating the object has you do it in two stages: create with table row, then employ Mutation.put() to populate the object with the actual mutation data. when you do this in scala, you get a
> java.lang.IllegalStateException: Can not add to mutation after serializing it at org.apache.accumulo.core.data.Mutation.put(Mutation.java:168) at org.apache.accumulo.core.data.Mutation.put(Mutation.java:163) at org.apache.accumulo.core.data.Mutation.put(Mutation.java:211)
> error. I *think* this has something to do with the byte array going out of scope in Scala but somehow not in Java. If you concat the operations (constuctor().put(data, data, ...) you don't run into the error, but scala sees a Unit return type, so you can't actually add the mutation to a BatchWriter. The only way I was able to get around this was to create a stand-alone jar with a method that created then returned a populated mutation object. 
> I wasn't sure whether or not to call this a bug or an enhancement. given that you probably want Accumulo to play nice with Scala I decided to call it a bug. 
> below is a link to the stack overflow thread I created whilst figuring all this out: 
> http://stackoverflow.com/questions/29497547/odd-error-when-populating-accumulo-1-6-mutation-object-via-spark-notebook/29527189#29527189



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)