You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Jonathan Ellis (JIRA)" <ji...@apache.org> on 2013/05/24 23:19:20 UTC

[jira] [Comment Edited] (CASSANDRA-5019) Still too much object allocation on reads

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

Jonathan Ellis edited comment on CASSANDRA-5019 at 5/24/13 9:18 PM:
--------------------------------------------------------------------

You're right.  It would need to be more like this:

{code}
class FlyweightColumns
{
  ByteBuffer[] names;
  ByteBuffer[] values;
  long[] timestamps;

  private int index;
  private FlyweightColumn instance = new FlyweightColumn();

  public IColumn getColumn(int i)
  {
     index = i;
     return instance;
  }

  private class FlyweightColumn implements IColumn
  {
    public ByteBuffer name()
    {
      return names[index];
    }

    ... 
  }
}
{code}

Obviously some caution would be required (like ABSC, this is not suitable for Memtable or cache use) but this would be totally adequate for the main "read some columns for the user, then serialize them back to the coordinator" path.

For more OO sugar we could move operations like "serialize columns to this OutputStream" into ISortedColumns instead of exposing getColumn(int) directly, I include that mainly because it is the easiest way to illustrate the FWC re-use.
                
      was (Author: jbellis):
    You're right.  It would need to be more like this:

A Flyweight pattern is one approach.  Something like

{code}
class FlyweightColumns
{
  ByteBuffer[] names;
  ByteBuffer[] values;
  long[] timestamps;

  private int index;
  private FlyweightColumn instance = new FlyweightColumn();

  public IColumn getColumn(int i)
  {
     index = i;
     return instance;
  }

  private class FlyweightColumn implements IColumn
  {
    public ByteBuffer name()
    {
      return names[index];
    }

    ... 
  }
}
{code}

Obviously some caution would be required (like ABSC, this is not suitable for Memtable or cache use) but this would be totally adequate for the main "read some columns for the user, then serialize them back to the coordinator" path.

For more OO sugar we could move operations like "serialize columns to this OutputStream" into ISortedColumns instead of exposing getColumn(int) directly, I include that mainly because it is the easiest way to illustrate the FWC re-use.
                  
> Still too much object allocation on reads
> -----------------------------------------
>
>                 Key: CASSANDRA-5019
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-5019
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Jonathan Ellis
>             Fix For: 2.1
>
>
> ArrayBackedSortedColumns was a step in the right direction but it's still relatively heavyweight thanks to allocating individual Columns.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira