Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 308d1db + 689c346 commit a6e2327b50175567a7ec7e62c5f9dca27ce29581 Grant Pexsa committed Sep 28, 2012
@@ -43,7 +43,7 @@ public static void InsertColumn(this CassandraColumnFamily family, CassandraObje
public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName, BytesType columnValue)
{
- InsertColumn(family, key, columnName, columnValue, DateTimeOffset.UtcNow, null);
+ InsertColumn(family, key, columnName, columnValue, TimestampHelper.UtcNow(), null);
}
public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName, BytesType columnValue, DateTimeOffset timestamp, int? timeToLive)
@@ -56,7 +56,7 @@ public static void InsertColumn(this CassandraSuperColumnFamily family, Cassandr
public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject name, BytesType value)
{
- InsertColumn(family, key, superColumnName, name, value, DateTimeOffset.UtcNow, null);
+ 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)
@@ -82,7 +82,7 @@ private void InitializeConnectionString(string connectionString)
if (nameValue.Length != 2)
continue;
- pairs.Add(nameValue[0], nameValue[1]);
+ pairs.Add(nameValue[0].Trim(), nameValue[1].Trim());
}
#region Keyspace
@@ -330,12 +330,12 @@ private void InitializeConnectionString(string connectionString)
foreach (var server in servers)
{
string[] serverParts = server.Split(':');
- string host = serverParts[0];
+ string host = serverParts[0].Trim();
if (serverParts.Length == 2)
{
int port;
- if (Int32.TryParse(serverParts[1], out port))
+ if (Int32.TryParse(serverParts[1].Trim(), out port))
Servers.Add(new Server(host: host, port: port, timeout: ConnectionTimeout.Seconds));
else
Servers.Add(new Server(host: host, timeout: ConnectionTimeout.Seconds));
@@ -127,6 +127,7 @@
<Compile Include="CassandraCqlRowSchema.cs" />
<Compile Include="CqlHelper.cs" />
<Compile Include="FluentCqlRow.cs" />
+ <Compile Include="GuidGeneration.cs" />
<Compile Include="ILoadable.cs" />
<Compile Include="FluentCassandraException.cs" />
<Compile Include="FluentColumn.cs">
@@ -217,6 +218,7 @@
<Compile Include="Operations\Void.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="System\DateTimePrecise.cs" />
<Compile Include="Thrift\Collections\THashSet.cs" />
<Compile Include="Thrift\Protocol\TBase.cs" />
<Compile Include="Thrift\Protocol\TBase64Utils.cs" />
@@ -2,7 +2,7 @@
<package>
<metadata>
<id>FluentCassandra</id>
- <version>1.1.6</version>
+ <version>1.1.7</version>
<title>Fluent Cassandra</title>
<authors>Nick Berardi</authors>
<owners>Managed Fusion, LLC</owners>
View
@@ -32,7 +32,7 @@ public FluentColumn(CassandraColumnSchema schema = null)
{
SetSchema(schema);
- ColumnTimestamp = DateTimeOffset.UtcNow;
+ ColumnTimestamp = TimestampHelper.UtcNow();
ColumnSecondsUntilDeleted = null;
ColumnTimeUntilDeleted = null;
}
@@ -46,7 +46,7 @@ public CassandraObject ColumnName
set
{
_name = value.GetValue(GetSchema().NameType);
- ColumnTimestamp = DateTimeOffset.UtcNow;
+ ColumnTimestamp = TimestampHelper.UtcNow();
}
}
@@ -59,7 +59,7 @@ public CassandraObject ColumnValue
set
{
_value = value.GetValue(GetSchema().ValueType);
- ColumnTimestamp = DateTimeOffset.UtcNow;
+ ColumnTimestamp = TimestampHelper.UtcNow();
}
}
View
@@ -80,18 +80,8 @@ public CassandraObject Key
/// <returns></returns>
public CassandraObject this[CassandraObject columnName]
{
- get
- {
- object value;
- if (!TryGetColumn(columnName, out value))
- throw new CassandraException(String.Format("Column, {0}, could not be found.", columnName));
-
- return (CassandraObject)value;
- }
- set
- {
- TrySetColumn(columnName, value);
- }
+ get { return GetColumnValue(columnName); }
+ set { SetColumn(columnName, value); }
}
/// <summary>
@@ -146,7 +136,7 @@ public override IList<FluentColumn> Columns
get { return _columns; }
}
- /// <summary>
+ /// <summary>
/// Gets the path.
/// </summary>
/// <returns></returns>
@@ -249,9 +239,31 @@ public override bool TrySetColumn(object name, object value)
return true;
}
+ public override bool TryRemoveColumn(object name)
+ {
+ var col = Columns.FirstOrDefault(c => c.ColumnName == name);
+
+ if (col != null) {
+ Columns.Remove(col);
+ return true;
+ }
+
+ var schema = GetColumnSchema(name);
+ var mutationType = MutationType.Removed;
+
+ col = new FluentColumn(schema);
+ col.ColumnName = CassandraObject.GetCassandraObjectFromObject(name, schema.NameType);
+ col.SetParent(GetSelf());
+
+ // notify the tracker that the column has changed
+ OnColumnMutated(mutationType, col);
+
+ return true;
+ }
+
public override string ToString()
{
return String.Format("{0} - {1}", FamilyName, Key);
}
}
-}
+}
View
@@ -95,6 +95,11 @@ public override bool TrySetColumn(object name, object value)
throw new NotSupportedException();
}
+ public override bool TryRemoveColumn(object name)
+ {
+ throw new NotSupportedException();
+ }
+
public string FamilyName
{
get;
@@ -112,7 +117,7 @@ public override IList<FluentColumn> Columns
get { return _columns; }
}
- public CassandraObject this[CassandraObject columnName]
+ public CassandraObject this[CassandraObject columnName]
{
get
{
View
@@ -9,7 +9,7 @@ public class FluentMutation
/// </summary>
internal FluentMutation()
{
- ColumnTimestamp = DateTimeOffset.UtcNow;
+ ColumnTimestamp = TimestampHelper.UtcNow();
}
/// <summary>
View
@@ -9,7 +9,7 @@ namespace FluentCassandra
/// <summary>
///
/// </summary>
- /// <typeparam name="T">A type that impliments <see cref="IFluentColumn"/>.</typeparam>
+ /// <typeparam name="T">A type that implements <see cref="IFluentColumn"/>.</typeparam>
public abstract class FluentRecord<T> : DynamicObject, IFluentRecord, INotifyPropertyChanged, IEnumerable<IFluentBaseColumn>, ILoadable
where T : IFluentBaseColumn
{
@@ -27,6 +27,53 @@ public FluentRecord()
/// </summary>
public abstract IList<T> Columns { get; }
+ public T GetColumn(object name)
+ {
+ var col = Columns.FirstOrDefault(c => c.ColumnName == name);
+
+ if (col == null)
+ return default(T);
+
+ return col;
+ }
+
+ public bool SetColumn(object name, object value)
+ {
+ return TrySetColumn(name, value);
+ }
+
+ public bool RemoveColumn(object name)
+ {
+ return TryRemoveColumn(name);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="name"></param>
+ /// <param name="result"></param>
+ /// <returns></returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public abstract bool TryGetColumn(object name, out object result);
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="name"></param>
+ /// <param name="value"></param>
+ /// <returns></returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public abstract bool TrySetColumn(object name, object value);
+
+
+ ///
+ /// </summary>
+ /// <param name="name"></param>
+ /// <param name="value"></param>
+ /// <returns></returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public abstract bool TryRemoveColumn(object name);
+
/// <summary>
///
/// </summary>
@@ -66,15 +113,6 @@ public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out ob
/// <summary>
///
/// </summary>
- /// <param name="name"></param>
- /// <param name="result"></param>
- /// <returns></returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public abstract bool TryGetColumn(object name, out object result);
-
- /// <summary>
- ///
- /// </summary>
/// <param name="binder"></param>
/// <param name="value"></param>
/// <returns></returns>
@@ -105,7 +143,24 @@ public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object
/// <param name="value"></param>
/// <returns></returns>
[EditorBrowsable(EditorBrowsableState.Never)]
- public abstract bool TrySetColumn(object name, object value);
+ public override bool TryDeleteMember(DeleteMemberBinder binder)
+ {
+ return TryRemoveColumn(binder.Name);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="binder"></param>
+ /// <param name="indexes"></param>
+ /// <param name="value"></param>
+ /// <returns></returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool TryDeleteIndex(DeleteIndexBinder binder, object[] indexes)
+ {
+ object index0 = indexes[0];
+ return TryRemoveColumn(index0);
+ }
protected bool SuppressMutationTracking { get; private set; }
@@ -170,14 +225,6 @@ public IFluentMutationTracker MutationTracker
private set;
}
- public void RemoveColumn(object name)
- {
- var col = Columns.FirstOrDefault(c => c.ColumnName == name);
-
- if (col != null)
- Columns.Remove(col);
- }
-
#endregion
}
}
View
@@ -87,7 +87,7 @@ public override IList<FluentColumn> Columns
get { return _columns; }
}
- /// <summary>
+ /// <summary>
///
/// </summary>
public FluentSuperColumnFamily Family
@@ -226,7 +226,7 @@ public override bool TrySetColumn(object name, object value)
var col = Columns.FirstOrDefault(c => c.ColumnName == name);
var mutationType = MutationType.Changed;
- // if column doesn't exisit create it and add it to the columns
+ // if column doesn't exist create it and add it to the columns
if (col == null)
{
var schema = GetColumnSchema(name);
@@ -249,6 +249,29 @@ public override bool TrySetColumn(object name, object value)
return true;
}
+ public override bool TryRemoveColumn(object name)
+ {
+ var col = Columns.FirstOrDefault(c => c.ColumnName == name);
+
+ if (col != null)
+ {
+ Columns.Remove(col);
+ return true;
+ }
+
+ var schema = GetColumnSchema(name);
+ var mutationType = MutationType.Removed;
+
+ col = new FluentColumn(schema);
+ col.ColumnName = CassandraObject.GetCassandraObjectFromObject(name, schema.NameType);
+ col.SetParent(GetPath());
+
+ // notify the tracker that the column has changed
+ OnColumnMutated(mutationType, col);
+
+ return true;
+ }
+
public void SetParent(FluentColumnParent parent)
{
UpdateParent(parent);
@@ -130,7 +130,7 @@ public override IList<FluentSuperColumn> Columns
get { return _columns; }
}
- /// <summary>
+ /// <summary>
///
/// </summary>
public CassandraColumnFamilySchema GetSchema()
@@ -251,6 +251,29 @@ public override bool TrySetColumn(object name, object value)
return true;
}
+ public override bool TryRemoveColumn(object name)
+ {
+ var col = Columns.FirstOrDefault(c => c.ColumnName == name);
+
+ if (col != null)
+ {
+ Columns.Remove(col);
+ return true;
+ }
+
+ var schema = GetColumnSchema(name);
+ var mutationType = MutationType.Removed;
+
+ col = new FluentSuperColumn(schema);
+ col.ColumnName = CassandraObject.GetCassandraObjectFromObject(name, schema.NameType);
+ col.SetParent(GetSelf());
+
+ // notify the tracker that the column has changed
+ OnColumnMutated(mutationType, col);
+
+ return true;
+ }
+
public override string ToString()
{
return String.Format("{0} - {1}", FamilyName, Key);
Oops, something went wrong.

0 comments on commit a6e2327

Please sign in to comment.