title: Hector + Cassandra: Get Column Family List
body: <p>I am trying to get all the column families in the current keyspace I am using because I want to get rid of the error:</p>
  
  <p><code>InvalidRequestException(why:[column family] already exists in keyspace)</code></p>
  
  <p>My logic is to get all the Column Families in the current key space &amp; check whether or not a particular column family appears in the returned list. So, I try:</p>
  
  <p><code>KeyspaceDefinition keyspaceDef = HFactory.createKeyspaceDefinition("test");</code></p>
  
  <p>...</p>
  
  <p><code>List&lt;ColumnFamilyDefinition&gt; lsCf = keyspaceDef.getCfDefs();</code></p>
  
  <p>There seems to be a problem with creating the</p>
  
  <p><code>List&lt;ColumnFamilyDefinition&gt; lsCf = keyspaceDef.getCfDefs();</code></p>
  
  <p>I did a <code>System.out.println(keyspaceDef.getCfDefs())</code> and it returned</p>
  
  <p><code>[]</code> </p>
  
  <p>an empty list - which is what I expected. What I cannot understand is why <code>List&lt;ColumnFamilyDefinition&gt; lsCf = keyspaceDef.getCfDefs();</code> is incorrect. Eclipse disagrees with the "List" portion of this line. Other than that, it appears that he code is right. Can some one please help me understand why this line is wrong or whether my approach is off?</p>
  
  <p>Here's the full code snippet:</p>
  
  <pre><code>package org.cassandra.examples;
  
  import me.prettyprint.cassandra.model.BasicColumnFamilyDefinition;
  import me.prettyprint.cassandra.service.CassandraHostConfigurator;
  import me.prettyprint.cassandra.service.ThriftCfDef;
  import me.prettyprint.cassandra.service.ThriftCluster;
  import me.prettyprint.hector.api.Cluster;
  import me.prettyprint.hector.api.Keyspace;
  import me.prettyprint.hector.api.exceptions.HectorException;
  import me.prettyprint.hector.api.factory.HFactory;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Comparator;
  
  import me.prettyprint.cassandra.serializers.StringSerializer;
  import me.prettyprint.cassandra.service.*;
  import me.prettyprint.cassandra.model.BasicColumnDefinition;
  import me.prettyprint.cassandra.model.BasicColumnFamilyDefinition;
  import me.prettyprint.cassandra.model.thrift.ThriftConverter;
  
  import org.apache.cassandra.db.ColumnFamily;
  import org.apache.cassandra.thrift.Cassandra;
  import me.prettyprint.cassandra.service.ThriftKsDef;
  import me.prettyprint.hector.api.*;
  import me.prettyprint.hector.api.beans.HColumn;
  import me.prettyprint.hector.api.beans.HSuperColumn;
  import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
  import me.prettyprint.hector.api.ddl.ColumnIndexType;
  import me.prettyprint.hector.api.ddl.ComparatorType;
  import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
  import me.prettyprint.hector.api.factory.HFactory;
  import me.prettyprint.hector.api.mutation.Mutator;
  import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate;
  import me.prettyprint.cassandra.service.template.ColumnFamilyUpdater;
  import me.prettyprint.cassandra.service.template.ThriftColumnFamilyTemplate;
  import me.prettyprint.hector.api.mutation.Mutator;
  import me.prettyprint.hector.api.query.ColumnQuery;
  import me.prettyprint.hector.api.query.QueryResult;
  import me.prettyprint.hector.api.query.SuperColumnQuery;
  
  public class HectorTest {
      private static String keyspaceName = "test3";
      private static KeyspaceDefinition newKeyspaceDef;
      private static Cluster cluster;
      private static Keyspace ksp;
  
      public static void main(String[] args) {
  
          cluster = HFactory.getOrCreateCluster("test cluster", "xxx.xxx.x.xx:9160");
          newKeyspaceDef = HFactory.createKeyspaceDefinition(keyspaceName);
          ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition("MyKeyspace",                              
                  "ColumnFamilyName", 
                  ComparatorType.BYTESTYPE);
          List&lt;ColumnFamilyDefinition&gt; lCf = newKeyspaceDef.getCfDefs(); //= new ArrayList&lt;ColumnFamilyDefinition&gt;();
          if((cluster.describeKeyspace(keyspaceName)) == null){
              createSchema();
          }
  
          ksp = HFactory.createKeyspace(keyspaceName, cluster);
          //Articles art = new Articles(cluster, newKeyspaceDef);
          //cluster.dropColumnFamily(keyspaceName, "Articles");
  
  
      }
  
      public static void createSchema(){
          cluster.addKeyspace(newKeyspaceDef,true);
      }
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
      List cannot be resolved to a type
  
      at org.cassandra.examples.HectorTest.main(HectorTest.java:55)
  </code></pre>