1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
//! Prototype streaming library for reading Hadoop sequencefiles
//!
//! # Example
//! ```ignore
//! let path = Path::new("/path/to/seqfile");
//! let file = File::open(&path).unwrap();
//!
//! let seqfile = match sequencefile::Reader::new(file) {
//! Ok(val) => val,
//! Err(err) => panic!("Failed to open sequence file: {}", err),
//! };
//!
//! // Returns a Result<(ByteString, ByteString)>, where a ByteString is a Vec<u8>
//! // An Err from this will signal an unrecoverable error. Next call to Iterator
//! // Returns None
//! for kv in seqfile {
//! println!("{:?}", kv);
//! }
//! ```
#![deny(
missing_docs,
missing_debug_implementations,
missing_copy_implementations,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unstable_features,
unused_import_braces
)]
extern crate byteorder;
extern crate bzip2;
extern crate flate2;
use std::collections::HashMap;
/// Convenience typedef
pub type ByteString = Vec<u8>;
/// Sequencefile header, metadata about the file, e.g. key/value types, version, compression
/// and some internal state for properly decoding
#[derive(Debug)]
pub struct Header {
/// Sequencefile version
/// Version 4 - block compression
/// Version 5 - custom compression codecs
/// Version 6 - metadata
pub version: u16,
/// Type of value compression
pub compression_type: CompressionType,
/// Codec, if any
pub compression_codec: Option<Codec>,
/// Fully-qualified Java class of key Writable
pub key_class: String,
/// Fully-qualified Java class of value Writable
pub value_class: String,
/// K-V metadata on sequencefile
pub metadata: HashMap<String, String>,
sync_marker: ByteString,
}
// modules
mod compress;
mod text;
mod util;
/// Error
pub mod errors;
pub mod reader;
// exports
pub use compress::{Codec, CompressionType};
pub use errors::*;
pub use reader::*;
pub use text::*;
#[cfg(test)]
pub mod tests;