Skip to content

Instantly share code, notes, and snippets.

diff -ru /Users/makoto/src/simplerdb-0.2/lib/simplerdb/query_language.rb /Library/Ruby/Gems/1.8/gems/simplerdb-0.2/lib/simplerdb/query_language.rb
--- /Users/makoto/src/simplerdb-0.2/lib/simplerdb/query_language.rb 2008-03-15 04:26:01.000000000 +0000
+++ /Library/Ruby/Gems/1.8/gems/simplerdb-0.2/lib/simplerdb/query_language.rb 2008-10-20 12:05:15.000000000 +0100
@@ -14,17 +14,23 @@
# Execute the query
def do_query(query, domain, max = 100, token = 0)
- parse_result = @parser.parse(@lexer.lex(query))
token = 0 if token.nil?
# There are some old db files around. Need to wipe out.
rm -rf /var/lib/mysql/*
# Install mysql and xfs related libraries.
apt-get update && apt-get upgrade -y
apt-get install -y xfsprogs mysql-server libmysql-ruby libmysqlclient15-dev
# Create and attach volume to /vol using the example below
# Stop mysql, move /var/live/mysql to /vol , create new config, and start it up again.
# The detail is at http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1663&categoryID=100
# Follow http://pandastream.com/docs/getting_started to grab panda.
# There are some old db files around. Need to wipe out.
rm -rf /var/lib/mysql/*
# Install mysql and xfs related libraries.
apt-get update && apt-get upgrade -y
apt-get install -y xfsprogs mysql-server libmysql-ruby libmysqlclient15-dev
# Create and attach volume to /vol using the example below
# Stop mysql, move /var/live/mysql to /vol , create new config, and start it up again.
# The detail is at http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1663&categoryID=100
# Follow http://pandastream.com/docs/getting_started to grab panda.
@makoto
makoto / gist:20456
Created October 28, 2008 18:05
dm panda installation note
# There are some old db files around. Need to wipe out.
rm -rf /var/lib/mysql/*
# Install mysql and xfs related libraries.
apt-get update && apt-get upgrade -y
apt-get install -y xfsprogs mysql-server libmysql-ruby libmysqlclient15-dev
# Create and attach volume to /vol using the example below
def after_create
- self.uploaded_photo_ids.each{|photo| self.photos << Photo.find(photo)} unless self.uploaded_photo_ids.blank?
+ self.photos << Photo.find_all_by_id(self.uploaded_photo_ids.compact) unless self.uploaded_photo_ids.blank?
end
# Insertion and select all benchmarking
# Script mostly based from http://refactormycode.com/codes/240-datamapper-threaded-benchmark
# MySQL (InnoDB, No Index)
Rehearsal -------------------------------------------------------------
DataMapper data insertion 1.090000 0.100000 1.190000 ( 1.970768)
DataMapper single-thread 0.020000 0.000000 0.020000 ( 0.019654)
DataMapper threaded 0.020000 0.000000 0.020000 ( 0.017503)
---------------------------------------------------- total: 1.230000sec
Rehearsal ------------------------------------------------------------
DataMapper create 1.750000 0.990000 2.740000 ( 2.938983)
DataMapper single-thread 0.940000 0.050000 0.990000 ( 1.032815)
DataMapper threaded 1.070000 0.050000 1.120000 ( 1.172269)
--------------------------------------------------- total: 4.850000sec
user system total real
DataMapper create 2.660000 1.160000 3.820000 ( 4.045616)
DataMapper single-thread 2.020000 0.060000 2.080000 ( 2.144937)
# Profiling result of inserting 10000 objects into MySQL, SQLITE, Tokyo Cabinet, and Tokyo Cabinet adapter disabling connection to TC iteself.
# Each object is consist of 5 attributes.
# For MySQL and SQLITE, index is set on each attribute.
# For Tokyo Cabinet, Datafile for each attribute is created with reverse ID lookup to a datafile which has id&marshalled object as key&value pair.
# TC disabled
Thread ID: 218880
Total: 67.673687
ActiveRecord::StatementInvalid in SourcesController#refresh
SQLite3::SQLException: PRIMARY KEY must be unique: update object_values set update_type='query',id=pending_id where (update_type='pending' or update_type is null) and source_id=11
RAILS_ROOT: /Users/makoto/work/personal/rhomobile/rhosync
Application Trace | Framework Trace | Full Trace
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite_adapter.rb:372:in `catch_schema_changes'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'
"url"
"/search.json?geocode=37.331689%2C-122.030731%2C25km"
"data class Array"
[#<ObjectValue id: nil, source_id: 13, attrib: "data_length", object: "37.331689,-122.030731", value: "15", update_type: nil, created_at: nil, updated_at: nil, pending_id: nil, user_id: nil>, #<ObjectValue id: nil, source_id: 13, attrib: "data", object: "37.331689,-122.030731", value: [{"text"=>"@eifion excellent service to the rails community! Thank you!", "from_user"=>"gluecode", "to_user"=>"eifion", "to_user_id"=>1717944, "id"=>1251426381, "iso_language_code"=>"en", "from_user_id"=>1058368, "source"=>"&lt;a href=&quot;http://www.atebits.com/software/tweetie/&quot;&gt;Tweetie&lt;/a&gt;", "created_at"=>"Wed, 25 Feb 2009 23:35:51 +0000", "profile_image_url"=>"http://s3.amazonaws.com/twitter_production/profile_images/82311413/avatar_normal.jpg", "location"=>"San Jose, CA (37.405417,-121.9"}, {"text"=>"@clarakim awesomest smell in my entire life..in my garage behind where we make our clothes smell good. :(", "from_user"=>"jacdo",