Expiring Columns - how to set TTL?

167 views
Skip to first unread message

Oleg Tsvinev

unread,
Apr 24, 2011, 4:37:20 PM4/24/11
to hector...@googlegroups.com
It's been a while since 0.7 was announced that introduced expiring columns.
I can't find a Hector API to set the TTL value. I know there's a
Thrift way but using Thrift directly from Hector is discouraged.
Does anyone has experience setting the TTL?

Oleg Tsvinev

unread,
Apr 24, 2011, 4:56:26 PM4/24/11
to hector...@googlegroups.com
Looks like I need to use HColumn.setTtl directly as there's no factory method that would take TTL.

soumik

unread,
Apr 25, 2011, 7:57:06 AM4/25/11
to hector-users
Yes, TTL as the factory method param would've been nicer.

So, does calling the setTtl() method translate into the client making
an extra Cassandra "update" operation for the column in question?

There seems to be a method - HColumn<N, V> apply(V value, long clock,
int ttl). Not sure if we end up calling this method(or its overloaded
form) before the actual Column creation using Thrift.


On Apr 25, 1:56 am, Oleg Tsvinev <oleg.tsvi...@gmail.com> wrote:
> Looks like I need to use HColumn.setTtl directly as there's no factory
> method that would take TTL.
>

Oleg Tsvinev

unread,
Apr 25, 2011, 1:29:46 PM4/25/11
to hector...@googlegroups.com
Nope, it does not:

  @Override
  public HColumn<N, V> apply(V value, long clock, int ttl) {
    setValue(value);
    column.setTimestamp(clock);
    column.setTtl(ttl);
    return this;

soumik

unread,
Apr 25, 2011, 1:54:14 PM4/25/11
to hector-users
So in that case, setTtl() is another update on the column and not an
initial setting?

Oleg Tsvinev

unread,
Apr 25, 2011, 2:16:42 PM4/25/11
to hector...@googlegroups.com
HColumn.setTtl looks like just a setter for the TTL  property. 
HColumnImpl is a wrapper for Thrift Column type.
HFactory, which one uses to create a HColumn, does not have any createColumn methods that would take TTL as a parameter. So there's no initial setting. It has to be added, because I believe there is a demand for it :)

Nate McCall

unread,
Apr 25, 2011, 2:47:19 PM4/25/11
to hector...@googlegroups.com
HColumnImpl#apply is to facilitate re-use of HColumn.

Fair enough on the overloaded versions. We like patches :-)

Oleg Tsvinev

unread,
Apr 28, 2011, 4:20:25 PM4/28/11
to hector...@googlegroups.com
Just submitted a pull request.
Reply all
Reply to author
Forward
0 new messages