Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactored a couple of schema related changes

  • Loading branch information...
commit a9597c90474a67ac4ac39918c17045bee5b62a72 1 parent 0b0daeb
@nberardi nberardi authored
View
14 src/CassandraColumnFamilySchema.cs
@@ -11,15 +11,11 @@ public class CassandraColumnFamilySchema
public static readonly AsciiType DefaultKeyName = "KEY";
public static readonly CassandraType DefaultKeyNameType = CassandraType.AsciiType;
-#if DEBUG
- private CfDef _def;
-#endif
+ private readonly CfDef _def;
public CassandraColumnFamilySchema(CfDef def)
{
-#if DEBUG
_def = def;
-#endif
KeyspaceName = def.Keyspace;
@@ -47,7 +43,7 @@ public CassandraColumnFamilySchema(CfDef def)
FamilyDescription = def.Comment;
KeyName = CassandraObject.GetCassandraObjectFromDatabaseByteArray(def.Key_alias, DefaultKeyNameType);
- DefaultKeyValueType = defaultKeyValueType;
+ KeyValueType = defaultKeyValueType;
SuperColumnNameType = superColumnNameType;
ColumnNameType = columnNameType;
@@ -63,7 +59,7 @@ public CassandraColumnFamilySchema(string name = null, ColumnType type = ColumnT
FamilyDescription = null;
KeyName = DefaultKeyName;
- DefaultKeyValueType = CassandraType.BytesType;
+ KeyValueType = CassandraType.BytesType;
SuperColumnNameType = type == ColumnType.Super ? CassandraType.BytesType : null;
ColumnNameType = CassandraType.BytesType;
@@ -79,7 +75,7 @@ public CassandraColumnFamilySchema(string name = null, ColumnType type = ColumnT
public string FamilyDescription { get; set; }
public CassandraObject KeyName { get; set; }
- public CassandraType DefaultKeyValueType { get; set; }
+ public CassandraType KeyValueType { get; set; }
public CassandraType SuperColumnNameType { get; set; }
public CassandraType ColumnNameType { get; set; }
@@ -95,7 +91,7 @@ public CassandraColumnFamilySchema(string name = null, ColumnType type = ColumnT
Comment = schema.FamilyDescription,
Column_type = schema.FamilyType.ToString(),
Key_alias = schema.KeyName.ToBigEndian(),
- Key_validation_class = schema.DefaultKeyValueType.DatabaseType,
+ Key_validation_class = schema.KeyValueType.DatabaseType,
Comparator_type = schema.ColumnNameType.DatabaseType,
Default_validation_class = schema.DefaultColumnValueType.DatabaseType
};
View
12 src/CassandraContext.cs
@@ -141,6 +141,12 @@ public string UpdateKeyspace(KsDef definition)
}));
}
+ public void TryDropKeyspace(string keyspace)
+ {
+ try { DropKeyspace(keyspace); }
+ catch (Exception exc) { Debug.WriteLine(exc); }
+ }
+
public string DropKeyspace(string keyspace)
{
return ExecuteOperation(new SimpleOperation<string>(ctx => {
@@ -166,6 +172,12 @@ public string UpdateColumnFamily(CfDef definition)
}));
}
+ public void TryDropColumnFamily(string columnFamily)
+ {
+ try { DropColumnFamily(columnFamily); }
+ catch (Exception exc) { Debug.WriteLine(exc); }
+ }
+
public string DropColumnFamily(string columnFamily)
{
Keyspace.ClearCachedKeyspaceSchema();
View
4 src/FluentCassandra.csproj
@@ -42,7 +42,8 @@
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
- <AssemblyOriginatorKeyFile>FluentCassandra.snk</AssemblyOriginatorKeyFile>
+ <AssemblyOriginatorKeyFile>
+ </AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -304,7 +305,6 @@
<None Include="FluentCassandra.nuspec">
<SubType>Designer</SubType>
</None>
- <None Include="FluentCassandra.snk" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
View
4 src/FluentColumnFamily.cs
@@ -12,7 +12,7 @@ public class FluentColumnFamily<CompareWith> : FluentColumnFamily
public FluentColumnFamily(CassandraObject key, string columnFamily)
: base(key, columnFamily, new CassandraColumnFamilySchema {
FamilyName = columnFamily,
- DefaultKeyValueType = typeof(BytesType),
+ KeyValueType = typeof(BytesType),
ColumnNameType = typeof(CompareWith)
}) { }
}
@@ -60,7 +60,7 @@ internal FluentColumnFamily(CassandraObject key, string columnFamily, CassandraC
public CassandraObject Key
{
get { return _key; }
- set { _key = value.GetValue(GetSchema().DefaultKeyValueType); }
+ set { _key = value.GetValue(GetSchema().KeyValueType); }
}
/// <summary>
View
4 src/FluentSuperColumnFamily.cs
@@ -13,7 +13,7 @@ public class FluentSuperColumnFamily<CompareWith, CompareSubcolumnWith> : Fluent
public FluentSuperColumnFamily(CassandraObject key, string columnFamily)
: base(key, columnFamily, new CassandraColumnFamilySchema {
FamilyName = columnFamily,
- DefaultKeyValueType = typeof(BytesType),
+ KeyValueType = typeof(BytesType),
SuperColumnNameType = typeof(CompareWith),
ColumnNameType = typeof(CompareSubcolumnWith)
}) { }
@@ -63,7 +63,7 @@ internal FluentSuperColumnFamily(CassandraObject key, string columnFamily, Cassa
public CassandraObject Key
{
get { return _key; }
- set { _key = value.GetValue(GetSchema().DefaultKeyValueType); }
+ set { _key = value.GetValue(GetSchema().KeyValueType); }
}
/// <summary>
View
2  src/Operations/MultiGetColumnFamilySlice.cs
@@ -32,7 +32,7 @@ public override IEnumerable<FluentColumnFamily> Execute()
foreach (var result in output)
{
- var key = CassandraObject.GetCassandraObjectFromDatabaseByteArray(result.Key, schema.DefaultKeyValueType);
+ var key = CassandraObject.GetCassandraObjectFromDatabaseByteArray(result.Key, schema.KeyValueType);
var r = new FluentColumnFamily(key, ColumnFamily.FamilyName, schema, result.Value.Select(col => {
return Helper.ConvertColumnToFluentColumn(col.Column, schema);
View
2  src/Operations/MultiGetSuperColumnFamilySlice.cs
@@ -33,7 +33,7 @@ public override IEnumerable<FluentSuperColumnFamily> Execute()
foreach (var result in output)
{
- var key = CassandraObject.GetCassandraObjectFromDatabaseByteArray(result.Key, schema.DefaultKeyValueType);
+ var key = CassandraObject.GetCassandraObjectFromDatabaseByteArray(result.Key, schema.KeyValueType);
var superColumns = (IEnumerable<FluentSuperColumn>)null;
View
5 src/Types/CassandraType.cs
@@ -187,6 +187,11 @@ public override string ToString()
return _dbType;
}
+ public static CassandraType CompositeType(params CassandraType[] hints)
+ {
+ return CompositeType((IEnumerable<CassandraType>)hints);
+ }
+
public static CassandraType CompositeType(IEnumerable<CassandraType> hints)
{
var sb = new StringBuilder();
View
4 test/FluentCassandra.Sandbox/Program.cs
@@ -38,7 +38,7 @@ PostedOn timestamp
// create column family using API
keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
FamilyName = "Tags",
- DefaultKeyValueType = CassandraType.AsciiType,
+ KeyValueType = CassandraType.AsciiType,
ColumnNameType = CassandraType.Int32Type,
DefaultColumnValueType = CassandraType.UTF8Type
});
@@ -47,7 +47,7 @@ PostedOn timestamp
keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
FamilyName = "Comments",
FamilyType = ColumnType.Super,
- DefaultKeyValueType = CassandraType.AsciiType,
+ KeyValueType = CassandraType.AsciiType,
SuperColumnNameType = CassandraType.DateType,
ColumnNameType = CassandraType.UTF8Type,
DefaultColumnValueType = CassandraType.UTF8Type
View
4 test/FluentCassandra.Tests/CassandraDatabaseSetup.cs
@@ -63,9 +63,7 @@ public void ResetDatabase()
using (var db = new CassandraContext(session))
{
db.ThrowErrors = true;
-
- try { db.DropKeyspace(Keyspace); }
- catch (Exception exc) { Console.WriteLine(exc); }
+ db.TryDropKeyspace(Keyspace);
var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema {
Name = Keyspace
View
1  test/FluentCassandra.Tests/FluentCassandra.Tests.csproj
@@ -53,6 +53,7 @@
<Compile Include="Bugs\Issue28GuidGeneratorInParallelContext.cs" />
<Compile Include="Bugs\Issue25JavaBigDecimalBinaryConversion.cs" />
<Compile Include="Bugs\Issue36KeyAliasSupport.cs" />
+ <Compile Include="Bugs\IssueXXCompositeTypeAsKey.cs" />
<Compile Include="CassandraDatabaseSetupFixture.cs" />
<Compile Include="CassandraQueryTest.cs" />
<Compile Include="Connections\ConnectionProviderTests.cs" />
Please sign in to comment.
Something went wrong with that request. Please try again.