首页 \ 问答 \ Cassandra(Pycassa / CQL)返回部分匹配(Cassandra (Pycassa/CQL) Return Partial Match)

Cassandra(Pycassa / CQL)返回部分匹配(Cassandra (Pycassa/CQL) Return Partial Match)

我正在尝试通过Cassandra中的列族进行部分搜索,类似于SQL查询,例如:SELECT * FROM columnfamily WHERE col ='val *'其中val *表示至少匹配前三个字符'val'的任何值。

我已阅读有关SELECT函数的datastax文档 ,但似乎无法找到对部分WHERE条件的任何支持。 有任何想法吗?


I'm trying to do a partial search through a column family in Cassandra similar to an SQL query like: SELECT * FROM columnfamily WHERE col = 'val*' where val* means any value matching at least the first three characters 'val'.

I've read datastax's documentation on the SELECT function, but can't seem to find any support for the partial WHERE criteria. Any ideas?


原文:https://stackoverflow.com/questions/10048506
更新时间:2023-10-26 12:10

最满意答案

如果您只是想解决问题,可以使用struct来封装数组:

$ cat struct.c ; make CFLAGS=-Wall -Wextra struct ; ./struct
#include <stdio.h>

#define NX 2
#define NY 3

typedef struct fixed {
    float arr[NX][NY];
} fixed_t;

void array_printer( const fixed_t f)
{
    int i, j;
    for (i = 0; i < NX; i++ )
        for( j=0; j < NY; j++ )
            printf("Element [%d,%d]=%f\n", i,j, f.arr[i][j] );
}


int main(int argc, char *argv[]) {
    fixed_t f = {.arr={ {1,2,3}, {4,5,6} }};
    array_printer(f);
    return 0;
}

cc -Wall    struct.c   -o struct
Element [0,0]=1.000000
Element [0,1]=2.000000
Element [0,2]=3.000000
Element [1,0]=4.000000
Element [1,1]=5.000000
Element [1,2]=6.000000

没有警告,没有错误,只是稍微f.arr[][]一点(例如)在array_printer使用( f.arr[][]而不是arr[][]

如果修改struct fixedstruct fixed以包含NXNY维度,则程序中甚至可以有多个不同大小的对象。 (虽然你稍微失去了编译时已知边界的好处,但我不确定你真正购买了多少。)


If you just want the problem solved, you can use a struct to encapsulate your array:

$ cat struct.c ; make CFLAGS=-Wall -Wextra struct ; ./struct
#include <stdio.h>

#define NX 2
#define NY 3

typedef struct fixed {
    float arr[NX][NY];
} fixed_t;

void array_printer( const fixed_t f)
{
    int i, j;
    for (i = 0; i < NX; i++ )
        for( j=0; j < NY; j++ )
            printf("Element [%d,%d]=%f\n", i,j, f.arr[i][j] );
}


int main(int argc, char *argv[]) {
    fixed_t f = {.arr={ {1,2,3}, {4,5,6} }};
    array_printer(f);
    return 0;
}

cc -Wall    struct.c   -o struct
Element [0,0]=1.000000
Element [0,1]=2.000000
Element [0,2]=3.000000
Element [1,0]=4.000000
Element [1,1]=5.000000
Element [1,2]=6.000000

No warnings, no errors, and only slightly more annoying to use (f.arr[][] rather than arr[][] in the array_printer, for example).

If you amend the struct fixed to include the NX and NY dimensions, you could even have multiple different-sized objects in your program. (Though you'd slightly lose the benefits of compile-time-known bounds, I'm not sure how much that really buys you.)

相关问答

更多
  • typedef将是 typedef char type24[3]; 但是,这可能是一个非常糟糕的主意,因为结果类型是一个数组类型,但它的用户不会看到它是一个数组类型。 如果用作函数参数,它将通过引用传递,而不是通过值传递,因此sizeof将被错误。 一个更好的解决方案是 typedef struct type24 { char x[3]; } type24; 您可能还希望使用unsigned char而不是char ,因为后者具有实现定义的签名。 The typedef would be typedef ...
  • 肇事者:rand()%1000有时评估为0。 vec1[x][y] = (float)(1+rand()%(1+rand()%1000)); vec2[x][y] = (float)(1+rand()%(1+rand()%1000)); 改成: vec1[x][y] = (float)(1+rand()%(1+rand()%1000)); vec2[x][y] = (float)(1+rand()%(1+rand()%1000)); The culprits: rand()%1000 evaluated ...
  • 问题是1:5是integer类型。 您必须将其转换为numeric才能将其作为double量传入: library(OpenCL) p = oclPlatforms() d = oclDevices(p[[1]]) code = c(" #pragma OPENCL EXTENSION cl_khr_fp64 : enable __kernel void countit( __global double* output, const unsigned int count, ...
  • 没有办法传递不同大小的数组,因为数组的长度是类型的一部分。 例如[3]int是一个不同的类型,然后是[2]int 。 在Go中,建议不要使用应该使用切片的数组( https://golang.org/doc/effective_go.html#arrays )。 No there is no way to pass different size arrays, because the length of an array is part of the type. For example [3]int is ...
  • 除了设置正确的VPWIDTH和VPHEIGHT output[i*w*j] = pixel; 必须改变为output[i*w+j] = pixel; 在C代码中。 Besides setting the right VPWIDTH and VPHEIGHT output[i*w*j] = pixel; had to be changed to output[i*w+j] = pixel; in C code.
  • names应声明为: char (*names)[80]; 这将names声明为指向80个字符数组的指针。 顺便说一句,没有必要在C中malloc的返回值,很多人认为这是不好的做法。 见: 1,2 。 names should be declared as: char (*names)[80]; This declares names as a pointer to an array of 80 chars. By the way, there's no need to cast the return ...
  • 如果您只是想解决问题,可以使用struct来封装数组: $ cat struct.c ; make CFLAGS=-Wall -Wextra struct ; ./struct #include #define NX 2 #define NY 3 typedef struct fixed { float arr[NX][NY]; } fixed_t; void array_printer( const fixed_t f) { int i, j; for ( ...
  • 您正在定义大小为8的cl_uint数组.cl_mem的创建和内核参数的设置是正确的。 但是您的内核参数不正确:您尝试读取cl_uint8而不是cl_uint的数组。 如果要使用向量数据类型,则必须声明:大小为1的cl_uint8 dataArr。或者如果要使用大小为8的数组: kernel void kernelFunction(constant uint *vectorPtr, uint size): 编辑: cl_uint8 dataVector的内核参数不是指针。 所以,正确的代码是: cl_uint ...
  • 你不应该使用systypes或syscolumns--它们是向后兼容的视图,并且sys.types和sys.columns是非常受欢迎的,除非你试图编写在SQL Server 2000+上工作的代码(我不建议这么做) 。 要获取关于类型的信息,您已经知道以下名称: SELECT name, precision, scale, max_length FROM sys.types AS t WHERE name = 'bVendor'; 要获取数据库中所有用户定义类型的信息,请执行以下操作: SELE ...
  • 你在使用OpenCL 1.0吗? 这不允许默认写入char *。 1.0仅支持写入int。 您需要1.1或扩展名http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/cl_khr_byte_addressable_store.html 你可以尝试添加 #pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable 在你的内核开始。 Are you using OpenCL 1.0? ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)