Пример #1
0
        public override string ToString()
        {
            Dictionary <string, string> opt =
                new Dictionary <string, string>()
            {
                { COMMENT, comment },
                { READ_REPAIR, readRepair.ToString() },
                { LOCAL_READ_REPAIR, localReadRepair.ToString() },
                { REPLICATE_ON_WRITE, replicateOnWrite.ToString() },
                { GC_GRACE, gcGrace.ToString() },
                { BF_FP_CHANCE, bfFpChance.ToString() },
                { CACHING, caching },
                { COMPACTION_OPTIONS, Utils.ConvertToCqlMap(compactionOptions) },
                { COMPRESSION_PARAMS, Utils.ConvertToCqlMap(compressionParams) }
            };

            StringBuilder sb    = new StringBuilder();
            bool          first = true;

            foreach (var ent in opt)
            {
                if (ent.Value.Contains("{"))
                {
                    sb.Append((first ? "" : " AND ") + ent.Key + " = " + ent.Value);
                }
                else
                {
                    sb.Append((first ? "" : " AND ") + ent.Key + " = '" + ent.Value + "'");
                }
                first = false;
            }
            return(sb.ToString());
        }
Пример #2
0
       public static string GetCreateKeyspaceCQL(string keyspace, Dictionary <string, string> replication, bool durable_writes)
       {
           if (replication == null)
           {
               replication = new Dictionary <string, string> {
                   { "class", ReplicationStrategies.SimpleStrategy }, { "replication_factor", "1" }
               }
           }
           ;
           return(string.Format(
                      @"CREATE KEYSPACE {0} 
 WITH replication = {1} 
  AND durable_writes = {2}"
                      , Cassandra.CqlQueryTools.CqlIdentifier(keyspace), Utils.ConvertToCqlMap(replication), durable_writes ? "true" : "false"));
       }
       public static string GetCreateKeyspaceCql(string keyspace, Dictionary <string, string> replication, bool durableWrites, bool ifNotExists)
       {
           if (replication == null)
           {
               replication = new Dictionary <string, string> {
                   { "class", ReplicationStrategies.SimpleStrategy }, { "replication_factor", "1" }
               }
           }
           ;
           return(string.Format(
                      @"CREATE KEYSPACE {3}{0} 
 WITH replication = {1} 
  AND durable_writes = {2}"
                      , QuoteIdentifier(keyspace), Utils.ConvertToCqlMap(replication), durableWrites ? "true" : "false",
                      ifNotExists ? "IF NOT EXISTS " : ""));
       }