title: commitLog and SSTables in Cassandra database
body: <p>I recently started working with Cassandra database. I have installed <code>single node cluster</code> in my local box. And I am working with <code>Cassandra 1.2.3</code>.</p>
  
  <p>I was reading the article on the internet and I found this line-</p>
  
  <blockquote>
    <p>Cassandra writes are first written to a commit log (for durability),
    and then to an in-memory table structure called a memtable. A write is
    successful once it is written to the commit log and memory, so there
    is very minimal disk I/O at the time of write. Writes are batched in
    memory and periodically written to disk to a persistent table
    structure called an SSTable (sorted string table).</p>
  </blockquote>
  
  <p>So to understand the above lines, I wrote a simple program that will write to Cassandra Database using <code>Pelops client</code>. And I was able to insert the data in Cassandra database. </p>
  
  <p>And now I am trying to see how my data was written into <code>commit log</code> and where that <code>commit log file</code> is? And also how <code>SSTables</code> is generated and where I can find that as well in my local box and what it contains also. </p>
  
  <p>I wanted to see these two files so that I can understand more how Cassandra works behind the scenes.</p>
  
  <p>In my cassandra.yaml file, I have something like this</p>
  
  <pre><code># directories where Cassandra should store data on disk.
  data_file_directories:
      - S:\Apache Cassandra\apache-cassandra-1.2.3\storage\data
  
  # commit log
  commitlog_directory: S:\Apache Cassandra\apache-cassandra-1.2.3\storage\commitlog
  
  # saved caches
  saved_caches_directory: S:\Apache Cassandra\apache-cassandra-1.2.3\storage\savedcaches
  </code></pre>
  
  <p>But when I opened commitLog, first of all it has lot of data so my notepad++ is not able to open it properly and if it gets opened, I cannot see properly because of some encoding or what. And in my data folder, I cannot find out anything?</p>
  
  <p>Meaning this folder is empty for me-</p>
  
  <pre><code>S:\Apache Cassandra\apache-cassandra-1.2.3\storage\data\my_keyspace\users
  </code></pre>
  
  <p>Is there anything I am missing here? Can anybody explain me how to read commitLog and SSTables files and where I can find these two files? And also what exactly happens behind the scenes whenever I am writing to Cassandra database.</p>
  
  <p><strong>Updated:-</strong></p>
  
  <p>Code I am using to insert into Cassandra Database-</p>
  
  <pre><code>public class MyPelops {
  
      private static final Logger log = Logger.getLogger(MyPelops.class);
  
      public static void main(String[] args) throws Exception {
  
  
          // -------------------------------------------------------------
          // -- Nodes, Pool, Keyspace, Column Family ---------------------
          // -------------------------------------------------------------
  
          // A comma separated List of Nodes
          String NODES = "localhost";
  
          // Thrift Connection Pool
          String THRIFT_CONNECTION_POOL = "Test Cluster";
  
          // Keyspace
          String KEYSPACE = "my_keyspace";
  
          // Column Family
          String COLUMN_FAMILY = "users";
  
          // -------------------------------------------------------------
          // -- Cluster --------------------------------------------------
          // -------------------------------------------------------------
  
          Cluster cluster = new Cluster(NODES, 9160);
  
          Pelops.addPool(THRIFT_CONNECTION_POOL, cluster, KEYSPACE);
  
          // -------------------------------------------------------------
          // -- Mutator --------------------------------------------------
          // -------------------------------------------------------------
  
          Mutator mutator = Pelops.createMutator(THRIFT_CONNECTION_POOL);
  
          log.info("- Write Column -");
  
          mutator.writeColumn(
                  COLUMN_FAMILY,
                  "Row1",
                  new Column().setName(" Name ".getBytes()).setValue(" Test One ".getBytes()).setTimestamp(new Date().getTime()));
  
          mutator.writeColumn(
                  COLUMN_FAMILY,
                  "Row1",
                  new Column().setName(" Work ".getBytes()).setValue(" Engineer ".getBytes()).setTimestamp(new Date().getTime()));
  
          log.info("- Execute -");
          mutator.execute(ConsistencyLevel.ONE);
  
          // -------------------------------------------------------------
          // -- Selector -------------------------------------------------
          // -------------------------------------------------------------
  
          Selector selector = Pelops.createSelector(THRIFT_CONNECTION_POOL);
  
          int columnCount = selector.getColumnCount(COLUMN_FAMILY, "Row1",
                  ConsistencyLevel.ONE);
          System.out.println("- Column Count = " + columnCount);
  
          List&lt;Column&gt; columnList = selector
                  .getColumnsFromRow(COLUMN_FAMILY, "Row1",
                          Selector.newColumnsPredicateAll(true, 10),
                          ConsistencyLevel.ONE);
          System.out.println("- Size of Column List = " + columnList.size());
  
          for (Column column : columnList) {
              System.out.println("- Column: (" + new String(column.getName()) + ","
                      + new String(column.getValue()) + ")");
          }
  
          System.out.println("- All Done. Exit -");
          System.exit(0);
      }
  
  }
  </code></pre>
  
  <p>Keyspace and Column family that I have created-</p>
  
  <pre><code>create keyspace my_keyspace with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' and strategy_options = {replication_factor:1};
  use my_keyspace;
  create column family users with column_type = 'Standard' and comparator = 'UTF8Type';
  </code></pre>