<commit_before>//! MemTable is a in-memory table representation.
//!
//! MemTable is designed to be used to contain the result or for fastest processing. 

use rustc_serialize::Decodable;

use session::Session;
use err::{Result, Void, void_ok};
use rows::*;
use types::Ty;

pub struct MemTable
{
	types      : Vec<Ty>,
	field_names: Vec<String>,
	
	pages      : Vec<Page>,
	row_num    : usize
}

impl MemTable
{
	pub fn new(session: &Session, types: &Vec<Ty>, fields_name: &Vec<&str>) -> MemTable
	{
		MemTable {
			types      : types.clone(),
			field_names: ::util::str::to_owned_vec(fields_name),
			pages      : Vec::new(),
			row_num    : 0
		}
	} 
}

pub struct DecodedRecords<'a, D>
{
	pages: &'a Vec<Page>,
	marker: ::std::marker::PhantomData<D>,
}

impl<'a, D> Iterator for DecodedRecords<'a, D> where D: Decodable {
  type Item = Result<D>;
  
  fn next(&mut self) -> Option<Result<D>> {
  	unimplemented!()
  }
}

impl MemTable 
{
	pub fn row_num(&self) -> usize
	{
		self.row_num
	}
	
	pub fn col_num(&self) -> usize
	{
		self.types.len()
	}
	
	pub fn types(&self) -> &Vec<Ty>
	{
		&self.types
	}
	
	pub fn field_names(&self) -> &Vec<String>
	{
		&self.field_names
	}
	
	pub fn reader<'a, D: Decodable>(&'a self) -> DecodedRecords<'a, D> 
	{
		DecodedRecords {
			pages: &self.pages,
			marker: ::std::marker::PhantomData
		}
	}<commit_msg>Add type schema to DecodeRecords.<commit_after>//! MemTable is a in-memory table representation.
//!
//! MemTable is designed to be used to contain the result or for fastest processing. 

use rustc_serialize::Decodable;

use session::Session;
use err::{Result, Void, void_ok};
use rows::*;
use types::Ty;

pub struct MemTable
{
	types      : Vec<Ty>,
	field_names: Vec<String>,
	
	pages      : Vec<Page>,
	row_num    : usize
}

impl MemTable
{
	pub fn new(session: &Session, types: &Vec<Ty>, fields_name: &Vec<&str>) -> MemTable
	{
		MemTable {
			types      : types.clone(),
			field_names: ::util::str::to_owned_vec(fields_name),
			pages      : Vec::new(),
			row_num    : 0
		}
	} 
}

pub struct DecodedRecords<'a, D>
{
	pages: &'a Vec<Page>,
	types: &'a Vec<Ty>,
	marker: ::std::marker::PhantomData<D>,
}

impl<'a, D> Iterator for DecodedRecords<'a, D> where D: Decodable {
  type Item = Result<D>;
  
  fn next(&mut self) -> Option<Result<D>> {
  	unimplemented!()
  }
}

impl MemTable 
{
	pub fn row_num(&self) -> usize
	{
		self.row_num
	}
	
	pub fn col_num(&self) -> usize
	{
		self.types.len()
	}
	
	pub fn types(&self) -> &Vec<Ty>
	{
		&self.types
	}
	
	pub fn field_names(&self) -> &Vec<String>
	{
		&self.field_names
	}
	
	pub fn reader<'a, D: Decodable>(&'a self) -> DecodedRecords<'a, D> 
	{
		DecodedRecords {
			pages: &self.pages,
			types: &self.types,
			marker: ::std::marker::PhantomData
		}
	}
{'fraction_non_alphanumeric': 0.1629335260115607, 'fraction_numerical': 0.000722543352601156, 'mean_word_length': 3.395238095238095, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4181641', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1075, 'n_words': 259}