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
9 # http://www.apache.org/licenses/LICENSE-2.0
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
18 #' @include arrow-package.R
20 #' @title class arrow::Message
32 Message <- R6Class("Message",
33 inherit = ArrowObject,
35 Equals = function(other, ...) {
36 inherits(other, "Message") && ipc___Message__Equals(self, other)
38 body_length = function() ipc___Message__body_length(self),
39 Verify = function() ipc___Message__Verify(self)
42 type = function() ipc___Message__type(self),
43 metadata = function() ipc___Message__metadata(self),
44 body = function() ipc___Message__body(self)
48 #' @title class arrow::MessageReader
58 #' @rdname MessageReader
59 #' @name MessageReader
61 MessageReader <- R6Class("MessageReader",
62 inherit = ArrowObject,
64 ReadNextMessage = function() ipc___MessageReader__ReadNextMessage(self)
68 MessageReader$create <- function(stream) {
69 if (!inherits(stream, "InputStream")) {
70 stream <- BufferReader$create(stream)
72 ipc___MessageReader__Open(stream)
75 #' Read a Message from a stream
77 #' @param stream an InputStream
80 read_message <- function(stream) {
81 UseMethod("read_message")
85 read_message.default <- function(stream) {
86 read_message(BufferReader$create(stream))
90 read_message.InputStream <- function(stream) {
91 ipc___ReadMessage(stream)
95 read_message.MessageReader <- function(stream) {
96 stream$ReadNextMessage()