Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 142 lines (121 sloc) 2.823 kb
e3e35a2 Nick Berardi basic column_family is working in sandbox
nberardi authored
1 using System;
a47e07d Nick Berardi have a new outlook on how columns should be structured, to support the m...
nberardi authored
2 using FluentCassandra.Types;
e3e35a2 Nick Berardi basic column_family is working in sandbox
nberardi authored
3
4 namespace FluentCassandra
5 {
6 /// <summary>
7 ///
8 /// </summary>
9 /// <typeparam name="T"></typeparam>
2db6327 Nick Berardi going through some changes to make the interface the objects more useful...
nberardi authored
10 public class FluentColumn<CompareWith> : IFluentColumn<CompareWith>
11 where CompareWith : CassandraType
e3e35a2 Nick Berardi basic column_family is working in sandbox
nberardi authored
12 {
2db6327 Nick Berardi going through some changes to make the interface the objects more useful...
nberardi authored
13 private BytesType _value;
cdf0b73 Nick Berardi added tests to make sure everything works correctly in the type conversi...
nberardi authored
14 private FluentColumnParent _parent;
fae0bc5 Nick Berardi fixed a bug dealing with mutations
nberardi authored
15 private IFluentBaseColumnFamily _family;
dc0875f Nick Berardi only in Cassandra does TTL mean Seconds Until Deleted
nberardi authored
16 private int? _ttl;
a47e07d Nick Berardi have a new outlook on how columns should be structured, to support the m...
nberardi authored
17
e3e35a2 Nick Berardi basic column_family is working in sandbox
nberardi authored
18 public FluentColumn()
19 {
a19e80c Nick Berardi added commenting to the demo
nberardi authored
20 ColumnTimestamp = DateTimeOffset.UtcNow;
dc0875f Nick Berardi only in Cassandra does TTL mean Seconds Until Deleted
nberardi authored
21 ColumnSecondsUntilDeleted = null;
2b76325 Nick Berardi added the new types introduced in Cassandra 1.0.0
nberardi authored
22 ColumnTimeUntilDeleted = null;
e3e35a2 Nick Berardi basic column_family is working in sandbox
nberardi authored
23 }
24
0999b21 Nick Berardi added prelim support for SuperColumn
nberardi authored
25 /// <summary>
26 /// The column name.
27 /// </summary>
a19e80c Nick Berardi added commenting to the demo
nberardi authored
28 public CompareWith ColumnName { get; set; }
88be638 Nick Berardi did some clean up and Get is now supported for a single column
nberardi authored
29
a19e80c Nick Berardi added commenting to the demo
nberardi authored
30 public BytesType ColumnValue
88be638 Nick Berardi did some clean up and Get is now supported for a single column
nberardi authored
31 {
2db6327 Nick Berardi going through some changes to make the interface the objects more useful...
nberardi authored
32 get { return _value; }
33 set
34 {
35 _value = value;
a19e80c Nick Berardi added commenting to the demo
nberardi authored
36 ColumnTimestamp = DateTimeOffset.UtcNow;
2db6327 Nick Berardi going through some changes to make the interface the objects more useful...
nberardi authored
37 }
e3e35a2 Nick Berardi basic column_family is working in sandbox
nberardi authored
38 }
39
0999b21 Nick Berardi added prelim support for SuperColumn
nberardi authored
40 /// <summary>
41 /// The column timestamp.
42 /// </summary>
a19e80c Nick Berardi added commenting to the demo
nberardi authored
43 public DateTimeOffset ColumnTimestamp
88be638 Nick Berardi did some clean up and Get is now supported for a single column
nberardi authored
44 {
45 get;
46 internal set;
47 }
e3e35a2 Nick Berardi basic column_family is working in sandbox
nberardi authored
48
0999b21 Nick Berardi added prelim support for SuperColumn
nberardi authored
49 /// <summary>
f784bbc Nick Berardi making some real progress slowly rebuilding project with new cassandra t...
nberardi authored
50 ///
88be638 Nick Berardi did some clean up and Get is now supported for a single column
nberardi authored
51 /// </summary>
fae0bc5 Nick Berardi fixed a bug dealing with mutations
nberardi authored
52 public IFluentBaseColumnFamily Family
88be638 Nick Berardi did some clean up and Get is now supported for a single column
nberardi authored
53 {
f77d3d9 Nick Berardi cleaning up some tests and getting example to work as part of some pre-p...
nberardi authored
54 get
55 {
56 if (_family == null && _parent != null)
57 _family = _parent.ColumnFamily as IFluentColumnFamily<CompareWith>;
58
59 return _family;
60 }
f784bbc Nick Berardi making some real progress slowly rebuilding project with new cassandra t...
nberardi authored
61 internal set
62 {
63 _family = value;
64 UpdateParent(GetParent());
65 }
88be638 Nick Berardi did some clean up and Get is now supported for a single column
nberardi authored
66 }
67
68 /// <summary>
ce017c8 Nick Berardi all tests working for 0.7
nberardi authored
69 ///
70 /// </summary>
dc0875f Nick Berardi only in Cassandra does TTL mean Seconds Until Deleted
nberardi authored
71 public int? ColumnSecondsUntilDeleted
ce017c8 Nick Berardi all tests working for 0.7
nberardi authored
72 {
dc0875f Nick Berardi only in Cassandra does TTL mean Seconds Until Deleted
nberardi authored
73 get { return _ttl; }
74 set
75 {
2b76325 Nick Berardi added the new types introduced in Cassandra 1.0.0
nberardi authored
76 if (value.HasValue && value < 1)
77 throw new CassandraException("ColumnSecondsUntilDeleted needs to be set to a postive value that is greater than zero.");
dc0875f Nick Berardi only in Cassandra does TTL mean Seconds Until Deleted
nberardi authored
78
79 _ttl = value;
80 }
ce017c8 Nick Berardi all tests working for 0.7
nberardi authored
81 }
82
83 /// <summary>
2b76325 Nick Berardi added the new types introduced in Cassandra 1.0.0
nberardi authored
84 ///
85 /// </summary>
86 public TimeSpan? ColumnTimeUntilDeleted
87 {
88 get
89 {
90 if (ColumnSecondsUntilDeleted.HasValue)
91 return TimeSpan.FromSeconds(ColumnSecondsUntilDeleted.Value);
92
93 return null;
94 }
95 set
96 {
97 if (value.HasValue && value.Value < TimeSpan.FromSeconds(1))
98 throw new CassandraException("ColumnTimeUntilDeleted needs to be set to a postive TimeSpan that is greater than or equal to 1 second.");
99
100 if (value.HasValue)
101 ColumnSecondsUntilDeleted = Convert.ToInt32(value.Value.TotalSeconds);
102
103 ColumnSecondsUntilDeleted = null;
104 }
105 }
106
107 /// <summary>
88be638 Nick Berardi did some clean up and Get is now supported for a single column
nberardi authored
108 /// Gets the path.
109 /// </summary>
110 /// <returns></returns>
111 public FluentColumnPath GetPath()
112 {
cdf0b73 Nick Berardi added tests to make sure everything works correctly in the type conversi...
nberardi authored
113 return new FluentColumnPath(_parent, (IFluentColumn<CassandraType>)this);
88be638 Nick Berardi did some clean up and Get is now supported for a single column
nberardi authored
114 }
115
116 /// <summary>
117 /// Gets the parent.
118 /// </summary>
119 /// <returns></returns>
120 public FluentColumnParent GetParent()
121 {
cdf0b73 Nick Berardi added tests to make sure everything works correctly in the type conversi...
nberardi authored
122 return _parent;
e3e35a2 Nick Berardi basic column_family is working in sandbox
nberardi authored
123 }
f27726f Nick Berardi adding mutation tracking to the fluent objects
nberardi authored
124
cdf0b73 Nick Berardi added tests to make sure everything works correctly in the type conversi...
nberardi authored
125 #region IFluentBaseColumn Members
2db6327 Nick Berardi going through some changes to make the interface the objects more useful...
nberardi authored
126
a19e80c Nick Berardi added commenting to the demo
nberardi authored
127 CassandraType IFluentBaseColumn.ColumnName { get { return ColumnName; } }
2db6327 Nick Berardi going through some changes to make the interface the objects more useful...
nberardi authored
128
cdf0b73 Nick Berardi added tests to make sure everything works correctly in the type conversi...
nberardi authored
129 void IFluentBaseColumn.SetParent(FluentColumnParent parent)
f27726f Nick Berardi adding mutation tracking to the fluent objects
nberardi authored
130 {
f784bbc Nick Berardi making some real progress slowly rebuilding project with new cassandra t...
nberardi authored
131 UpdateParent(parent);
132 }
133
134 private void UpdateParent(FluentColumnParent parent)
135 {
cdf0b73 Nick Berardi added tests to make sure everything works correctly in the type conversi...
nberardi authored
136 _parent = parent;
f27726f Nick Berardi adding mutation tracking to the fluent objects
nberardi authored
137 }
2db6327 Nick Berardi going through some changes to make the interface the objects more useful...
nberardi authored
138
139 #endregion
e3e35a2 Nick Berardi basic column_family is working in sandbox
nberardi authored
140 }
141 }
Something went wrong with that request. Please try again.