cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tamar Fraenkel <ta...@tok-media.com>
Subject Re: Creating counter columns in cassandra
Date Thu, 26 Jul 2012 06:00:28 GMT
Hi
To create:

ColumnFamilyDefinition counters = createBasicCfDef(
            KEYSPACE, Consts.COUNTERS, ComparatorType.UTF8TYPE,
            null, "CounterColumnType", "CompositeType(UTF8Type,UUIDType)");
    counters.setReplicateOnWrite(true);
    cluster.addColumnFamily(counters, true);

to increment (add) counter

  public static void incrementCounter(Composite key,
          String columnName, long inc) {
    Mutator<Composite> mutator =
            HFactory.createMutator(keyspace,
                    CompositeSerializer.get());
    mutator.incrementCounter(key,
            Consts.COUNTERS, columnName, inc);
    mutator.execute();
  }

Regards,

*Tamar Fraenkel *
Senior Software Engineer, TOK Media

[image: Inline image 1]

tamar@tok-media.com
Tel:   +972 2 6409736
Mob:  +972 54 8356490
Fax:   +972 2 5612956





On Wed, Jul 25, 2012 at 8:24 PM, Amila Paranawithana <amila1204@gmail.com>wrote:

>
> Hi all,
>
> I want to create counter columns in a column family via a java module.
> These column families and counter columns need to be created dynamically.
> plz send me some example codes to refer. (with hector or any  other method
> )
>
> Thanks
> --
> Amila Iroshani Paranawithana
> CSE-University of Moratuwa.
> B-http://amilaparanawithana.blogspot.com
> T-https://twitter.com/#!/AmilaPara
>
>
>

Mime
View raw message