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

William Slacum commented on ACCUMULO-3718:
------------------------------------------

I verified that this happens in a scala console, but not in a simple scala 
application.

What happens is the console stores the resulting mutation in a register, so it 
calls {{Mutation#serialize}}, which sets the buffer to null. I added in some 
probing into {{Mutation}} to figure out when serialize gets called by the 
console:

{noformat}
at org.apache.accumulo.core.data.Mutation.serialize(Mutation.java:190)
        at org.apache.accumulo.core.data.Mutation.toThrift(Mutation.java:723)
        at org.apache.accumulo.core.data.Mutation.hashCode(Mutation.java:698)
        at java.lang.Object.toString(Object.java:237)
        at 
scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:324)
        at scala.runtime.ScalaRunTime$.stringOf(ScalaRunTime.scala:329)
        at scala.runtime.ScalaRunTime$.replStringOf(ScalaRunTime.scala:337)
        at $line4.$eval$.<init>(<console>:10)
        at $line4.$eval$.<clinit>(<console>)
        at $line4.$eval.$print(<console>)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:734)
        at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:983)
        at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:573)
        at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:604)
        at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:568)
        at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:760)
        at 
scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:805)
        at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:717)
        at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:581)
        at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:588)
        at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:591)
        at 
scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:882)
        at 
scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:837)
        at 
scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:837)
        at 
scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
        at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:837)
        at 
scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:83)
        at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
        at 
scala_maven_executions.JavaMainCallerInProcess.runInternal(JavaMainCallerInProcess.java:94)
        at 
scala_maven_executions.JavaMainCallerInProcess.run(JavaMainCallerInProcess.java:54)
        at 
scala_maven_executions.JavaMainCallerSupport.run(JavaMainCallerSupport.java:110)
        at scala_maven.ScalaConsoleMojo.doExecute(ScalaConsoleMojo.java:103)
        at scala_maven.ScalaMojoSupport.execute(ScalaMojoSupport.java:482)
        at 
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
        at 
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at 
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at 
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at 
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
        at 
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
        at 
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at 
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at 
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at 
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at 
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at 
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
{noformat}

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

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

Reply via email to