示例#1
0
        public void CreateFromByteArrayOptimizedTest()
        {
            byte[] data = Enumerable.Range(0, 1000).Select(o => (byte)(o % 256)).ToArray();

            var btArr = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(data);
            Assert.NotNull(btArr);

            Assert.Equal(data, btArr.ToByteArray());
        }
示例#2
0
        public void ExtractByteArrayOptimizedTest(int size)
        {
            byte[] data = Enumerable.Range(0, size).Select(o => (byte)(o % 256)).ToArray();

            Google.Protobuf.ByteString btStr = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(data);
            var extractedArray = ProtoBufByteStringHelper.ExtractByteArrayOptimized(btStr);

            Assert.Equal(data, extractedArray);

            if (ProtoBufByteStringHelper.CanExtractByteArrayOptimized() && ProtoBufByteStringHelper.CanCreateFromByteArrayOptimized() && data.Length >= ProtoBufByteStringHelper.ExtractObjectIndexFromMemoryWithReflectionThreshold)
                Assert.True(object.ReferenceEquals(data, extractedArray));
        }
示例#3
0
 public GetRequest(Qoollo.BobClient.BobKey key, bool fullGet = false)
 {
     Key = new BlobKey
     {
         //Key = ByteString.CopyFrom(key.GetKeyBytes())
         Key = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(key.GetKeyBytes())
     };
     Options = new GetOptions
     {
         Source = fullGet ? GetSource.All : GetSource.Normal,
     };
 }
示例#4
0
        public ExistRequest(IEnumerable <Qoollo.BobClient.BobKey> keys, bool fullGet)
        {
            foreach (var k in keys)
            {
                Keys.Add(new BlobKey()
                {
                    //Key = ByteString.CopyFrom(k.GetKeyBytes())
                    Key = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(k.GetKeyBytes())
                });
            }

            Options = new GetOptions
            {
                Source = fullGet ? GetSource.All : GetSource.Normal
            };
        }
示例#5
0
 public PutRequest(Qoollo.BobClient.BobKey key, byte[] data)
 {
     Key = new BlobKey
     {
         //Key = ByteString.CopyFrom(key.GetKeyBytes())
         Key = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(key.GetKeyBytes())
     };
     Data = new Blob
     {
         //Data = ByteString.CopyFrom(data),
         Data = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(data),
         Meta = new BlobMeta {
             Timestamp = unchecked ((ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds())
         }
     };
 }
示例#6
0
        public ExistRequest(IReadOnlyList <Qoollo.BobClient.BobKey> keys, bool fullGet)
        {
            Keys.Capacity = keys.Count;
            for (int i = 0; i < keys.Count; i++)
            {
                Keys.Add(new BlobKey()
                {
                    //Key = ByteString.CopyFrom(keys[i].GetKeyBytes())
                    Key = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(keys[i].GetKeyBytes())
                });
            }

            Options = new GetOptions
            {
                Source = fullGet ? GetSource.All : GetSource.Normal
            };
        }