Skip to content

Commit

Permalink
Unit tests passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Aug 28, 2016
1 parent b10227e commit 7f52da2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/indexer/index_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl IndexWriter {
let document_receiver_clone = self.document_receiver.clone();
let target_num_docs = self.target_num_docs;
let join_handle: JoinHandle<()> = thread::spawn(move || {
let mut block_store = BlockStore::allocate(100_000);
let mut block_store = BlockStore::allocate(500_000);
loop {
let segment = index.new_segment();
let segment_id = segment.id();
Expand Down
8 changes: 3 additions & 5 deletions src/postings/block_store.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use compression::NUM_DOCS_PER_BLOCK;

pub const BLOCK_SIZE: u32 = NUM_DOCS_PER_BLOCK as u32;
pub const BLOCK_SIZE: u32 = 64u32;

struct Block {
data: [u32; BLOCK_SIZE as usize],
Expand Down Expand Up @@ -32,7 +30,7 @@ pub struct BlockStore {
impl BlockStore {
pub fn allocate(num_blocks: usize) -> BlockStore {
BlockStore {
lists: Vec::with_capacity(100_000),
lists: Vec::with_capacity(num_blocks),
blocks: (0 .. num_blocks).map(|_| Block::new()).collect(),
free_block_id: 0,
}
Expand Down Expand Up @@ -149,7 +147,7 @@ mod tests {

#[test]
pub fn test_block_store() {
let mut block_store = BlockStore::allocate(1_000);
let mut block_store = BlockStore::allocate(50_000);
let list_2 = block_store.new_list();
let list_3 = block_store.new_list();
let list_4 = block_store.new_list();
Expand Down
2 changes: 1 addition & 1 deletion src/postings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mod tests {
let schema = schema_builder.build();
let index = Index::create_in_ram(schema.clone());
let segment = index.new_segment();
let mut block_store = BlockStore::allocate(1_000);
let mut block_store = BlockStore::allocate(50_000);
{
let mut segment_writer = SegmentWriter::for_segment(&mut block_store, segment.clone(), &schema).unwrap();
{
Expand Down
2 changes: 2 additions & 0 deletions src/postings/postings_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ pub struct SpecializedPostingsWriter<Rec: Recorder + 'static> {

fn get_or_create_recorder<'a, Rec: Recorder>(term: Term, term_index: &'a mut HashMap<Term, Rec>, block_store: &mut BlockStore) -> &'a mut Rec {
if term_index.contains_key(&term) {
println!("recorder here");
term_index.get_mut(&term).unwrap()
}
else {
println!("adding recorder");
let recorder = Rec::new(block_store);
term_index
.entry(term)
Expand Down

0 comments on commit 7f52da2

Please sign in to comment.