Cassandra timeout in Datastax C # driver

What type of C # is equivalent to timeuuid in a Datastax Cassandra C # driver?

I am writing a simple user tracking service and want to access the latest user history. I am trying to create a table equivalent to this create statement:

CREATE TABLE IF NOT EXISTS user_history (
    user_id text,
    event_type text,
    create_date timeuuid,
    item_id text,
    PRIMARY KEY ((user_id, event_type), create_date)
);

I made the following class:

[AllowFiltering]
[Table("user_history")]
public class UserHistory
{
    [PartitionKey(1)]
    [Column("user_id")]
    public string UserID;

    [PartitionKey(2)]
    [Column("event_type")]
    public string EventType;

    [ClusteringKey(1)]
    [Column("create_date")]
    public DateTime CreateDate { get; set; }

    [Column("item_id")] 
    public string ItemID;
}

And I use this operator to create a table in Cassandra:

var table = Session.GetTable<UserHistory>();
table.CreateIfNotExists();

But this gives me the following table:

CREATE TABLE user_history (
  user_id text,
  event_type text,
  create_date timestamp,
  item_id text,
  PRIMARY KEY ((user_id, event_type), create_date)
)

As you can see, the type create_dateis equal timestampinstead timeuuid.

I tried Guidinstead DateTime, but it gives me uuidwhen I call .CreateIfNotExists().

Guid DateTime CreateDate ​​ CQL3? , timeuuid / ( GuidGenerator, FluentCassandra)?! (: Datastax)

+3
2

Timeuuid , guid, : create-a-time-uuid-guid-in -net FluentCassandra

" , UUID Time-Based Guid .NET.

public static Guid GenerateTimeBasedGuid(DateTime dateTime)  
{
    long ticks = dateTime.Ticks - GregorianCalendarStart.Ticks;

    byte[] guid = new byte[ByteArraySize];
    byte[] clockSequenceBytes = BitConverter.GetBytes(Convert.ToInt16(Environment.TickCount % Int16.MaxValue));
    byte[] timestamp = BitConverter.GetBytes(ticks);

    // copy node
    Array.Copy(Node, 0, guid, NodeByte, Node.Length);

    // copy clock sequence
    Array.Copy(clockSequenceBytes, 0, guid, GuidClockSequenceByte, clockSequenceBytes.Length);

    // copy timestamp
    Array.Copy(timestamp, 0, guid, 0, timestamp.Length);

    // set the variant
    guid[VariantByte] &= (byte)VariantByteMask;
    guid[VariantByte] |= (byte)VariantByteShift;

    // set the version
    guid[VersionByte] &= (byte)VersionByteMask;
    guid[VersionByte] |= (byte)((int)GuidVersion.TimeBased << VersionByteShift);

    return new Guid(guid);
}
+4

, , .

, , BCL TimeUUID, Java, DataStax.NET Driver 2.1.3 TimeUuid, . . / System.Guid LINQ, .

+5

All Articles