예제 #1
0
        public void TestBinaryRoundTrip()
        {
            // arrange
            var lines = new[]
            {
                $"list_{nameof(TestBinaryRoundTrip)} <- list(ints = c(1,2,3), nums = c(1.0, 2.0, 3.), alpha = c(\"a\",\"b\",\"c\"))",
                $"copy_of_list_{nameof(TestBinaryRoundTrip)} <- list_{nameof(TestBinaryRoundTrip)}"
            };

            // act
            ROpsApi.SourceLines(lines);
            var bytes = ROpsApi.SaveObjectToBinary($"list_{nameof(TestBinaryRoundTrip)}");

            ROpsApi.EvaluateNonQuery($"rm(list_{nameof(TestBinaryRoundTrip)})");
            ROpsApi.LoadFromBinary(bytes);
            var evaluated = ROpsApi.Evaluate($"all.equal(copy_of_list_{nameof(TestBinaryRoundTrip)}, list_{nameof(TestBinaryRoundTrip)})");

            // assert
            Assert.IsNotNull(evaluated.First().Value);
            Assert.IsTrue(evaluated.First().Value !.First().Resolve(out bool allEqual) && allEqual);
        }
예제 #2
0
        public override async Task <LoadFromBinaryReply> LoadFromBinary(LoadFromBinaryRequest request, ServerCallContext context)
        {
            await _semaphoreSlim.WaitAsync();

            var reply = new LoadFromBinaryReply();

            try
            {
                ROpsApi.LoadFromBinary(request.Raw.ToArray());

                reply.Payload = new LoadFromBinaryPayload();
            }
            catch (Exception ex)
            {
                reply.Error = PopulateError(ex);
                _logger.LogError(ex, nameof(LoadFromBinary));
            }
            finally
            {
                _semaphoreSlim.Release();
            }

            return(await Task.FromResult(reply));
        }