]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | # Licensed to the Apache Software Foundation (ASF) under one |
2 | # or more contributor license agreements. See the NOTICE file | |
3 | # distributed with this work for additional information | |
4 | # regarding copyright ownership. The ASF licenses this file | |
5 | # to you under the Apache License, Version 2.0 (the | |
6 | # "License"); you may not use this file except in compliance | |
7 | # with the License. You may obtain a copy of the License at | |
8 | # | |
9 | # http://www.apache.org/licenses/LICENSE-2.0 | |
10 | # | |
11 | # Unless required by applicable law or agreed to in writing, | |
12 | # software distributed under the License is distributed on an | |
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
14 | # KIND, either express or implied. See the License for the | |
15 | # specific language governing permissions and limitations | |
16 | # under the License. | |
17 | ||
18 | #' @include arrow-package.R | |
19 | ||
20 | #' @title class arrow::Message | |
21 | #' | |
22 | #' @usage NULL | |
23 | #' @format NULL | |
24 | #' @docType class | |
25 | #' | |
26 | #' @section Methods: | |
27 | #' | |
28 | #' TODO | |
29 | #' | |
30 | #' @rdname Message | |
31 | #' @name Message | |
32 | Message <- R6Class("Message", | |
33 | inherit = ArrowObject, | |
34 | public = list( | |
35 | Equals = function(other, ...) { | |
36 | inherits(other, "Message") && ipc___Message__Equals(self, other) | |
37 | }, | |
38 | body_length = function() ipc___Message__body_length(self), | |
39 | Verify = function() ipc___Message__Verify(self) | |
40 | ), | |
41 | active = list( | |
42 | type = function() ipc___Message__type(self), | |
43 | metadata = function() ipc___Message__metadata(self), | |
44 | body = function() ipc___Message__body(self) | |
45 | ) | |
46 | ) | |
47 | ||
48 | #' @title class arrow::MessageReader | |
49 | #' | |
50 | #' @usage NULL | |
51 | #' @format NULL | |
52 | #' @docType class | |
53 | #' | |
54 | #' @section Methods: | |
55 | #' | |
56 | #' TODO | |
57 | #' | |
58 | #' @rdname MessageReader | |
59 | #' @name MessageReader | |
60 | #' @export | |
61 | MessageReader <- R6Class("MessageReader", | |
62 | inherit = ArrowObject, | |
63 | public = list( | |
64 | ReadNextMessage = function() ipc___MessageReader__ReadNextMessage(self) | |
65 | ) | |
66 | ) | |
67 | ||
68 | MessageReader$create <- function(stream) { | |
69 | if (!inherits(stream, "InputStream")) { | |
70 | stream <- BufferReader$create(stream) | |
71 | } | |
72 | ipc___MessageReader__Open(stream) | |
73 | } | |
74 | ||
75 | #' Read a Message from a stream | |
76 | #' | |
77 | #' @param stream an InputStream | |
78 | #' | |
79 | #' @export | |
80 | read_message <- function(stream) { | |
81 | UseMethod("read_message") | |
82 | } | |
83 | ||
84 | #' @export | |
85 | read_message.default <- function(stream) { | |
86 | read_message(BufferReader$create(stream)) | |
87 | } | |
88 | ||
89 | #' @export | |
90 | read_message.InputStream <- function(stream) { | |
91 | ipc___ReadMessage(stream) | |
92 | } | |
93 | ||
94 | #' @export | |
95 | read_message.MessageReader <- function(stream) { | |
96 | stream$ReadNextMessage() | |
97 | } |