我有一个问题,如果我们尝试将相同的数据插入 cassandra 数据库会怎样。这里的“相同”是指 cassandra 数据库中已经存在一组 100 行,例如在测试列族中。如果我们再次尝试将相同的 100 行插入 cassandra 数据库,即具有相同 rowkey 的行,它会再次插入吗?。
创建密钥空间并使用 CQL 但收到错误
CREATE KEYSPACE demodb
WITH strategy_class = 'org.apache.cassandra.locator.SimpleStrategy'
... AND strategy_options:replication_factor='1';
cqlsh:demodb> CREATE TABLE users (
... user_name varchar,
... password varchar,
... gender varchar,
... session_token varchar,
... state varchar,
... birth_year bigint,
... PRIMARY KEY (user_name)
... );
Bad Request: line 1:163 mismatched input ')' expecting EOF
Run Code Online (Sandbox Code Playgroud)
为什么我收到这个错误,任何帮助,谢谢。
我使用datastax java驱动程序构造一个select查询.我使用限制选项设置限制.但我看到另一个属性也可以设置
setFetchSize(int size)
DEFAULT_FETCH_SIZE- 5000根据文档.
这是否意味着如果我连续有大约10000列,如果我有一个限制为3的查询运行,它将始终获取指定的默认值 - 5000行,然后限制最后3行?
我认为限制查询默认情况下在默认情况下单独获取最后3个值.有人可以澄清一下吗?
我正在使用datastax cassandra 2.1驱动程序并以~8000 IOPS的速率执行读/写操作.我已经使用池选项来配置我的会话,并使用单独的会话进行读取和写入,每个会话都连接到群集中的另一个节点作为联系点.这样可以正常工作5分钟,但之后我得到了很多例外,例如:
失败:com.datastax.driver.core.exceptions.NoHostAvailableException:所有尝试查询的主机都失败了(尝试:/10.0.1.123:9042(com.datastax.driver.core.TransportException:[/10.0.1.123: 9042]连接已关闭),/ 10.0.1.56:9042(com.datastax.driver.core.exceptions.DriverException:尝试获取可用连接时超时(您可能希望增加每个主机连接的驱动程序数)) )
任何人都可以帮我解决可能出现的问题吗?
异常要求我增加每个主机的连接数,但是我可以为此参数设置多高的值?此外,我无法设置CoreConnectionsPerHost超过2,因为它抛出异常,说2是最大值.
这就是我创建每个读/写会话的方式.
PoolingOptions poolingOpts = new PoolingOptions();
poolingOpts.setCoreConnectionsPerHost(HostDistance.REMOTE, 2);
poolingOpts.setMaxConnectionsPerHost(HostDistance.REMOTE, 200);
poolingOpts.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, 128);
poolingOpts.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, 2);
cluster = Cluster
.builder()
.withPoolingOptions( poolingOpts )
.addContactPoint(ip)
.withRetryPolicy( DowngradingConsistencyRetryPolicy.INSTANCE )
.withReconnectionPolicy( new ConstantReconnectionPolicy( 100L ) ).build();
Session s = cluster.connect(keySpace);
Run Code Online (Sandbox Code Playgroud) 我有一张如下表:
CREATE TABLE tab(
categoryid text,
id text,
name text,
author text,
desc text,
PRIMARY KEY (categoryid , id)
) WITH CLUSTERING ORDER BY (id ASC);
CREATE INDEX ON tab (name);
CREATE INDEX ON tab (author);
Run Code Online (Sandbox Code Playgroud)
当我执行以下查询时:
select * from tab ALLOW FILTERING; ---1
select * from tab where id = 'id01' ALLOW FILTERING; ---2
select * from tab where categoryid = 'cid01' ALLOW FILTERING; ---3
Run Code Online (Sandbox Code Playgroud)
三个查询的后端发生了什么?
是否会完全忽略id和categoryid上的关键索引.
感谢回复.谢谢
我将我的列族gcgraceseconds设置为0; 但是仍然没有删除rowkey,它仍留在我的列族中
create column family workInfo123
with column_type = 'Standard'
and comparator = 'UTF8Type'
and default_validation_class = 'UTF8Type'
and key_validation_class = 'UTF8Type'
and read_repair_chance = 0.1
and dclocal_read_repair_chance = 0.0
and populate_io_cache_on_flush = true
and gc_grace = 0
and min_compaction_threshold = 4
and max_compaction_threshold = 32
and replicate_on_write = true
and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
and caching = 'KEYS_ONLY'
and default_time_to_live = 0
and speculative_retry = 'NONE'
and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.LZ4Compressor'}
and index_interval = 128;
Run Code Online (Sandbox Code Playgroud)
见下面的观点
[default@winoriatest] list workInfo123; …Run Code Online (Sandbox Code Playgroud) 我将使用以下Cassandra模型:-
class Automobile(Model):
manufacturer = columns.Text(primary_key=True)
year = columns.Integer(index=True)
model = columns.Text(index=True)
price = columns.Decimal(index=True)
Run Code Online (Sandbox Code Playgroud)
我需要以下查询:
q = Automobile.objects.filter(manufacturer='Tesla')
q = Automobile.objects.filter(year='something')
q = Automobile.objects.filter(model='something')
q = Automobile.objects.filter(price='something')
Run Code Online (Sandbox Code Playgroud)
这些都工作正常,直到我想要多列过滤,即当我尝试
q = Automobile.objects.filter(manufacturer='Tesla',year='2013')
Run Code Online (Sandbox Code Playgroud)
它抛出一个错误说 Cannot execute this query as it might involve data filtering and thus may have unpredictable performance.
我用重写了查询 allowed_filtering,但这不是最佳解决方案。
然后,在阅读更多内容后,我对模型进行了如下编辑:
class Automobile(Model):
manufacturer = columns.Text(primary_key=True)
year = columns.Integer(primary_key=True)
model = columns.Text(primary_key=True)
price = columns.Decimal()
Run Code Online (Sandbox Code Playgroud)
有了这个,我也能够过滤多个库仑,而无需任何警告。
当我这样做时DESCRIBE TABLE automobile,它表明这将创建复合键PRIMARY KEY ((manufacturer), year, model)。
所以,我的问题是,如果我将每个属性都声明为主键,该怎么办? …
我试图理解为什么我以两种方式看到不同的数据来显示Cassandra(1.2.x)列族列.
在第一个,我使用cassandra-cli到list该行一列的家庭.
[cassandra-cli]> list Users columns 1;
Using default limit of 100
-------------------
RowKey: [rowkey1]
=> (name=[name1], value=[value1], timestamp=[timestamp1])
Run Code Online (Sandbox Code Playgroud)
两者之间的数据[]是值的占位符.实际上,它们显示为a的十六进制表示byte[].上面似乎表明有一行有一个列(有一个名称,一个值和一个时间戳).
我正在做我认为与DataStax v1 API等效的东西
var cluster = Cluster.Builder ()
.AddContactPoint ("127.0.0.1")
.Build ();
var metadata = cluster.Metadata;
var keyspace = "keyspaceName";
var tableMetadatas = metadata.GetTables(keyspace);
foreach (var tableMetadata in tableMetadatas) {
var session = cluster.Connect(keyspace);
var rowSet = session.Execute("SELECT * FROM \""+ tableMetadata + "\" ", ConsistencyLevel.One);
CqlColumn[] columns = rowSet.Columns;
foreach(var column …Run Code Online (Sandbox Code Playgroud) 我在Cassandra有一个表,我用1000个条目填充一些行(每行有10000+列).行中的条目经常更新,基本上只是一个字段(它是一个整数)用不同的值更新.列的所有其他值保持不变.我的问题是,更新是否会就地完成?Cassandra频繁更新参赛作品有多好?