Comments (3)
You found a type casting bug. The current work around would be do add the following to your code. So instead of having in your GetData
method:
return productFamily.Get(keys).FetchColumns(columns).FirstOrDefault().AsDynamic();
You would do this to force the right casting.
var keys = new[] { key };
return productFamily.Get(keys).FetchColumns(columns).FirstOrDefault().AsDynamic();
The current problem is the CompositeType was set to implicitly cast to "CassandraObject[]" and that is the type being used in the Get(...)
signature, which is suppose to take in multiple keys. Let me know if the above works for you. This bug will be fixed next release.
from fluentcassandra.
I have been playing a bit more with fluentcassandra especially focusing on composite keys.
And I had another issue.
Here is the Column Family I use:
===================================================
ColumnFamily: Data
Key Validation Class: org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.AsciiType,org.apache.cassandra.db.marshal.AsciiType,org.apache.cassandra.db.marshal.TimeUUIDType)
Default column value validator: org.apache.cassandra.db.marshal.BytesType
Columns sorted by: org.apache.cassandra.db.marshal.AsciiType
GC grace seconds: 864000
Compaction min/max thresholds: 4/32
Read repair chance: 0.1
DC Local Read repair chance: 0.0
Replicate on write: true
Caching: KEYS_ONLY
Bloom Filter FP chance: default
Built indexes: []
Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
Compression Options:
sstable_compression: org.apache.cassandra.io.compress.SnappyCompressor
===================================================
I now am testing a CF with a Composite Key of Type <AsciiType, AsciiType, TimeUUIDType>,
I use the code below to insert data, and it seems to work:
public void InsertData(string keyspace, Data data, DateTimeOffset stamp)
{
using (var db = new CassandraContext(keyspace: keyspace, server: _server))
{
var productFamily = db.GetColumnFamily("Data");
var key = new CompositeType<AsciiType, AsciiType, TimeUUIDType>(data.Key1, data.Key2, stamp);
var post = productFamily.CreateRecord(key);
db.Attach(post);
foreach (var fieldValue in data.Values)
{
if (!post.TrySetColumn(fieldValue.Key, fieldValue.Value))
throw new InvalidDataException(string.Format("Can't add {0}:{1}", fieldValue.Key,
fieldValue.Value));
}
db.SaveChanges();
}
}
And to retrieve the data I use:
public dynamic GetData(string keyspace, string source, string product, DateTimeOffset stamp, params CassandraObject[] columns)
{
var key = new CompositeType<AsciiType, AsciiType, TimeUUIDType>(source, product, stamp);
using (var db = new CassandraContext(keyspace: keyspace, server: _server))
{
var productFamily = db.GetColumnFamily("Data");
var keys = new [] {key};
return productFamily.Get(keys).FetchColumns(columns).FirstOrDefault().AsDynamic();
}
}
Of course in the 2 cases I use the same DateTimeOffset object, but the data returned is only composed of NullTypes.
Tell me if you need more details.
Thanks,
Pierre
from fluentcassandra.
Hi Pierre,
This is related to the fact that you are using TimeUUID. The clock sequence of TimeUUID changes with each request, and since Cassandra doesn't do a valid TimeUUID comparison and just does a byte comparison on Composite types, the value of TimeUUID changes each time you create it which changes the Composite byte value.
To fix this since it seems like you only need a date and not a TimeUUID, you can change the 3rd Composite type to a DateType instead of a TimeUUIDType and this should solve your problems.
Nick
from fluentcassandra.
Related Issues (20)
- FluentCassandra Thrift transport throws exception after idling due to Cassandra connection closed HOT 16
- Exception at insertion of an item with PRIMARY KEY of type BLOB HOT 8
- Composite columns HOT 4
- Direct Contributors Nomination HOT 2
- Is this fix the right thing to do? fix for issue #75: making sure null columns gets a proper default value HOT 6
- Error message reverses column family and keyspace in response
- High CPU utilization when reading with FluentCassandra HOT 1
- Memory leaking when working with large super columns
- Support for Blob Constant HOT 3
- exception should be thrown when cassandra is down HOT 2
- thrift client throws failed: unknown result or Bad protocol identifier HOT 3
- Switching build system to Albacore / Rake HOT 1
- Push Latest Code To NuGet HOT 1
- SingleServerManager goes into silent spin-loop on server failure HOT 14
- add Prepared Statement support
- Need updated documentation and more examples
- Incorrect code in MultiGetColumnCount.cs HOT 2
- Inserting composite key using API fails
- Various objects leaking HOT 5
- Multi-keyspace clusters cannot take advantage of connection pooling HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentcassandra.