




                Partitions in Cassandra
                
                I have...
                My Cluster spans the world
                
      
      DataCenter                DataCenter              DataCenter
        Tokyo                     London                   Cape Town
         I have
           4 Nodes                2 Nodes                  3 Nodes
        
        
      My Keyspace defines the RF = 3, (3 copies of each record)
      where should these copies go?
      
      RULE:
      ------------------------------------------------------
      
      I will start w/ RF=1 (1 copy of reach record)
      
      Cassandra will pick the Node (server) to host that copy based
      on your Primary key (the Partition key part of the Primary Key)
      
      When I insert a record into my Table (within the KeySpace)
      Cassandra runs a Partition (software) to compute which Node
      hosts this record
      
      For example I have have the Primary key of A21 -> the partitoner
      may computer a hash value (+/- 2^32) of 12382 
      That means the Node hosting the hash value of 12383 would host
      this record
      
      Note, a different Primary key could/would end up somewhere else in cluster (world)
      
      this hash value (computed by Cassandra from the Partition key part
      of the Primary Key) is called a Token
      
      ----------------------------------------------------------------
        CREATE TABLE customers (
         first_name text, 
         last_name text,
         company_name text,
         address text,
         city text,
         county text,
         state text,
         zip int,
         phone1 text,
         phone2 text,
         email text,
         web text,
         PRIMARY KEY ((state), city, last_name, first_name)) <- Here is the Primary key
                                                                 and it is Parts
                                                                 from left to right
                                                                 the first part is the
                                                                 Partition Key
                                                                 the rest of the Primary key
                                                                 are Clustering Columns
                 
      
      
------------------------------------------------------------

              I have...
                My Cluster spans the world
                
      
      DataCenter                DataCenter              DataCenter
        Tokyo                     London                   Cape Town
         I have
           4 Nodes                2 Nodes                  3 Nodes

        Node A in Tokyo hosts                           Node 22 in Cape Town hosts
        Token range 1000 thru 0                        Token Range 123123 thru 443123
        


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

   3 Node Cluster
   Node #1 has Token range 1-100 and 1000-1001 and 2000-2001, etc
        #2                 101-200
        #3                 201-300
        
        
    I insert 200 records
    record #12 has a Primary Key that (partition part) hashes to Token # 123
       it will go into Node #2
       
    record #91 has a Primary Key that (partition part) hashes to Token # 123
       it will go into Node #2   
       
