Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 53 lines (43 sloc) 1.335 kB
f27726f @nberardi adding mutation tracking to the fluent objects
nberardi authored
1 using System;
2c77dfc @nberardi refactored mutation handling to better handle super columns which fix…
nberardi authored
2 using System.Linq;
f27726f @nberardi adding mutation tracking to the fluent objects
nberardi authored
3 using System.Collections.Generic;
4
5 namespace FluentCassandra
6 {
7 public class FluentMutationTracker : IFluentMutationTracker
8 {
9 private IList<FluentMutation> _mutation;
10
72267db @nberardi tracking object seems to be working for adds, needs a ton more testin…
nberardi authored
11 protected internal FluentMutationTracker(IFluentRecord parentRecord)
f27726f @nberardi adding mutation tracking to the fluent objects
nberardi authored
12 {
72267db @nberardi tracking object seems to be working for adds, needs a ton more testin…
nberardi authored
13 ParentRecord = parentRecord;
f27726f @nberardi adding mutation tracking to the fluent objects
nberardi authored
14 _mutation = new List<FluentMutation>();
15 }
16
72267db @nberardi tracking object seems to be working for adds, needs a ton more testin…
nberardi authored
17 public IFluentRecord ParentRecord { get; private set; }
f27726f @nberardi adding mutation tracking to the fluent objects
nberardi authored
18
2c77dfc @nberardi refactored mutation handling to better handle super columns which fix…
nberardi authored
19 public virtual void ColumnMutated(MutationType type, IFluentBaseColumn column)
f27726f @nberardi adding mutation tracking to the fluent objects
nberardi authored
20 {
2c77dfc @nberardi refactored mutation handling to better handle super columns which fix…
nberardi authored
21 if (ParentRecord is FluentSuperColumn)
22 {
23 var superColumn = (FluentSuperColumn)ParentRecord;
24 var superColumnFamilyMutationTracker = superColumn.Family.MutationTracker;
25
26 // check to see if there is a mutation for this column already, so we don't create duplicate mutations
27 if (!superColumnFamilyMutationTracker.GetMutations().Any(x => x.Column.ColumnName == superColumn.ColumnName))
28 superColumnFamilyMutationTracker.ColumnMutated(MutationType.Changed, superColumn);
29 }
30
f27726f @nberardi adding mutation tracking to the fluent objects
nberardi authored
31 _mutation.Add(new FluentMutation {
32 Type = type,
33 Column = column
34 });
35 }
36
2c77dfc @nberardi refactored mutation handling to better handle super columns which fix…
nberardi authored
37 protected internal void Remove(FluentMutation mutation)
38 {
39 _mutation.Remove(mutation);
40 }
41
42 public virtual void Clear()
f27726f @nberardi adding mutation tracking to the fluent objects
nberardi authored
43 {
44 _mutation.Clear();
45 }
46
47 public IEnumerable<FluentMutation> GetMutations()
48 {
49 return _mutation;
50 }
51 }
52 }
Something went wrong with that request. Please try again.