incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leonid Ilyevsky <lilyev...@mooncapital.com>
Subject RE: Setting column to null
Date Mon, 11 Jun 2012 13:50:47 GMT
Thanks, I understand what you are telling me. Obviously deleting the column is the proper way
to do this in Cassandra.
What I was looking for, is some convenient wrapper on top of that which will do it for me.
Here is my scenario.

I have a function that takes a record to be saved in Cassandra (array of objects, or Map<String,
Object>). Let say, it can have up to 8 columns. I prepare a statement like this:

Insert into <table> values(?, ?, ?, ?, ?, ?, ?, ?)

If I somehow could put null when I execute it, it would be enough to prepare that statement
once and execute it multiple times. I would then expect that when some element is null, the
corresponding column is not inserted (for the new key) or deleted (for the existing key).
The way it is now, in my code I have to examine which columns are present and which are not,
depending on that I have to generate customized statement, and it is going to be different
for the case of existing key versus case of the new key.
Isn't this too much hassle?

Related question. I assumed that prepared statement in Cassandra is there for the same reason
as in RDBMS, that is, for efficiency. In the above scenario, how expensive is it to execute
specialized statement for every record compare to prepared statement executed multiple times?

If I need to execute those specialized statements, should I still use prepared statement or
should I just generate a string with everything in ascii format?

-----Original Message-----
From: Roshni Rajagopal [mailto:Roshni.Rajagopal@wal-mart.com]
Sent: Monday, June 11, 2012 12:58 AM
To: user@cassandra.apache.org
Subject: Re: Setting column to null

Would you want to view data like this "there was a key, which had this column , but now it
does not have any value as of this time."

Unless you specifically want this information, I believe you should just delete the column,
rather than have an alternate value for NULL or create a composite column.

Because in cassandra that’s the way deletion is dealt with, putting NULLs is the way we
deal with it in RDBMS because we have a fixed number of columns which always have to have
some value, even if its NULL, and we have to have the same set of columns for every row.
In Cassandara, we can delete the column, and in most scenarios that’s what we should do,
unless we specifically want to preserve some history that this column was turned null at this
time…Each row can have different columns.

Regards,
Roshni

From: Edward Capriolo <edlinuxguru@gmail.com<mailto:edlinuxguru@gmail.com>>
Reply-To: "user@cassandra.apache.org<mailto:user@cassandra.apache.org>" <user@cassandra.apache.org<mailto:user@cassandra.apache.org>>
To: "user@cassandra.apache.org<mailto:user@cassandra.apache.org>" <user@cassandra.apache.org<mailto:user@cassandra.apache.org>>
Subject: Re: Setting column to null

Your best bet is to define the column as a composite column where one part represents is null
and the other part is the data.

On Friday, June 8, 2012, shashwat shriparv <dwivedishashwat@gmail.com<mailto:dwivedishashwat@gmail.com>>
wrote:
> What you can do is you can define some specific variable like "NULLDATA" some thing like
that to update in columns that does have value
>
>
> On Fri, Jun 8, 2012 at 11:58 PM, aaron morton <aaron@thelastpickle.com<mailto:aaron@thelastpickle.com>>
wrote:
>
> You don't nee to set columns to null, delete the column instead.
> Cheers
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
> On 8/06/2012, at 9:34 AM, Leonid Ilyevsky wrote:
>
> Is it possible to explicitly set a column value to null?
>
> I see that if insert statement does not include a specific column, that column comes
up as null (assuming we are creating a record with new unique key).
> But if we want to update a record, how we set it to null?
>
> Another situation is when I use prepared cql3 statement (in Java) and send parameters
when I execute it. If I want to leave some column unassigned, I need a special statement without
that column.
> What I would like is, prepare one statement including all columns, and then be able to
set some of them to null. I tried to set corresponding ByteBuffer parameter to null, obviously
got an exception.
> ________________________________
> This email, along with any attachments, is confidential and may be legally privileged
or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of
the contents of this email is strictly prohibited and may be in violation of law. If you are
not the intended recipient, any disclosure, copying, forwarding or distribution of this email
is strictly prohibited and this email and any attachments should be deleted immediately. This
email and any attachments do not constitute an offer to sell or a solicitation of an offer
to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP
(“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement
regarding legal, accounting or tax matters was not intended or written to be relied upon by
any person as advice. Moon Capital does not waive confidentiality or privilege as a result
of this email.
>
>
>
> --
>
>
> ∞
>
> Shashwat Shriparv
>
>

This email and any files transmitted with it are confidential and intended solely for the
individual or entity to whom they are addressed. If you have received this email in error
destroy it immediately. *** Walmart Confidential ***

This email, along with any attachments, is confidential and may be legally privileged or otherwise
protected from disclosure. Any unauthorized dissemination, copying or use of the contents
of this email is strictly prohibited and may be in violation of law. If you are not the intended
recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited
and this email and any attachments should be deleted immediately.  This email and any attachments
do not constitute an offer to sell or a solicitation of an offer to purchase any interest
in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon
Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting
or tax matters was not intended or written to be relied upon by any person as advice. Moon
Capital does not waive confidentiality or privilege as a result of this email.

Mime
View raw message