Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 2.0

Large and Negative numbers

2 replies [Last post]
  • Login or register to post comments
Mon, 01/16/2012 - 05:24
MarcusLongmuir
Offline
Joined: 08/08/2011
Groups: None

I'm currently using the Couchbase Server 2.0 Developer Preview, but I think what I am seeing is the same as Membase Server.

I'm using spymemcached in Java and I'd like to be able to increase a numeric key and return the new value. This works when the numbers are small as the result of the asyncIncr method fits into a Long, but when it doesn't Java overflows the Long and I end up with negative numbers. I can retrieve the correct (positive) value by doing a normal get as it returns the value as a String.

Is it possible to retrieve the result of asyncIncr as a String as to prevent this problem?

I'd also like to ask why negative numbers aren't supported and if there is a standard way to achieve this functionality by using an offset in my application code?

Thanks

Top
  • Login or register to post comments
Tue, 02/07/2012 - 22:06
mikew
Offline
Joined: 03/14/2011
Groups:

You bring up some interesting points, but at the moment I can't think of a good way to fix them. We could return a String, but this is kind of a pain to have to convert since most people won't be usng number long enough to overflow a long. We will think of something though. I filed a bug here:

http://www.couchbase.com/issues/browse/SPY-77

Also, if you are using Spymemcached 2.7.1 or lower then please upgrade since there was an issue affecting long's getting properly decoded. This might alleviate issues for you.

Top
  • Login or register to post comments
Thu, 10/04/2012 - 16:21
mikew
Offline
Joined: 03/14/2011
Groups:

I just realized that this is actually not an issue. The problem is that Java doesn't have a good way to represent an unsigned long so if the cas is really bg it will be interpreted by Java as a negative number. The bits that hold that number do correctly represent the cas value.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker