This repository has been archived by the owner on May 25, 2021. It is now read-only.
/
InsertColumn.cs
74 lines (58 loc) · 1.69 KB
/
InsertColumn.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using FluentCassandra.Types;
using Apache.Cassandra;
namespace FluentCassandra.Operations
{
public class InsertColumn : ColumnFamilyOperation<Void>
{
/*
* insert(keyspace, key, column_path, value, timestamp, consistency_level)
*/
public BytesType Key { get; private set; }
public CassandraType SuperColumnName { get; private set; }
public CassandraType ColumnName { get; private set; }
public BytesType ColumnValue { get; private set; }
public int TimeToLive { get; private set; }
public DateTimeOffset Timestamp { get; private set; }
#region ICassandraAction<Void> Members
public override Void Execute(BaseCassandraColumnFamily columnFamily)
{
var parent = new ColumnParent {
Column_family = columnFamily.FamilyName,
};
if (SuperColumnName != null)
parent.Super_column = SuperColumnName;
var column = new Column {
Name = ColumnName,
Value = ColumnValue,
Timestamp = Timestamp.ToTimestamp(),
Ttl = TimeToLive
};
CassandraSession.Current.GetClient().insert(
Key,
parent,
column,
CassandraSession.Current.WriteConsistency
);
return new Void();
}
#endregion
public InsertColumn(BytesType key, CassandraType name, BytesType value, DateTimeOffset timestamp, int timeToLive)
{
Key = key;
ColumnName = name;
ColumnValue = value;
Timestamp = timestamp;
TimeToLive = timeToLive;
}
public InsertColumn(BytesType key, CassandraType superColumnName, CassandraType name, BytesType value, DateTimeOffset timestamp, int timeToLive)
{
Key = key;
SuperColumnName = superColumnName;
ColumnName = name;
ColumnValue = value;
Timestamp = timestamp;
TimeToLive = timeToLive;
}
}
}