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); } }
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); }
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); }
public int GetDataSize() { if (dataSize == -1) { dataSize = OtsUtils.CalcStringSizeInBytes(Name) + Value.GetDataSize(); } return(dataSize); }
/// <summary> /// 获取User-Agent信息。 /// </summary> private static string GetDefaultUserAgent() { return(UserAgentPrefix + typeof(OTSClientConfig).Assembly.GetName().Version + "(" + OtsUtils.DetermineOsVersion() + "/" + Environment.OSVersion.Version + "/" + OtsUtils.DetermineSystemArchitecture() + ";" + Environment.Version + ")"); }
public new int GetDataSize() { if (dataSize == -1) { int size = OtsUtils.CalcStringSizeInBytes(Name) + Value.GetDataSize(); if (this.Timestamp.HasValue) { size += 8; } dataSize = size; } return(dataSize); }
/// <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); }
public byte[] GetNameRawData() { return(OtsUtils.String2Bytes(Name)); }
public override string ToString() { return(OtsUtils.Bytes2UTF8String(this.buffer.GetBuffer())); }
public string ReadUTFString(int size) { return(OtsUtils.Bytes2UTF8String(ReadBytes(size))); }