浏览代码

Some inline code comments for beginners

The program panics when the keyspace or table was not available. The querying
part failed when an index was not prebuilt.

These information may be common knowledge for Cassandra experts. But I was a
beginner who was considering cassandra and gocql over sqlite and had to spend
time finding these pre-requisite cql instructions myself. Since it is the basic
example, Documenting these CQL queries will help beginners.
Sankar சங்கர் 11 年之前
父节点
当前提交
dc2da1c707
共有 2 个文件被更改,包括 9 次插入1 次删除
  1. 1 0
      AUTHORS
  2. 8 1
      README.md

+ 1 - 0
AUTHORS

@@ -28,3 +28,4 @@ Ben Frye <benfrye@gmail.com>
 Fred McCann <fred@sharpnoodles.com>
 Dan Simmons <dan@simmons.io>
 Muir Manders <muir@retailnext.net>
+Sankar P <sankar.curiosity@gmail.com>

+ 8 - 1
README.md

@@ -86,6 +86,11 @@ Example
 -------
 
 ```go
+/* Before you execute the program, Launch `cqlsh` and execute:
+create keyspace example with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
+create table example.tweet(timeline text, id UUID, text text, PRIMARY KEY(id));
+create index on example.tweet(timeline);
+*/
 package main
 
 import (
@@ -112,7 +117,9 @@ func main() {
 	var id gocql.UUID
 	var text string
 
-	// select a single tweet
+	/* Search for a specific set of records whose 'timeline' column matches
+	 * the value 'me'. The secondary index that we created earlier will be
+	 * used for optimizing the search */
 	if err := session.Query(`SELECT id, text FROM tweet WHERE timeline = ? LIMIT 1`,
 		"me").Consistency(gocql.One).Scan(&id, &text); err != nil {
 		log.Fatal(err)