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
最满意答案
如果您只是想解决问题,可以使用
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 fixed
的struct fixed
以包含NX
和NY
维度,则程序中甚至可以有多个不同大小的对象。 (虽然你稍微失去了编译时已知边界的好处,但我不确定你真正购买了多少。)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 thanarr[][]
in thearray_printer
, for example).If you amend the
struct fixed
to include theNX
andNY
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 fixed length array)[2023-08-18]
typedef将是 typedef char type24[3]; 但是,这可能是一个非常糟糕的主意,因为结果类型是一个数组类型,但它的用户不会看到它是一个数组类型。 如果用作函数参数,它将通过引用传递,而不是通过值传递,因此sizeof将被错误。 一个更好的解决方案是 typedef struct type24 { char x[3]; } type24; 您可能还希望使用unsigned char而不是char ,因为后者具有实现定义的签名。 The typedef would be typedef ... -
OpenCL 2D数组实现(OpenCL 2D Array Implementation)[2022-08-19]
肇事者: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:奇怪的内核行为(OpenCL: weird kernel behavior)[2023-01-30]
你在使用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? ...