Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for 
change notification.

The "FAQ" page has been changed by Alan Malloy.
The comment on this change is: Describe how to create a TimeUUID from a 
java.util.Date.
http://wiki.apache.org/cassandra/FAQ?action=diff&rev1=99&rev2=100

--------------------------------------------------

              return buffer;
          }
  }}}
+ Further, it is often useful to create a TimeUUID object from some time other 
than the present: for example, to use as the lower bound in a SlicePredicate to 
retrieve all columns whose TimeUUID comes after time ''X''. Most libraries 
don't provide this functionality, probably because this breaks the "Universal" 
part of UUID: '''this should give you pause'''! Never assume such a UUID is 
unique: use it only as a marker for a specific time.
+ 
+ With those disclaimers out of the way, if you feel a need to create a 
TimeUUID based on a specific date, here is some code that will work:
+ 
+ {{{
+         public static java.util.UUID uuidForDate(Date d)
+         {
+ /*
+   Magic number obtained from #cassandra's thobbs, who
+   claims to have stolen it from a Python library.
+ */
+             final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 
0x01b21dd213814000L;
+ 
+             long origTime = d.getTime();
+             long time = origTime * 10000 + 
NUM_100NS_INTERVALS_SINCE_UUID_EPOCH;
+             long timeLow = time &       0xffffffffL;
+             long timeMid = time &   0xffff00000000L;
+             long timeHi = time & 0xfff000000000000L;
+             long upperLong = (timeLow << 32) | (timeMid >> 16) | (1 << 12) | 
(timeHi >> 48) ;
+             return new java.util.UUID(upperLong, 0xC000000000000000L);
+         }
+ }}}
  <<Anchor(i_deleted_what_gives)>>
  
  == I delete data from Cassandra, but disk usage stays the same. What gives? ==
@@ -266, +288 @@

  == Is there a GUI admin tool for Cassandra? ==
  The closest is [[http://github.com/driftx/chiton|chiton]], a GTK data browser.
  
- Another java UI [[http://code.google.com/p/cassandra-gui]], a Swing data 
browser.
+ Another java UI http://code.google.com/p/cassandra-gui, a Swing data browser.
  
  <<Anchor(a_long_is_exactly_8_bytes)>>
  
@@ -327, +349 @@

  <<Anchor(logging_using_cassandra)>>
  
  == Are there ways to do logging directly to Cassandra? ==
- 
  For information on logging directly to Cassandra, see LoggingToCassandra.
  
  <<Anchor(rhel_selinux)>>
  
  == On RHEL nodes are unable to join the ring ==
- 
  Check if selinux is on, if it is turn it OFF
  
  <<Anchor(auth)>>
  
  == Is there an authentication/authorization mechanism for Cassandra? ==
- 
  Yes. For details, see ExtensibleAuth.
  
  <<Anchor(bulkloading)>>
  
  == How do I bulk load data into Cassandra? ==
- 
  See BulkLoading
  
  <<Anchor(unsubscribe)>>
  
  == How do I unsubscribe from the email list? ==
- 
  Send an email to [email protected]
  

Reply via email to