Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Accumulo >> mail # dev >> Can Mutation.readFields return Mutation instead fo void?


Copy link to this message
-
Can Mutation.readFields return Mutation instead fo void?
I am looking to simplify some. Here is the code I am looking at:

  private Mutation cloneMutation(Mutation m) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    m.write(dos);
    dos.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DataInputStream dis = new DataInputStream(bais);

    Mutation m = new Mutation();
    m.readFields(dis);
    return m;
  }

The readFields method in Mutation starts like this:

  @Override
  public void readFields(DataInput in) throws IOException {
  ...
  }

It seems harmless to have readFields return 'this' instead fo void.
Any objections?

On a slightly different note, it seems like readFields should actually
be a constructor. Because it's job is to set the row, data, value, and
entries. Just as the other constructors do. Any objections to
converting it to a constructor.
+
Billie Rinaldi 2012-09-11, 13:41
+
David Medinets 2012-09-11, 15:38
+
Keith Turner 2012-09-11, 15:59
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB