Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 赫克托+;Cassandra:获取列族列表_List_Cassandra_Hector - Fatal编程技术网

List 赫克托+;Cassandra:获取列族列表

List 赫克托+;Cassandra:获取列族列表,list,cassandra,hector,List,Cassandra,Hector,我试图获取当前使用的键空间中的所有列族,因为我希望消除以下错误: InvalidRequestException(为什么键空间中已经存在:[列族]) 我的逻辑是获取当前键空间中的所有列族&检查返回的列表中是否显示特定的列族。因此,我尝试: KeyspaceDefinition keyspaceDef=HFactory.createKeyspaceDefinition(“测试”) List lsCf=keyspaceDef.getCfDefs() 似乎在创建 List lsCf=keyspace

我试图获取当前使用的键空间中的所有列族,因为我希望消除以下错误:

InvalidRequestException(为什么键空间中已经存在:[列族])

我的逻辑是获取当前键空间中的所有列族&检查返回的列表中是否显示特定的列族。因此,我尝试:

KeyspaceDefinition keyspaceDef=HFactory.createKeyspaceDefinition(“测试”)

List lsCf=keyspaceDef.getCfDefs()

似乎在创建

List lsCf=keyspaceDef.getCfDefs()

我做了一个
System.out.println(keyspaceDef.getCfDefs())
,它返回了

[]

一个空的列表——这正是我所期望的。我不明白的是为什么
List lsCf=keyspaceDef.getCfDefs()不正确。Eclipse不同意此行的“列表”部分。除此之外,他的代码似乎是正确的。有人能帮我理解为什么这条线是错误的,或者我的方法是错误的吗

以下是完整的代码片段:

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<ColumnFamilyDefinition> lCf = newKeyspaceDef.getCfDefs(); //= new ArrayList<ColumnFamilyDefinition>();
        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);
    }
}


给你进口。在eclipse中,CTRL-SHIFT-O将为您组织导入,并添加任何缺少的内容。

您能否发布完整的代码示例和/或编译器错误,我怀疑这是一种愚蠢的行为,就像意外导入javax.swing.List而不是java.util.Listok修改了原始问题以包含代码和错误
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)
import java.util.List;