FluentCassandra范围选择问题

发布于 2024-10-22 03:07:22 字数 786 浏览 1 评论 0原文

我在使用 c# 和 FluentCassandra 从 Cassandra 获取一些数据时遇到问题。 在我的 Cassandra 键空间中,我有以下超级列族定义:

<ColumnFamily Name="MySCFName"
                    ColumnType="Super"
                    CompareWith="TimeUUIDType"

                CompareSubcolumnsWith="AsciiType"/>

我想要做的是对此超级列族运行查询,类似于 sql 中的以下内容:

select "something" from MyTable where "timestamp" between "2011-01-01 00:00:00.000" and "2011-03-01 00:00:00.000"

按照一个教程,我发现我可以使用以下命令从 Cassandra 中获取一些数据:

family.Get("238028210009775").Fetch(DateTime.Parse("2011-01-01 00:00:00.000")).FirstOrDefault();

但这在 sql "timestamp" > 中是等效的“2011-01-01 00:00:00.000”

到目前为止,我无法弄清楚如何从一系列值中检索数据。

任何提示或帮助将不胜感激:) 提前致谢, 尼古拉

I have a problem in getting some data out from Cassandra using c# and FluentCassandra.
In my Cassandra keyspace i have the following super column family definition:

<ColumnFamily Name="MySCFName"
                    ColumnType="Super"
                    CompareWith="TimeUUIDType"

                CompareSubcolumnsWith="AsciiType"/>

What i would like to do is run a query on this supercolumnfamily similar to the following in sql:

select "something" from MyTable where "timestamp" between "2011-01-01 00:00:00.000" and "2011-03-01 00:00:00.000"

Following one tutorial i found i can get some data out of Cassandra with the following command:

family.Get("238028210009775").Fetch(DateTime.Parse("2011-01-01 00:00:00.000")).FirstOrDefault();

but this is equivalent in sql "timestamp" > "2011-01-01 00:00:00.000"

and so far i cannot figure out how to retrieve data from a range of values.

Any hints or help will be appreciated :)
Thanks in advance,
Nicola

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2024-10-29 03:07:22

您应该能够通过以下操作来完成此操作:

using (var db = new CassandraContext(keyspace: "keyspace_name", host: "localhost"))
{
    var fromDate = DateTime.Now.Subtract(new TimeSpan(0, 30, 0));
    var toDate = DateTime.Now;
    var family = db.GetColumnFamily<TimeUUIDType, AsciiType>("family_name");
    var results = family.Get("row_key")
                        .Fetch(fromDate)
                        .TakeUntil(toDate)
                        .FirstOrDefault();
}

You should be able to do it with the following:

using (var db = new CassandraContext(keyspace: "keyspace_name", host: "localhost"))
{
    var fromDate = DateTime.Now.Subtract(new TimeSpan(0, 30, 0));
    var toDate = DateTime.Now;
    var family = db.GetColumnFamily<TimeUUIDType, AsciiType>("family_name");
    var results = family.Get("row_key")
                        .Fetch(fromDate)
                        .TakeUntil(toDate)
                        .FirstOrDefault();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文