This repository has been archived by the owner on May 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
/
InsertColumn.cs
75 lines (58 loc) · 1.76 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
75
using FluentCassandra.Types;
using System;
namespace FluentCassandra.Operations
{
public class InsertColumn : ColumnFamilyOperation<Void>
{
/*
* insert(keyspace, key, column_path, value, timestamp, consistency_level)
*/
public CassandraObject Key { get; private set; }
public CassandraObject SuperColumnName { get; private set; }
public CassandraObject ColumnName { get; private set; }
public CassandraObject ColumnValue { get; private set; }
public int? TimeToLive { get; private set; }
public DateTimeOffset Timestamp { get; private set; }
#region ICassandraAction<Void> Members
public override Void Execute()
{
var schema = ColumnFamily.GetSchema();
var parent = new CassandraColumnParent {
ColumnFamily = ColumnFamily.FamilyName,
};
if (SuperColumnName != null)
parent.SuperColumn = SuperColumnName.GetValue(schema.SuperColumnNameType);
var column = new CassandraColumn {
Name = ColumnName.GetValue(schema.ColumnNameType),
Value = ColumnValue,
Timestamp = Timestamp,
Ttl = TimeToLive
};
Session.GetClient().insert(
Key,
parent,
column,
Session.WriteConsistency
);
return new Void();
}
#endregion
public InsertColumn(CassandraObject key, CassandraObject name, CassandraObject value, DateTimeOffset timestamp, int? timeToLive)
{
Key = key;
ColumnName = name;
ColumnValue = value;
Timestamp = timestamp;
TimeToLive = timeToLive;
}
public InsertColumn(CassandraObject key, CassandraObject superColumnName, CassandraObject name, CassandraObject value, DateTimeOffset timestamp, int? timeToLive)
{
Key = key;
SuperColumnName = superColumnName;
ColumnName = name;
ColumnValue = value;
Timestamp = timestamp;
TimeToLive = timeToLive;
}
}
}