Archive

Archive for June, 2010

BlitzDB is now in Drizzle’s Trunk Repository

June 21st, 2010

Happy to announce that BlitzDB has been merged with Drizzle’s Trunk.

As much as I’m excited, it’s time to come back to reality. This merge is merely a beginning. There is much more work that needs to be done to BlitzDB such as ensuring stability by adding more tests, find bugs, and eliminate them. I’m hoping that the likelihood of bugs being found will increase due to this merge. Admittedly, I want to hack on fancy (yet important) things like auto recovery but I’m going to resist doing this until I’m truly satisfied with the quality of BlitzDB. My plan is to have BlitzDB rock solid by Drizzle’s Beta release.

The review process to get BlitzDB into Drizzle was straight forward and smooth. This is mostly due to the fact that the community was very supportive about testing. Folks like Stewart Smith and Patrick Crews from Rackspace pointed out several bugs that I would not have found myself. I’m certainly lucky to have a supportive professional QA engineer (looking at you Patrick) to test out and give punishment to BlitzDB.

All I’ll be doing on BlitzDB for the next couple of weeks is debugging and refactoring to improve readability. What I need more of at the moment is test cases on JOINs that are likely to be used in practice. If you have a good test case, I would greatly appreciate it!

Toru Maesaka drizzle, oss ,

Better Mobile Internet Life in Japan

June 16th, 2010

b-mobile U300 Having mobile internet connectivity was always something hot among tech geeks. What’s interesting though is that this luxury is gradually becoming a normal day to day lifestyle in urban Japan. Nowadays pretty much every major mobile carrier provides unlimited 3G Data SIM package for a competitive price. Pricing currently ranges between 2000 to 3000 JPY (Google Currency Conversion).

This movement in the mobile market is understandable since most modern lightweight laptops and netbooks sold in Japan has an internal 3G modem, which allows you to gain instant internet connectivity as long as there’s antenna coverage. Sony Vaio is a great example of this use-case. Needless to say, the iPad and Android is a contributing factor to the market shift as well.

The catch with these products is that you’re usually obliged to sign a contract for two years. This wouldn’t be a problem if you’re traveling to Japan and planning to stick around for that long but otherwise this can turn out to cost you unnecessary fees for cancellation.

Traveling to Japan? Read This

I’ve always been a fan of the prepaid model (as long as it’s not overpriced). So, last weekend I bought a 6 month package from b-mobile, which is a service that provides 3G internet connectivity (unlimited packets) for a finite period that you choose. The awesome thing about this service is that you don’t have to sign any contracts or register your personal information to the service provider (Japan Communications). All you need to do is prepay for a certain period and they’ll give you a SIM for it. No questions asked. Another good thing about b-mobile is that it runs on docomo’s FOMA network which is arguably the strongest mobile network in Japan.

For your interest I bought mine at Bic Camera in Shibuya and paid around 14,000 JPY for 6 months (works out to be around 2333 JPY per month). Their sales model is great for us consumers but the first impression I got was that this could be pretty dodgy if this product gets in the hands of folks with malicious intents.

Perfect with Android, Especially Nexus One

I decided to throw my new SIM into my HTC Magic (Dev Phone courtesy of Google) and setup tethering on it (both WiFi and USB Cable). Unfortunately the certain Android 2.1 kernel I was using wasn’t compatible with b-mobile so I had to go through several workarounds and ask my Android guru colleagues for help to get it working. The funny thing is that b-mobile will work out of the box with Nexus One running Froyo.

Despite the obstacles I’m happy with the outcome and I hope this blog entry would turn out to be helpful to those that are planning on traveling and staying in Japan for a while.

Toru Maesaka technology , , ,

Notes on Loading Data to Google App Engine

June 15th, 2010

Google has a fantastic documentation on this topic but at the time I wrote this blog entry, the documentation covered how to download and upload data using appcfg.py but not with bulkloader.py (there is also bulkload_client.py). So, I decided to play around with the nifty bulkloader and keep a note on my findings.

Prepare the End Point for Loading Data

Loading data to the Data Store is accomplished by sending data to the application over HTTP. This means that your application needs a uniquely identifiable URI for you to send your data to. Creating a valid URI is just a matter of setting up a handler for it in the app.yaml config file. GAE takes care of the import logic with it’s own handler. There’s nothing special in this step and the documentation covers how to do this concisely.

Test Data for Demo Purpose

For this blog entry, I decided to prepare a CSV with four rows that represents users. In reality, there would be more information related to a user but I decided to keep things minimal for this blog entry. I saved this data as user.csv.

1, Daniel, Bernstein, xxxxxxx
2, Donald, Knuth, xxxxxxx
3, Bjarne, Stroustrup, xxxxxxx
4, Robert, Sedgewick, xxxxxxx

You can also represent your table in XML but I decided to use CSV for it’s simplicity.

Create a Bulk Loader Configuration File or Not

In addition to the CSV file, the bulk loader needs to know how each record in the CSV file should be represented as a Data Store entity. The modeling as far as I know can be done in two ways. One is to write a loader class in Python that the bulkloader can use. Another approach is to get bulkloader.py to generate a configuration file (in YAML).

I decided to write my own Python class to get through this step since according to the documentation at the time this blog post was written, this approach doesn’t work with the local development server.

With the above in mind, here is my loader class. You would usually keep the Data Model definition (the User class) in a separate file but for demo purposes, I decided to keep it in one file.

from google.appengine.ext import db
from google.appengine.tools import bulkloader
 
class User(db.Model):
  id = db.IntegerProperty()
  firstname = db.StringProperty()
  lastname = db.StringProperty()
  some_text = db.StringProperty()
 
class UserLoader(bulkloader.Loader):
  def __init__(self):
    bulkloader.Loader.__init__(self, 'User',
                               [('id', int),
                                ('firstname', str),
                                ('lastname', str),
                                ('some_text', str)])
loaders = [UserLoader]

The explanation on what this class does is described in the documentation. I saved this script as user_loader.py.

Load your Data to the Data Store

For demo purposes, I used my local development server on port 8083 to load the CSV file. Given that the application is running and that the API endpoint is active, it’s just a matter of providing bulkloader.py with essential information. For available options I recommend reading help by executing ‘bulkloader.py -h’.

The following command attempts to load our entity of ‘kind=User’ from user.csv using our loader class (user_loader.py) to the endpoint.

$ bulkloader.py --filename=user.csv --config_file=user_loader.py \
--kind=User --url=http://localhost:8083/import --app_id=your_app_id

Note that it’s essential to provide the --app_id option when uploading data to the local server. When asked for credentials, you can type anything you like. You only need to supply valid credentials when uploading to production.

Here’s the output from executing the above command.

[INFO    ] Logging to bulkloader-log-20100615.213842
[INFO    ] Throttling transfers:
[INFO    ] Bandwidth: 250000 bytes/second
[INFO    ] HTTP connections: 8/second
[INFO    ] Entities inserted/fetched/modified: 20/second
[INFO    ] Batch Size: 10
[INFO    ] Opening database: bulkloader-progress-20100615.213842.sql3
Please enter login credentials for localhost
Email: foo
Password for foo: 
[INFO    ] Connecting to localhost:8083/import
[INFO    ] Starting import; maximum 10 entities per post
[INFO    ] 4 entites total, 0 previously transferred
[INFO    ] 4 entities (933 bytes) transferred in 4.0 seconds
[INFO    ] All entities successfully transferred

Success!

Toru Maesaka knowledge, technology , ,