Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/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
C# 从Cassandra到C的最快方式是什么?_C#_Cassandra_Cql_Cql3_Datastax - Fatal编程技术网

C# 从Cassandra到C的最快方式是什么?

C# 从Cassandra到C的最快方式是什么?,c#,cassandra,cql,cql3,datastax,C#,Cassandra,Cql,Cql3,Datastax,从Cassandra到C,加载一行或几行最高效的方法是什么?我的宽行有10.000-100.000列。主键由多个值组成,但列键是单个字符串,列值是单个计数器。请参见下面的模式 在cqlsh中使用跟踪,我可以看到Cassandra可以选择一个宽行,44 m中有17.000列,但是使用Datastax驱动程序将这些数据一路加载到C中需要700 ms。有没有更快的方法?我需要在50-100毫秒内加载整个宽行。还有更地道的方式吗?一种最小化网络流量的方法?更快的司机?驱动程序的另一种配置?还是别的什么

从Cassandra到C,加载一行或几行最高效的方法是什么?我的宽行有10.000-100.000列。主键由多个值组成,但列键是单个字符串,列值是单个计数器。请参见下面的模式

在cqlsh中使用跟踪,我可以看到Cassandra可以选择一个宽行,44 m中有17.000列,但是使用Datastax驱动程序将这些数据一路加载到C中需要700 ms。有没有更快的方法?我需要在50-100毫秒内加载整个宽行。还有更地道的方式吗?一种最小化网络流量的方法?更快的司机?驱动程序的另一种配置?还是别的什么

实际上,我并不需要所有17000列。我只需要'support'>=2的列或按'support'降序排列的前1000列。但由于“support”是我的列值,我不知道在CQL中有什么方法可以这样查询

这是我的桌子:

CREATE TABLE real_time.grouped_feature_support (
    algorithm_id int,
    group_by_feature_id int,
    select_feature_id int,
    group_by_feature_value text,
    select_feature_value text,
    support counter,
    PRIMARY KEY ((algorithm_id, group_by_feature_id, select_feature_id, group_by_feature_value), select_feature_value)
这是我使用Datastax驱动程序访问数据的方法:

var table = session.GetTable<GroupedFeatureSupportDataEntry>();
var query = table.Where(x => x.CustomerAlgorithmId == customerAlgorithmId
    && x.GroupByFeatureId == groupedFeatureId
    && myGroupedFeatureValues.Contains(x.GroupByFeatureValue)
    && x.GroupByFeatureValue == groupedFeatureValue
    && x.SelectFeatureId == selectFeatureId)
    .Select(x => new
    {
        x.GroupByFeatureValue,
        x.SelectFeatureValue,
        x.Support,
    })
    .Take(1000000);
var result = query.Execute();

如果在检索大型结果集时希望获得最佳性能,则不应使用Linq到cql或任何其他映射组件

您可以使用检索行,在您的情况下,它类似于:

var query = "SELECT * from grouped_feature_support WHERE" + 
            " algorithm_id = ? AND group_by_feature_id = ? " +
            " AND select_feature_id = ? AND group_by_feature_value = ?";
//Prepare the query once in your application lifetime
var ps = session.Prepare(query);
//Reuse the prepared statement by binding different parameters to it
var rs = session.Execute(ps.Bind(parameters));
foreach (var row in rs)
{
  //The enumerator will yield all the rows from Cassandra
  //Retrieving them in the back in blocks of 5000 (determined by the pagesize).
}
//You can also use a IEnumerable<T> Linq Extensions to filter
var filteredRows = rs.Where(r => r.GetValue<long>("support") > 2);

是否可以通过将support>=2要求移动到集群来最小化网络负载,或者引入order by support desc并占据集群的顶部?否,Cassandra不可能按照您希望的方式进行服务器端筛选,至少在C*3.0之前是不可能的