ZlibCompress() public static method

public static ZlibCompress ( byte data ) : byte[]
data byte
return byte[]
Esempio n. 1
0
        public override Void Execute()
        {
            Debug.Write(CqlQuery.ToString(), "query");
            byte[] query = CqlQuery;
            bool   isCqlQueryCompressed = query.Length > 200 && Session.ConnectionBuilder.CompressCqlQueries;

            // it doesn't make sense to compress queryies that are really small
            if (isCqlQueryCompressed)
            {
                query = Helper.ZlibCompress(query);
            }

            var result = Session.GetClient().execute_cql_query(
                query,
                isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE
                );

            return(new Void());
        }
        public override IEnumerable <ICqlRow> Execute()
        {
            Debug.Write(CqlQuery.ToString(), "query");

            byte[] query = CqlQuery;
            bool   isCqlQueryCompressed = query.Length > 200 && Session.ConnectionBuilder.CompressCqlQueries;

            // it doesn't make sense to compress queries that are really small
            if (isCqlQueryCompressed)
            {
                query = Helper.ZlibCompress(query);
            }

            if (CqlVersion == null)
            {
                CqlVersion = Session.ConnectionBuilder.CqlVersion;
            }

            var client = Session.GetClient();
            var result = (CqlResult)null;

            if (CqlVersion == FluentCassandra.Connections.CqlVersion.Cql || client.describe_version() < RpcApiVersion.Cassandra120)
            {
                result = client.execute_cql_query(
                    query,
                    isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE);
            }
            else if (CqlVersion == FluentCassandra.Connections.CqlVersion.Cql3)
            {
                result = client.execute_cql3_query(
                    query,
                    isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE,
                    Session.ReadConsistency);
            }
            else
            {
                throw new FluentCassandraException(CqlVersion + " is not a valid CQL version.");
            }

            return(GetRows(result));
        }