Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 184 lines (141 sloc) 7.095 kb
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
using FluentCassandra.Operations;
using FluentCassandra.Types;
using System;
using System.Collections.Generic;

namespace FluentCassandra
{
public static class CassandraSuperColumnFamilyOperations
{
#region ColumnCount

public static int ColumnCount(this CassandraSuperColumnFamily family, CassandraObject key, IEnumerable<CassandraObject> columnNames)
{
var op = new ColumnCount(key, new CassandraColumnSlicePredicate(columnNames));
return family.ExecuteOperation(op);
}

public static int ColumnCount(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject columnStart, CassandraObject columnEnd, bool reversed = false, int count = 100)
{
var op = new ColumnCount(key, new CassandraRangeSlicePredicate(columnStart, columnEnd, reversed, count));
return family.ExecuteOperation(op);
}

public static int SuperColumnCount(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, IEnumerable<CassandraObject> columnNames)
{
var op = new ColumnCount(key, superColumnName, new CassandraColumnSlicePredicate(columnNames));
return family.ExecuteOperation(op);
}

public static int SuperColumnCount(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject columnStart, CassandraObject columnEnd, bool reversed = false, int count = 100)
{
var op = new ColumnCount(key, superColumnName, new CassandraRangeSlicePredicate(columnStart, columnEnd, reversed, count));
return family.ExecuteOperation(op);
}

#endregion

#region InsertColumn

public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumn column)
{
InsertColumn(family, key, column.GetPath());
}

public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumnPath path)
{
var superColumnName = path.SuperColumn.ColumnName;
var name = path.Column.ColumnName;
var value = path.Column.ColumnValue;
var timestamp = path.Column.ColumnTimestamp;
var timeToLive = path.Column.ColumnSecondsUntilDeleted;

var op = new InsertColumn(key, superColumnName, name, value, timestamp, timeToLive);
family.ExecuteOperation(op);
}

public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject name, BytesType value)
{
InsertColumn(family, key, superColumnName, name, value, TimestampHelper.UtcNow(), null);
}

public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject name, BytesType value, DateTimeOffset timestamp, int? timeToLive)
{
var op = new InsertColumn(key, superColumnName, name, value, timestamp, timeToLive);
family.ExecuteOperation(op);
}

#endregion

#region AddColumn

public static void InsertCounterColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject columnName, long columnValue)
{
var op = new AddColumn(key, superColumnName, columnName, columnValue);
family.ExecuteOperation(op);
}

#endregion

#region GetColumn

public static FluentColumn GetColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumnPath path)
{
var columnName = path.Column.ColumnName;
var superColumnName = path.SuperColumn.ColumnName;
return GetColumn(family, key, superColumnName, columnName);
}

public static FluentColumn GetColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject columnName)
{
var op = new GetColumn(key, superColumnName, columnName);
return family.ExecuteOperation(op);
}

#endregion

#region GetSuperColumn

public static FluentSuperColumn GetSuperColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumnParent parent)
{
var superColumnName = parent.SuperColumn.ColumnName;
return GetSuperColumn(family, key, superColumnName);
}

public static FluentSuperColumn GetSuperColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName)
{
var op = new GetSuperColumn(key, superColumnName);
return family.ExecuteOperation(op);
}

#endregion

#region RemoveColumn

public static void RemoveColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumnPath path)
{
var columnName = path.Column.ColumnName;
var superColumnName = path.SuperColumn.ColumnName;
RemoveColumn(family, key, superColumnName, columnName);
}

public static void RemoveColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName)
{
RemoveColumn(family, key, superColumnName, null);
}

public static void RemoveColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject columnName)
{
var op = new Remove(key, superColumnName, columnName);
family.ExecuteOperation(op);
}

#endregion

#region GetSingleSuperColumn

public static FluentSuperColumn GetSingleSuperColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, IEnumerable<CassandraObject> columnNames)
{
var op = new GetSuperColumnSlice(key, superColumnName, new CassandraColumnSlicePredicate(columnNames));
return family.ExecuteOperation(op);
}

public static FluentSuperColumn GetSingleSuperColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject columnStart, CassandraObject columnEnd, bool reversed = false, int count = 100)
{
var op = new GetSuperColumnSlice(key, superColumnName, new CassandraRangeSlicePredicate(columnStart, columnEnd, reversed, count));
return family.ExecuteOperation(op);
}

#endregion

#region GetSingle

public static FluentSuperColumnFamily GetSingle(this CassandraSuperColumnFamily family, CassandraObject key, IEnumerable<CassandraObject> columnNames)
{
var op = new GetSuperColumnFamilySlice(key, new CassandraColumnSlicePredicate(columnNames));
return family.ExecuteOperation(op);
}

public static FluentSuperColumnFamily GetSingle(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject columnStart, CassandraObject columnEnd, bool reversed = false, int count = 100)
{
var op = new GetSuperColumnFamilySlice(key, new CassandraRangeSlicePredicate(columnStart, columnEnd, reversed, count));
return family.ExecuteOperation(op);
}

#endregion

#region Get

// queryable

public static CassandraSlicePredicateQuery<FluentSuperColumnFamily> Get(this CassandraSuperColumnFamily family)
{
return family.CreateCassandraSlicePredicateQuery<FluentSuperColumnFamily>(null);
}

public static CassandraSlicePredicateQuery<FluentSuperColumnFamily> Get(this CassandraSuperColumnFamily family, params CassandraObject[] keys)
{
return Get(family).FetchKeys(keys);
}

#endregion
}
}
Something went wrong with that request. Please try again.