/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
namespace Avro.File
{
///
/// Defines the interface for an object that reads data from a file.
///
/// Type to serialize data to.
public interface IFileReader : IDisposable
{
///
/// Return the header for the input file or stream.
///
/// Parsed header from the file or stream.
Header GetHeader();
///
/// Return the schema as read from the file or stream.
///
/// Parse schema from the file or stream.
Schema GetSchema();
///
/// Return the list of keys in the metadata.
///
/// Metadata keys from the header of the data file.
ICollection GetMetaKeys();
///
/// Return an enumeration of the remaining entries in the file.
///
/// An enumeration of the remaining entries in the file.
IEnumerable NextEntries { get; }
///
/// Read the next datum from the file.
///
/// Next deserialized data entry.
T Next();
///
/// Returns true if more entries remain in this file.
///
/// True if more entries remain in this file, false otherwise.
bool HasNext();
///
/// Return the byte value of a metadata property.
///
/// Key for the metadata entry.
/// Raw bytes of the value of the metadata entry.
///
/// There is no metadata entry with the specified .
///
byte[] GetMeta(string key);
///
/// Return the long value of a metadata property.
///
/// Key for the metadata entry.
/// Metadata value as a long.
///
/// There is no metadata entry with the specified .
///
long GetMetaLong(string key);
///
/// Return the string value of a metadata property. This method assumes that the string is a
/// UTF-8 encoded in the header.
///
/// Key for the metadata entry.
/// Metadata value as a string.
///
/// There is no metadata entry with the specified .
///
///
/// Encountered an exception while decoding the value as a UTF-8 string.
///
string GetMetaString(string key);
///
/// Return true if past the next synchronization point after a position.
///
/// Position to test.
///
/// True if pasth the next synchronization point after , false
/// otherwise.
///
bool PastSync(long position);
///
/// Return the last synchronization point before our current position.
///
///
/// Position of the last synchronization point before our current position.
///
long PreviousSync();
///
/// Move to a specific, known synchronization point,
/// one returned from while writing.
///
/// Position to jump to.
void Seek(long position);
///
/// Move to the next synchronization point after a position.
///
/// Position in the stream to start.
void Sync(long position);
///
/// Return the current position in the input.
///
/// Current position in the input.
long Tell();
}
}