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()); }
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)); }
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, }; }
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 }; }
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()) } }; }
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 }; }