何时在Cassandra(和CQL)表中使用Blob以及什么是blob?

Pin*_*hio 8 cql cassandra

当我在cassandra中创建表条目时以及blob类型是一个不错的选择时,我试图更好地理解设计决策选择.

我意识到我真的不知道何时选择blob作为数据类型,因为我不确定blob到底是什么(或者缩写代表什么).因此,我决定阅读以下有关数据类型blob的文档:

http://www.datastax.com/documentation/cql/3.0/cql/cql_reference/blob_r.html

斑点

Cassandra 1.2.3 still supports blobs as string constants for input (to allow smoother transition to blob constant). Blobs as strings are
Run Code Online (Sandbox Code Playgroud)

现已弃用,不久将不再受支持.如果您使用字符串作为blob,请更新客户端代码以切换到blob常量.blob常量是由0xX +定义的十六进制数,其中hex是十六进制字符,例如[0-9a-fA-F].例如,0xcafe.

Blob conversion functions

A number of functions convert the native types into binary data (blob). For every <native-type> nonblob type supported by CQL3, the
Run Code Online (Sandbox Code Playgroud)

typeAsBlob函数接受类型为type的参数,并将其作为blob返回.相反,blobAsType函数采用64位blob参数并将其转换为bigint值.例如,bigintAsBlob(3)为0x0000000000000003,blobAsBigint(0x0000000000000003)为3.

我得到的是它只是一个很长的十六进制/二进制.但是,当我将它用作潜在表的列类型以及它如何比其他类型更好或更差时,我并不欣赏.此外,通过一些属性可能是一个很好的方法来弄清楚blob有什么好处.

Rus*_*ssS 6

Blob(Binary Large OBjectS)是您的数据不适合C*提供的标准类型的解决方案.例如,假设您想建立一个允许用户上传任何类型文件的论坛.要将它们存储在C*中,您将使用Blob列(或者可能使用几个blob列,因为您不希望单个单元格变大).

另一个示例可以是允许用户拥有当前照片的表格,该照片可以作为blob添加并与其余用户信息一起存储.