SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
Cassandra
   A short Intro




                   Vitaly Kushner
                    astrails.com
• Distributed
• Non-relational
• Linearly scalable
• Multi data-center aware
BigTable
http://labs.google.com/papers/bigtable.html
Terminology Sucks
      big time
my_cluster: {
  demo_app: {
    accounts: {
       "1": {
         "attributes": {
            "name": "astrails"
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {
       "1": {
         "name": "vitaly",
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {	 	 	 	 	 	 	 	              <<= Cluster Name
  demo_app: {
    accounts: {
       "1": {
         "attributes": {
            "name": "astrails"
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {
       "1": {
         "name": "vitaly",
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {
  demo_app: {	 	 	 	 	 	 	 	              <== Keyspace
    accounts: {
       "1": {
         "attributes": {
            "name": "astrails"
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {
       "1": {
         "name": "vitaly",
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {
  demo_app: {
    accounts: {	 	 	 	 	 	 	              <<= super column family
       "1": {
         "attributes": {
            "name": "astrails"
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {
       "1": {
         "name": "vitaly",
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {
  demo_app: {
    accounts: {
       "1": {
         "attributes": {
            "name": "astrails"
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {	 	 	 	 	 	 	 	               <<= column family
       "1": {
         "name": "vitaly",
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {
  demo_app: {
    accounts: {
       "1": {	 	 	 	 	 	 	 	              <<= key
         "attributes": {
            "name": "astrails"
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {
       "1": {
         "name": "vitaly",
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {
  demo_app: {
    accounts: {
       "1": {
         "attributes": {	 	 	 	 	         << super column
            "name": "astrails"
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {
       "1": {
         "name": "vitaly",
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {
  demo_app: {
    accounts: {
       "1": {
         "attributes": {
            "name": "astrails"	 	 	       <<= column
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {
       "1": {
         "name": "vitaly",
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {
  demo_app: {
    accounts: {
       "1": {
         "attributes": {
            "name": "astrails"	 	 	       <<= value
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {
       "1": {
         "name": "vitaly",
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {
  demo_app: {
    accounts: {
       "1": {
         "attributes": {
            "name": "astrails"
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {
       "1": {
         "name": "vitaly",	 	 	 	         <<= column
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {	 	 	 	 	 	 	 	              <<=   cluster
  demo_app: {	 	 	 	 	 	 	 	              <<=   keyspace
    accounts: {	 	 	 	 	 	 	              <<=   super column family
       "1": {	 	 	 	 	 	 	 	              <<=   key
         "attributes": {	 	 	 	 	         <<=   supercolumn
            "name": "astrails"	 	 	       <<=   column
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {	 	 	 	 	 	 	 	               <<= column family
       "1": {	 	 	 	 	 	 	 	              <<= key
         "name": "vitaly",	 	 	 	         <<= column
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {	 	 	 	 	 	 	 	              <<=   cluster
  demo_app: {	 	 	 	 	 	 	 	              <<=   database
    accounts: {	 	 	 	 	 	 	              <<=   super column family
       "1": {	 	 	 	 	 	 	 	              <<=   key
         "attributes": {	 	 	 	 	         <<=   supercolumn
            "name": "astrails"	 	 	       <<=   column
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {	 	 	 	 	 	 	 	               <<= column family
       "1": {	 	 	 	 	 	 	 	              <<= key
         "name": "vitaly",	 	 	 	         <<= column
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {	 	 	 	 	 	 	 	              <<=   cluster
  demo_app: {	 	 	 	 	 	 	 	              <<=   database
    accounts: {	 	 	 	 	 	 	              <<=   table
       "1": {	 	 	 	 	 	 	 	              <<=   key
         "attributes": {	 	 	 	 	         <<=   supercolumn
            "name": "astrails"	 	 	       <<=   column
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {	 	 	 	 	 	 	 	               <<= column family
       "1": {	 	 	 	 	 	 	 	              <<= key
         "name": "vitaly",	 	 	 	         <<= column
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {	 	 	 	 	 	 	 	              <<=   cluster
  demo_app: {	 	 	 	 	 	 	 	              <<=   database
    accounts: {	 	 	 	 	 	 	              <<=   table
       "1": {	 	 	 	 	 	 	 	              <<=   key
         "attributes": {	 	 	 	 	         <<=   supercolumn
            "name": "astrails"	 	 	       <<=   column
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {	 	 	 	 	 	 	 	               <<= table
       "1": {	 	 	 	 	 	 	 	              <<= key
         "name": "vitaly",	 	 	 	         <<= column
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {	 	 	 	 	 	 	 	              <<=   cluster
  demo_app: {	 	 	 	 	 	 	 	              <<=   database
    accounts: {	 	 	 	 	 	 	              <<=   table
       "1": {	 	 	 	 	 	 	 	              <<=   key
         "attributes": {	 	 	 	 	         <<=   collection
            "name": "astrails"	 	 	       <<=   column
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {	 	 	 	 	 	 	 	               <<= table
       "1": {	 	 	 	 	 	 	 	              <<= key
         "name": "vitaly",	 	 	 	         <<= column
         "email": "vitaly@astrails.com"
       }
    }
  }
}
my_cluster: {	 	 	 	 	 	 	 	              <<=   cluster
  demo_app: {	 	 	 	 	 	 	 	              <<=   database
    accounts: {	 	 	 	 	 	 	              <<=   table
       "1": {	 	 	 	 	 	 	 	              <<=   key
         "attributes": {	 	 	 	 	         <<=   collection
            "name": "astrails"	 	 	       <<=   attribute
         },
         "users": {
            "1" => "",
            "3" => "",
         }
       }
    },
    users: {	 	 	 	 	 	 	 	               <<= table
       "1": {	 	 	 	 	 	 	 	              <<= key
         "name": "vitaly",	 	 	 	         <<= attribute
         "email": "vitaly@astrails.com"
       }
    }
  }
}
Indexing
"my_cluster": {
  "demo_app": {
    "users": {
       "b2c75e99-e079-449d-b562-293dfdbf006e": {
         "attributes": {
           "name": "Vitaly",
           "email": "vitaly@astrails.com",
           "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e"
         }
       }
    },
    "emails": {
       "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
    "remember_me": {
       "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
  }
}
"my_cluster": {
  "demo_app": {
    "users": {
       "b2c75e99-e079-449d-b562-293dfdbf006e": {
         "attributes": {
           "name": "Vitaly",
           "email": "vitaly@astrails.com",
           "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e"
         }
       }
    },
    "emails": {
       "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
    "remember_me": {
       "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
  }
}
"my_cluster": {
  "demo_app": {
    "users": {
       "b2c75e99-e079-449d-b562-293dfdbf006e": {
         "attributes": {
           "name": "Vitaly",
           "email": "vitaly@astrails.com",
           "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e"
         }
       }
    },
    "emails": {
       "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
    "remember_me": {
       "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
  }
}
"my_cluster": {
  "demo_app": {
    "users": {
       "b2c75e99-e079-449d-b562-293dfdbf006e": {
         "attributes": {
           "name": "Vitaly",
           "email": "vitaly@astrails.com",
           "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e"
         }
       }
    },
    "emails": {
       "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
    "remember_me": {
       "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
  }
}
"my_cluster": {
  "demo_app": {
    "users": {
       "b2c75e99-e079-449d-b562-293dfdbf006e": {
         "attributes": {
           "name": "Vitaly",
           "email": "vitaly@astrails.com",
           "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e"
         }
       }
    },
    "emails": {
       "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
    "remember_me": {
       "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
  }
}
"my_cluster": {
  "demo_app": {
    "users": {
       "b2c75e99-e079-449d-b562-293dfdbf006e": {
         "attributes": {
           "name": "Vitaly",
           "email": "vitaly@astrails.com",
           "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e"
         }
       }
    },
    "emails": {
       "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
    "remember_me": {
       "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e",
    }
  }
}
Playtime
> gem install cassandra
...
> cassandra_helper cassandra
...
<ClusterName>my_cluster</ClusterName>

<Keyspaces>
  <Keyspace Name="demo_app">
    <ColumnFamily CompareWith="UTF8Type" Name="users" ColumnType="Super" CompareSubcolumnsWith="UTF8Type" />
    <ColumnFamily CompareWith="UTF8Type" Name="emails" ColumnType="Super" CompareSubcolumnsWith="UTF8Type" />
    <ColumnFamily CompareWith="UTF8Type" Name="tokens" />
  </Keyspace>
</Keyspaces>
require 'rubygems'
require 'cassandra'

include Cassandra::Constants

client = Cassandra.new('demo_app')

client.insert(:users, "1", {"name" => "vitaly", "email" => "vitaly@astrails.com"})
client.insert(:accounts, "1", {"attributes" => {"name" => "astrails"}, "users" => {"1" => ""}})

client.insert(:users, "2", {"name" => "boris"})
client.insert(:accounts, "1", {"users" => {"2" => ""}})

client.get(:users, "1")
Rails?
YES!
SmallRecord
WARNING: waporware :)
http://github.com/astrails/small_record
ActiveModel
class Account < SmallRecord::Base
  attribute :name
  attribute :created_at, :type => :datetime

  has_many :users

  validates_presence_of :name
end

class User < SmallRecord::Base
  attribute :name
  attribute :email
  attribute :created_at, :type => :datetime
  attribute :account_id

  def account
    @account ||= Account.find(:account_id)
  end

  validates_presence_of :name
  validates_presence_of :email
end

Account.find(params[:account]).users.first.name
production:
 adapter: cassandra
 host: 127.0.0.1
 port: 9160
 keyspace: chronos

development:
 adapter: mock

test:
 adapter: mock
production:
 adapter: cassandra
 host: 127.0.0.1
 port: 9160
 keyspace: chronos

development:
 adapter: mock

test:
 adapter: mock
Some Links

•   http://incubator.apache.org/cassandra

•   http://labs.google.com/papers/bigtable.html

•   http://blog.evanweaver.com/articles/2009/07/06/up-and-running-with-cassandra/

•   http://arin.me/blog/wtf-is-a-supercolumn-cassandra-data-model

•   http://github.com/astrails/small_record

Mais conteúdo relacionado

Mais procurados

Mais procurados (18)

What's new in Doctrine
What's new in DoctrineWhat's new in Doctrine
What's new in Doctrine
 
Effective Java with Groovy
Effective Java with GroovyEffective Java with Groovy
Effective Java with Groovy
 
Structuring React.js Components
Structuring React.js ComponentsStructuring React.js Components
Structuring React.js Components
 
4Developers 2018: Structuring React components (Bartłomiej Witczak)
4Developers 2018: Structuring React components (Bartłomiej Witczak)4Developers 2018: Structuring React components (Bartłomiej Witczak)
4Developers 2018: Structuring React components (Bartłomiej Witczak)
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen ChinHacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
Hacking JavaFX with Groovy, Clojure, Scala, and Visage: Stephen Chin
 
The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212
 
Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007
 
A to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperA to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java Developer
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
JavaFX and Scala - Like Milk and Cookies
JavaFX and Scala - Like Milk and CookiesJavaFX and Scala - Like Milk and Cookies
JavaFX and Scala - Like Milk and Cookies
 
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
 
Mysql python
Mysql pythonMysql python
Mysql python
 
Mysql python
Mysql pythonMysql python
Mysql python
 
BGOUG15: JSON support in MySQL 5.7
BGOUG15: JSON support in MySQL 5.7BGOUG15: JSON support in MySQL 5.7
BGOUG15: JSON support in MySQL 5.7
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)
 
Couchbase Korea User Group 2nd Meetup #2
Couchbase Korea User Group 2nd Meetup #2Couchbase Korea User Group 2nd Meetup #2
Couchbase Korea User Group 2nd Meetup #2
 

Destaque

Destaque (7)

Lean Software Development
Lean Software DevelopmentLean Software Development
Lean Software Development
 
Engineering esthetics
Engineering estheticsEngineering esthetics
Engineering esthetics
 
WTF is NoSQL
WTF is NoSQLWTF is NoSQL
WTF is NoSQL
 
RubyMotion: Put your Dreams in Motion with Ruby
RubyMotion: Put your Dreams in Motion with RubyRubyMotion: Put your Dreams in Motion with Ruby
RubyMotion: Put your Dreams in Motion with Ruby
 
Ruby is an Acceptable Lisp
Ruby is an Acceptable LispRuby is an Acceptable Lisp
Ruby is an Acceptable Lisp
 
Machine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code SmarterMachine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code Smarter
 
Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.
 

Semelhante a Cassandra intro

C# Starter L04-Collections
C# Starter L04-CollectionsC# Starter L04-Collections
C# Starter L04-Collections
Mohammad Shaker
 
How ElasticSearch lives in my DevOps life
How ElasticSearch lives in my DevOps lifeHow ElasticSearch lives in my DevOps life
How ElasticSearch lives in my DevOps life
琛琳 饶
 

Semelhante a Cassandra intro (20)

Building a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and JavaBuilding a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and Java
 
C# Starter L04-Collections
C# Starter L04-CollectionsC# Starter L04-Collections
C# Starter L04-Collections
 
Coming to Terms with GraphQL
Coming to Terms with GraphQLComing to Terms with GraphQL
Coming to Terms with GraphQL
 
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examples
 
Elasticsearch an overview
Elasticsearch   an overviewElasticsearch   an overview
Elasticsearch an overview
 
How ElasticSearch lives in my DevOps life
How ElasticSearch lives in my DevOps lifeHow ElasticSearch lives in my DevOps life
How ElasticSearch lives in my DevOps life
 
Rails3 changesets
Rails3 changesetsRails3 changesets
Rails3 changesets
 
Json Persistence Framework
Json Persistence FrameworkJson Persistence Framework
Json Persistence Framework
 
Architecture Components
Architecture ComponentsArchitecture Components
Architecture Components
 
Elastic tire demo
Elastic tire demoElastic tire demo
Elastic tire demo
 
Active record(1)
Active record(1)Active record(1)
Active record(1)
 
Ruby is Awesome
Ruby is AwesomeRuby is Awesome
Ruby is Awesome
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
 
MongoDB With Style
MongoDB With StyleMongoDB With Style
MongoDB With Style
 
Next-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNext-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and Prisma
 
The Testing Games: Mocking, yay!
The Testing Games: Mocking, yay!The Testing Games: Mocking, yay!
The Testing Games: Mocking, yay!
 
Ecto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii BodarevEcto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii Bodarev
 
Yurii Bodarev - Ecto DSL
Yurii Bodarev - Ecto DSLYurii Bodarev - Ecto DSL
Yurii Bodarev - Ecto DSL
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Cassandra intro

  • 1. Cassandra A short Intro Vitaly Kushner astrails.com
  • 2. • Distributed • Non-relational • Linearly scalable • Multi data-center aware
  • 4. Terminology Sucks big time
  • 5. my_cluster: { demo_app: { accounts: { "1": { "attributes": { "name": "astrails" }, "users": { "1" => "", "3" => "", } } }, users: { "1": { "name": "vitaly", "email": "vitaly@astrails.com" } } } }
  • 6. my_cluster: { <<= Cluster Name demo_app: { accounts: { "1": { "attributes": { "name": "astrails" }, "users": { "1" => "", "3" => "", } } }, users: { "1": { "name": "vitaly", "email": "vitaly@astrails.com" } } } }
  • 7. my_cluster: { demo_app: { <== Keyspace accounts: { "1": { "attributes": { "name": "astrails" }, "users": { "1" => "", "3" => "", } } }, users: { "1": { "name": "vitaly", "email": "vitaly@astrails.com" } } } }
  • 8. my_cluster: { demo_app: { accounts: { <<= super column family "1": { "attributes": { "name": "astrails" }, "users": { "1" => "", "3" => "", } } }, users: { "1": { "name": "vitaly", "email": "vitaly@astrails.com" } } } }
  • 9. my_cluster: { demo_app: { accounts: { "1": { "attributes": { "name": "astrails" }, "users": { "1" => "", "3" => "", } } }, users: { <<= column family "1": { "name": "vitaly", "email": "vitaly@astrails.com" } } } }
  • 10. my_cluster: { demo_app: { accounts: { "1": { <<= key "attributes": { "name": "astrails" }, "users": { "1" => "", "3" => "", } } }, users: { "1": { "name": "vitaly", "email": "vitaly@astrails.com" } } } }
  • 11. my_cluster: { demo_app: { accounts: { "1": { "attributes": { << super column "name": "astrails" }, "users": { "1" => "", "3" => "", } } }, users: { "1": { "name": "vitaly", "email": "vitaly@astrails.com" } } } }
  • 12. my_cluster: { demo_app: { accounts: { "1": { "attributes": { "name": "astrails" <<= column }, "users": { "1" => "", "3" => "", } } }, users: { "1": { "name": "vitaly", "email": "vitaly@astrails.com" } } } }
  • 13. my_cluster: { demo_app: { accounts: { "1": { "attributes": { "name": "astrails" <<= value }, "users": { "1" => "", "3" => "", } } }, users: { "1": { "name": "vitaly", "email": "vitaly@astrails.com" } } } }
  • 14. my_cluster: { demo_app: { accounts: { "1": { "attributes": { "name": "astrails" }, "users": { "1" => "", "3" => "", } } }, users: { "1": { "name": "vitaly", <<= column "email": "vitaly@astrails.com" } } } }
  • 15. my_cluster: { <<= cluster demo_app: { <<= keyspace accounts: { <<= super column family "1": { <<= key "attributes": { <<= supercolumn "name": "astrails" <<= column }, "users": { "1" => "", "3" => "", } } }, users: { <<= column family "1": { <<= key "name": "vitaly", <<= column "email": "vitaly@astrails.com" } } } }
  • 16. my_cluster: { <<= cluster demo_app: { <<= database accounts: { <<= super column family "1": { <<= key "attributes": { <<= supercolumn "name": "astrails" <<= column }, "users": { "1" => "", "3" => "", } } }, users: { <<= column family "1": { <<= key "name": "vitaly", <<= column "email": "vitaly@astrails.com" } } } }
  • 17. my_cluster: { <<= cluster demo_app: { <<= database accounts: { <<= table "1": { <<= key "attributes": { <<= supercolumn "name": "astrails" <<= column }, "users": { "1" => "", "3" => "", } } }, users: { <<= column family "1": { <<= key "name": "vitaly", <<= column "email": "vitaly@astrails.com" } } } }
  • 18. my_cluster: { <<= cluster demo_app: { <<= database accounts: { <<= table "1": { <<= key "attributes": { <<= supercolumn "name": "astrails" <<= column }, "users": { "1" => "", "3" => "", } } }, users: { <<= table "1": { <<= key "name": "vitaly", <<= column "email": "vitaly@astrails.com" } } } }
  • 19. my_cluster: { <<= cluster demo_app: { <<= database accounts: { <<= table "1": { <<= key "attributes": { <<= collection "name": "astrails" <<= column }, "users": { "1" => "", "3" => "", } } }, users: { <<= table "1": { <<= key "name": "vitaly", <<= column "email": "vitaly@astrails.com" } } } }
  • 20. my_cluster: { <<= cluster demo_app: { <<= database accounts: { <<= table "1": { <<= key "attributes": { <<= collection "name": "astrails" <<= attribute }, "users": { "1" => "", "3" => "", } } }, users: { <<= table "1": { <<= key "name": "vitaly", <<= attribute "email": "vitaly@astrails.com" } } } }
  • 22. "my_cluster": { "demo_app": { "users": { "b2c75e99-e079-449d-b562-293dfdbf006e": { "attributes": { "name": "Vitaly", "email": "vitaly@astrails.com", "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e" } } }, "emails": { "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e", } "remember_me": { "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e", } } }
  • 23. "my_cluster": { "demo_app": { "users": { "b2c75e99-e079-449d-b562-293dfdbf006e": { "attributes": { "name": "Vitaly", "email": "vitaly@astrails.com", "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e" } } }, "emails": { "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e", } "remember_me": { "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e", } } }
  • 24. "my_cluster": { "demo_app": { "users": { "b2c75e99-e079-449d-b562-293dfdbf006e": { "attributes": { "name": "Vitaly", "email": "vitaly@astrails.com", "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e" } } }, "emails": { "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e", } "remember_me": { "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e", } } }
  • 25. "my_cluster": { "demo_app": { "users": { "b2c75e99-e079-449d-b562-293dfdbf006e": { "attributes": { "name": "Vitaly", "email": "vitaly@astrails.com", "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e" } } }, "emails": { "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e", } "remember_me": { "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e", } } }
  • 26. "my_cluster": { "demo_app": { "users": { "b2c75e99-e079-449d-b562-293dfdbf006e": { "attributes": { "name": "Vitaly", "email": "vitaly@astrails.com", "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e" } } }, "emails": { "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e", } "remember_me": { "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e", } } }
  • 27. "my_cluster": { "demo_app": { "users": { "b2c75e99-e079-449d-b562-293dfdbf006e": { "attributes": { "name": "Vitaly", "email": "vitaly@astrails.com", "remember_me": "74c4f3a2c85b66f216211edd5245d25ba251d83e" } } }, "emails": { "vitaly@astrails.com": "b2c75e99-e079-449d-b562-293dfdbf006e", } "remember_me": { "74c4f3a2c85b66f216211edd5245d25ba251d83e": "b2c75e99-e079-449d-b562-293dfdbf006e", } } }
  • 29. > gem install cassandra ... > cassandra_helper cassandra ...
  • 30. <ClusterName>my_cluster</ClusterName> <Keyspaces> <Keyspace Name="demo_app"> <ColumnFamily CompareWith="UTF8Type" Name="users" ColumnType="Super" CompareSubcolumnsWith="UTF8Type" /> <ColumnFamily CompareWith="UTF8Type" Name="emails" ColumnType="Super" CompareSubcolumnsWith="UTF8Type" /> <ColumnFamily CompareWith="UTF8Type" Name="tokens" /> </Keyspace> </Keyspaces>
  • 31. require 'rubygems' require 'cassandra' include Cassandra::Constants client = Cassandra.new('demo_app') client.insert(:users, "1", {"name" => "vitaly", "email" => "vitaly@astrails.com"}) client.insert(:accounts, "1", {"attributes" => {"name" => "astrails"}, "users" => {"1" => ""}}) client.insert(:users, "2", {"name" => "boris"}) client.insert(:accounts, "1", {"users" => {"2" => ""}}) client.get(:users, "1")
  • 33. YES!
  • 37. class Account < SmallRecord::Base attribute :name attribute :created_at, :type => :datetime has_many :users validates_presence_of :name end class User < SmallRecord::Base attribute :name attribute :email attribute :created_at, :type => :datetime attribute :account_id def account @account ||= Account.find(:account_id) end validates_presence_of :name validates_presence_of :email end Account.find(params[:account]).users.first.name
  • 38. production: adapter: cassandra host: 127.0.0.1 port: 9160 keyspace: chronos development: adapter: mock test: adapter: mock
  • 39. production: adapter: cassandra host: 127.0.0.1 port: 9160 keyspace: chronos development: adapter: mock test: adapter: mock
  • 40. Some Links • http://incubator.apache.org/cassandra • http://labs.google.com/papers/bigtable.html • http://blog.evanweaver.com/articles/2009/07/06/up-and-running-with-cassandra/ • http://arin.me/blog/wtf-is-a-supercolumn-cassandra-data-model • http://github.com/astrails/small_record