コード例 #1
0
        public int CompareTo(Object obj)
        {
            var target = obj as ColumnValue;

            if (this.Type != target.Type)
            {
                throw new ArgumentException("The type of column to compare must be the same.");
            }

            switch (this.Type)
            {
            case ColumnValueType.String:
                return(string.Compare(this.StringValue, target.StringValue, StringComparison.Ordinal));

            case ColumnValueType.Integer:
                return(this.IntegerValue.CompareTo(target.IntegerValue));

            case ColumnValueType.Binary:
                int ret = OtsUtils.CompareByteArrayInLexOrder(this.BinaryValue, 0, this.BinaryValue.Length, target.BinaryValue, 0, target.BinaryValue.Length);
                return(ret);

            case ColumnValueType.Double:
                return(this.DoubleValue.CompareTo(target.DoubleValue));

            case ColumnValueType.Boolean:
                return(this.BooleanValue.CompareTo(target.BooleanValue));

            default:
                throw new ArgumentException("Unknown type: " + this.Type);
            }
        }
コード例 #2
0
        public void TestFormatDateTimeStr()
        {
            var dt      = DateTime.Parse("2018-04-26T05:12:30");
            var dateStr = OtsUtils.FormatDateTimeStr(dt);

            Assert.AreEqual("2018-04-26T05:12:30.000Z", dateStr);
        }
コード例 #3
0
        public int GetDataSize()
        {
            int dataSize = 0;

            switch (this.Type)
            {
            case ColumnValueType.Integer:
                dataSize = 8;
                break;

            case ColumnValueType.String:

                dataSize = this.StringValue == null ? 0 : OtsUtils.CalcStringSizeInBytes(this.StringValue);
                break;

            case ColumnValueType.Binary:
                dataSize = this.BinaryValue.Length;
                break;

            case ColumnValueType.Double:
                dataSize = 8;
                break;

            case ColumnValueType.Boolean:
                dataSize = 1;
                break;

            default:
                throw new TypeLoadException("Bug: not support the type : " + this.Type);
            }

            return(dataSize);
        }
コード例 #4
0
        public int GetDataSize()
        {
            if (dataSize == -1)
            {
                dataSize = OtsUtils.CalcStringSizeInBytes(Name) + Value.GetDataSize();
            }

            return(dataSize);
        }
コード例 #5
0
 /// <summary>
 /// 获取User-Agent信息。
 /// </summary>
 private static string GetDefaultUserAgent()
 {
     return(UserAgentPrefix +
            typeof(OTSClientConfig).Assembly.GetName().Version + "(" +
            OtsUtils.DetermineOsVersion() + "/" +
            Environment.OSVersion.Version + "/" +
            OtsUtils.DetermineSystemArchitecture() + ";" +
            Environment.Version + ")");
 }
コード例 #6
0
        public new int GetDataSize()
        {
            if (dataSize == -1)
            {
                int size = OtsUtils.CalcStringSizeInBytes(Name) + Value.GetDataSize();
                if (this.Timestamp.HasValue)
                {
                    size += 8;
                }

                dataSize = size;
            }

            return(dataSize);
        }
コード例 #7
0
        /// <summary>
        /// 获取行主键的数据大小总和,大小总和包括所有主键列的名称和值。
        /// </summary>
        /// <returns>行主键的数据大小总和</returns>
        public int GetDataSize()
        {
            if (this.Keys == null)
            {
                return(0);
            }


            int size = 0;

            foreach (var key in this.Keys)
            {
                size += OtsUtils.CalcStringSizeInBytes(key);
                size += this[key].GetDataSize();
            }

            return(size);
        }
コード例 #8
0
 public byte[] GetNameRawData()
 {
     return(OtsUtils.String2Bytes(Name));
 }
 public override string ToString()
 {
     return(OtsUtils.Bytes2UTF8String(this.buffer.GetBuffer()));
 }
コード例 #10
0
 public string ReadUTFString(int size)
 {
     return(OtsUtils.Bytes2UTF8String(ReadBytes(size)));
 }