Mailing List Archive

r3746 - in trunk: boilerplater/lib/Boilerplater c_src/KinoSearch c_src/KinoSearch/Index c_src/KinoSearch/Search c_src/KinoSearch/Store c_src/KinoSearch/Util perl perl/lib perl/lib/KinoSearch/Util perl/t
Author: creamyg
Date: 2008-08-22 18:33:24 -0700 (Fri, 22 Aug 2008)
New Revision: 3746

Added:
trunk/c_src/KinoSearch/Util/I32Array.bp
trunk/c_src/KinoSearch/Util/I32Array.c
trunk/perl/lib/KinoSearch/Util/I32Array.pm
Removed:
trunk/c_src/KinoSearch/Util/IntMap.bp
trunk/c_src/KinoSearch/Util/IntMap.c
trunk/perl/lib/KinoSearch/Util/IntMap.pm
Modified:
trunk/boilerplater/lib/Boilerplater/Class.pm
trunk/boilerplater/lib/Boilerplater/Parser.pm
trunk/c_src/KinoSearch/Index/DelDocs.bp
trunk/c_src/KinoSearch/Index/DelDocs.c
trunk/c_src/KinoSearch/Index/DocVector.c
trunk/c_src/KinoSearch/Index/DocWriter.bp
trunk/c_src/KinoSearch/Index/DocWriter.c
trunk/c_src/KinoSearch/Index/IndexReader.bp
trunk/c_src/KinoSearch/Index/IndexReader.c
trunk/c_src/KinoSearch/Index/LexWriter.c
trunk/c_src/KinoSearch/Index/Lexicon.bp
trunk/c_src/KinoSearch/Index/Lexicon.c
trunk/c_src/KinoSearch/Index/MultiLexicon.bp
trunk/c_src/KinoSearch/Index/MultiLexicon.c
trunk/c_src/KinoSearch/Index/MultiPostingList.bp
trunk/c_src/KinoSearch/Index/MultiPostingList.c
trunk/c_src/KinoSearch/Index/MultiReader.bp
trunk/c_src/KinoSearch/Index/MultiReader.c
trunk/c_src/KinoSearch/Index/PostingPool.bp
trunk/c_src/KinoSearch/Index/PostingPool.c
trunk/c_src/KinoSearch/Index/PostingPoolQueue.c
trunk/c_src/KinoSearch/Index/PostingsWriter.bp
trunk/c_src/KinoSearch/Index/PostingsWriter.c
trunk/c_src/KinoSearch/Index/SegDataWriter.bp
trunk/c_src/KinoSearch/Index/SegDataWriter.c
trunk/c_src/KinoSearch/Index/SegInfo.c
trunk/c_src/KinoSearch/Index/SegLexicon.bp
trunk/c_src/KinoSearch/Index/SegLexicon.c
trunk/c_src/KinoSearch/Index/SegReader.bp
trunk/c_src/KinoSearch/Index/SegReader.c
trunk/c_src/KinoSearch/Index/SegWriter.bp
trunk/c_src/KinoSearch/Index/SegWriter.c
trunk/c_src/KinoSearch/Index/TermVector.bp
trunk/c_src/KinoSearch/Index/TermVector.c
trunk/c_src/KinoSearch/Index/TermVectorsReader.c
trunk/c_src/KinoSearch/Index/TermVectorsWriter.bp
trunk/c_src/KinoSearch/Index/TermVectorsWriter.c
trunk/c_src/KinoSearch/Search/FieldDocCollator.bp
trunk/c_src/KinoSearch/Search/FieldDocCollator.c
trunk/c_src/KinoSearch/Search/HitCollector.c
trunk/c_src/KinoSearch/Search/MultiSearcher.bp
trunk/c_src/KinoSearch/Search/MultiSearcher.c
trunk/c_src/KinoSearch/Search/PhraseQuery.c
trunk/c_src/KinoSearch/Search/RangeQuery.c
trunk/c_src/KinoSearch/Search/RangeScorer.bp
trunk/c_src/KinoSearch/Search/RangeScorer.c
trunk/c_src/KinoSearch/Search/Scorer.bp
trunk/c_src/KinoSearch/Search/Scorer.c
trunk/c_src/KinoSearch/Search/SortSpec.c
trunk/c_src/KinoSearch/Search/TermQuery.c
trunk/c_src/KinoSearch/Search/TopDocs.c
trunk/c_src/KinoSearch/Searcher.c
trunk/c_src/KinoSearch/Store/CompoundFileWriter.c
trunk/c_src/KinoSearch/Util/BitVector.bp
trunk/c_src/KinoSearch/Util/BitVector.c
trunk/perl/MANIFEST
trunk/perl/META.yml
trunk/perl/lib/KinoSearch.pm
trunk/perl/t/217-multi_lexicon.t
trunk/perl/t/513-scorer.t
trunk/perl/t/520-score_doc.t
Log:
Rename IntMap to I32Array, since with the new behavior of Get() it's more like
an array than a mapping.


Modified: trunk/boilerplater/lib/Boilerplater/Class.pm
===================================================================
--- trunk/boilerplater/lib/Boilerplater/Class.pm 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/boilerplater/lib/Boilerplater/Class.pm 2008-08-23 01:33:24 UTC (rev 3746)
@@ -57,7 +57,8 @@

# Verify class name, derive struct name and possibly cnick as well.
confess("Invalid class name")
- unless $self->{class_name} =~ /^([A-Z][A-Za-z]*)(::[A-Z][A-Za-z]*)*$/;
+ unless $self->{class_name}
+ =~ /^([A-Z][A-Za-z0-9]*)(::[A-Z][A-Za-z0-9]*)*$/;
$self->{class_name} =~ /(\w+)$/;
$self->{struct_name} = $1;
$self->{cnick} = $1 unless defined $self->{cnick};

Modified: trunk/boilerplater/lib/Boilerplater/Parser.pm
===================================================================
--- trunk/boilerplater/lib/Boilerplater/Parser.pm 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/boilerplater/lib/Boilerplater/Parser.pm 2008-08-23 01:33:24 UTC (rev 3746)
@@ -161,7 +161,7 @@
{ "[$item[2]]" }

object_type_specifier:
- /[A-Z][A-Za-z]+(?!\w)/
+ /[A-Z][A-Za-z0-9]+(?!\w)/

constant_expression:
/\d+/

Modified: trunk/c_src/KinoSearch/Index/DelDocs.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/DelDocs.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/DelDocs.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -46,7 +46,7 @@
* With an offset of 1000, the array in the previous example would be
* { 1001, 0, 1002, 1003 }.
*/
- incremented IntMap*
+ incremented I32Array*
Generate_Doc_Map(DelDocs *self, i32_t offset);

/** Delete all the documents represented by a PostingList.

Modified: trunk/c_src/KinoSearch/Index/DelDocs.c
===================================================================
--- trunk/c_src/KinoSearch/Index/DelDocs.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/DelDocs.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -7,7 +7,7 @@
#include "KinoSearch/Index/IndexFileNames.h"
#include "KinoSearch/Index/SegInfo.h"
#include "KinoSearch/Index/PostingList.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Store/Folder.h"
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Store/OutStream.h"
@@ -119,7 +119,7 @@
REFCOUNT_DEC(metadata);
}

-IntMap*
+I32Array*
DelDocs_generate_doc_map(DelDocs *self, i32_t offset)
{
i32_t max = self->seg_info->doc_count;
@@ -133,7 +133,7 @@
doc_map[i] = offset + new_doc_num++;
}

- return IntMap_new_steal(doc_map, max + 1);
+ return I32Arr_new_steal(doc_map, max + 1);
}

void

Modified: trunk/c_src/KinoSearch/Index/DocVector.c
===================================================================
--- trunk/c_src/KinoSearch/Index/DocVector.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/DocVector.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -5,7 +5,7 @@
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Store/OutStream.h"
#include "KinoSearch/Util/ByteBuf.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/MathUtils.h"

/* Extract a document's compressed TermVector data into ( term_text =>
@@ -184,9 +184,9 @@
CONFESS("Bad encoding of posdata");
}
else {
- IntMap *posits_map = IntMap_new_steal(positions, num_pos);
- IntMap *starts_map = IntMap_new_steal(starts, num_pos);
- IntMap *ends_map = IntMap_new_steal(ends, num_pos);
+ I32Array *posits_map = I32Arr_new_steal(positions, num_pos);
+ I32Array *starts_map = I32Arr_new_steal(starts, num_pos);
+ I32Array *ends_map = I32Arr_new_steal(ends, num_pos);
retval = TV_new(field, term_text, posits_map, starts_map, ends_map);
REFCOUNT_DEC(posits_map);
REFCOUNT_DEC(starts_map);

Modified: trunk/c_src/KinoSearch/Index/DocWriter.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/DocWriter.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/DocWriter.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -24,7 +24,7 @@
Add(DocWriter *self, Inverter *inverter, u32_t doc_num);

void
- Add_Segment(DocWriter *self, SegReader *reader, IntMap *doc_map = NULL);
+ Add_Segment(DocWriter *self, SegReader *reader, I32Array *doc_map = NULL);

void
Finish(DocWriter *self);

Modified: trunk/c_src/KinoSearch/Index/DocWriter.c
===================================================================
--- trunk/c_src/KinoSearch/Index/DocWriter.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/DocWriter.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -13,7 +13,7 @@
#include "KinoSearch/Store/Folder.h"
#include "KinoSearch/Store/OutStream.h"
#include "KinoSearch/Util/ByteBuf.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Native.h"

DocWriter*
@@ -96,7 +96,7 @@
}

void
-DocWriter_add_segment(DocWriter *self, SegReader *reader, IntMap *doc_map)
+DocWriter_add_segment(DocWriter *self, SegReader *reader, I32Array *doc_map)
{
OutStream *const ds_out = self->ds_out;
OutStream *const dsx_out = self->dsx_out;
@@ -105,7 +105,7 @@
u32_t orig, max;

for (orig = 1, max = SegReader_Max_Docs(reader); orig <= max; orig++) {
- if (IntMap_Get(doc_map, orig)) {
+ if (I32Arr_Get(doc_map, orig)) {
u64_t start = OutStream_Tell(ds_out);

/* Copy record over. */

Modified: trunk/c_src/KinoSearch/Index/IndexReader.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/IndexReader.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/IndexReader.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -132,15 +132,15 @@
abstract incremented DocVector*
Fetch_Doc_Vec(IndexReader *self, u32_t doc_num);

- /** Return an IntMap sort cache for the given field.
+ /** Return an I32Array sort cache for the given field.
*/
- IntMap*
+ I32Array*
Fetch_Sort_Cache(IndexReader *self, const CharBuf *field);

- /** Return an IntMap with one entry for each segment, corresponding to
+ /** Return an I32Array with one entry for each segment, corresponding to
* segment doc_num start offset.
*/
- abstract incremented IntMap*
+ abstract incremented I32Array*
Seg_Starts(IndexReader *self);

/** Return an array of all the SegReaders represented within the

Modified: trunk/c_src/KinoSearch/Index/IndexReader.c
===================================================================
--- trunk/c_src/KinoSearch/Index/IndexReader.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/IndexReader.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -17,7 +17,7 @@
#include "KinoSearch/Store/LockFactory.h"
#include "KinoSearch/Store/Lock.h"
#include "KinoSearch/Store/SharedLock.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Native.h"

static IndexReader*
@@ -212,10 +212,10 @@
return true_self;
}

-IntMap*
+I32Array*
IxReader_fetch_sort_cache(IndexReader *self, const CharBuf *field_name)
{
- IntMap *sort_cache = (IntMap*)Hash_Fetch(self->sort_caches, field_name);
+ I32Array *sort_cache = (I32Array*)Hash_Fetch(self->sort_caches, field_name);

if (sort_cache == NULL) {
FieldSpec *fspec;
@@ -242,8 +242,8 @@
REFCOUNT_DEC(plist);
}
else {
- /* Use an empty IntMap if this field has no values. */
- sort_cache = IntMap_new(NULL, 0);
+ /* Use an empty I32Array if this field has no values. */
+ sort_cache = I32Arr_new(NULL, 0);
}

/* Cache the sort cache. */

Modified: trunk/c_src/KinoSearch/Index/LexWriter.c
===================================================================
--- trunk/c_src/KinoSearch/Index/LexWriter.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/LexWriter.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -9,7 +9,7 @@
#include "KinoSearch/Index/TermInfo.h"
#include "KinoSearch/Store/Folder.h"
#include "KinoSearch/Store/OutStream.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

LexWriter*
LexWriter_new(InvIndex *invindex, SegInfo *seg_info, i32_t is_index)

Modified: trunk/c_src/KinoSearch/Index/Lexicon.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/Lexicon.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/Lexicon.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -60,11 +60,11 @@
abstract Obj*
Get_Term(Lexicon *self);

- /** Build an IntMap mapping from doc number to term number.
+ /** Build an I32Array mapping from doc number to term number.
*
* Calling this method leaves the iterator in an invalid state.
*/
- abstract incremented IntMap*
+ abstract incremented I32Array*
Build_Sort_Cache(Lexicon *self, PostingList *posting_list, u32_t max_docs);

/** Pretend the Lexicon is an array and seek the iterator to Term at index

Modified: trunk/c_src/KinoSearch/Index/Lexicon.c
===================================================================
--- trunk/c_src/KinoSearch/Index/Lexicon.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/Lexicon.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -2,7 +2,7 @@
#include "KinoSearch/Util/ToolSet.h"

#include "KinoSearch/Index/Lexicon.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Native.h"
#include "KinoSearch/Util/Carp.h"


Modified: trunk/c_src/KinoSearch/Index/MultiLexicon.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/MultiLexicon.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/MultiLexicon.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -45,7 +45,7 @@
Obj*
Get_Term(MultiLexicon *self);

- incremented IntMap*
+ incremented I32Array*
Build_Sort_Cache(MultiLexicon *self, PostingList *posting_list,
u32_t max_docs);


Modified: trunk/c_src/KinoSearch/Index/MultiLexicon.c
===================================================================
--- trunk/c_src/KinoSearch/Index/MultiLexicon.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/MultiLexicon.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -6,7 +6,7 @@
#include "KinoSearch/Index/SegReader.h"
#include "KinoSearch/Index/LexCache.h"
#include "KinoSearch/Util/PriorityQueue.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

/* Empty out, then refill the Queue, seeking all elements to [target]. */
static void
@@ -157,7 +157,7 @@
return true;
}

-IntMap*
+I32Array*
MultiLex_build_sort_cache(MultiLexicon *self, PostingList *plist,
u32_t max_docs)
{
@@ -211,7 +211,7 @@
REFCOUNT_DEC(term_texts);
REFCOUNT_DEC(last_term_text);

- return IntMap_new_steal(ints, max_docs + 1);
+ return I32Arr_new_steal(ints, max_docs + 1);
}

void

Modified: trunk/c_src/KinoSearch/Index/MultiPostingList.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/MultiPostingList.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/MultiPostingList.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -15,11 +15,11 @@
/* Constructors.
*/
static incremented MultiPostingList*
- new(const CharBuf *field, VArray *sub_readers, IntMap *starts);
+ new(const CharBuf *field, VArray *sub_readers, I32Array *starts);

static MultiPostingList*
init(MultiPostingList *self, const CharBuf *field, VArray *sub_readers,
- IntMap *starts);
+ I32Array *starts);

void
Destroy(MultiPostingList *self);

Modified: trunk/c_src/KinoSearch/Index/MultiPostingList.c
===================================================================
--- trunk/c_src/KinoSearch/Index/MultiPostingList.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/MultiPostingList.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -4,10 +4,10 @@
#include "KinoSearch/Posting.h"
#include "KinoSearch/Index/SegReader.h"
#include "KinoSearch/Index/SegPostingList.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

MultiPostingList*
-MultiPList_new(const CharBuf *field, VArray *sub_readers, IntMap *starts)
+MultiPList_new(const CharBuf *field, VArray *sub_readers, I32Array *starts)
{
MultiPostingList *self
= (MultiPostingList*)CREATE(NULL, MULTIPOSTINGLIST);
@@ -16,7 +16,7 @@

MultiPostingList*
MultiPList_init(MultiPostingList *self, const CharBuf *field,
- VArray *sub_readers, IntMap *starts)
+ VArray *sub_readers, I32Array *starts)
{
u32_t i;

@@ -32,7 +32,7 @@
for (i = 0; i < sub_readers->size; i++) {
SegReader *const seg_reader
= (SegReader*)VA_Fetch(sub_readers, i);
- i32_t offset = IntMap_Get(starts, i);
+ i32_t offset = I32Arr_Get(starts, i);
PostingList *sub_plist
= SegReader_Posting_List(seg_reader, field, NULL);
if (sub_plist) {

Modified: trunk/c_src/KinoSearch/Index/MultiReader.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/MultiReader.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/MultiReader.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -7,7 +7,7 @@

VArray *sub_readers;
u32_t max_docs;
- IntMap *starts;
+ I32Array *starts;

static incremented MultiReader*
new(InvIndex *invindex, Snapshot *snapshot = NULL,
@@ -57,7 +57,7 @@
incremented DocVector*
Fetch_Doc_Vec(MultiReader *self, u32_t doc_num);

- incremented IntMap*
+ incremented I32Array*
Seg_Starts(MultiReader *self);

incremented VArray*

Modified: trunk/c_src/KinoSearch/Index/MultiReader.c
===================================================================
--- trunk/c_src/KinoSearch/Index/MultiReader.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/MultiReader.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -13,7 +13,7 @@
#include "KinoSearch/Index/SegReader.h"
#include "KinoSearch/Index/Snapshot.h"
#include "KinoSearch/Store/LockFactory.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Native.h"

MultiReader*
@@ -42,7 +42,7 @@
starts[i] = self->max_docs;
self->max_docs += SegReader_Max_Docs(seg_reader);
}
- self->starts = IntMap_new_steal(starts, sub_readers->size);
+ self->starts = I32Arr_new_steal(starts, sub_readers->size);
return self;
}

@@ -102,7 +102,7 @@
{
u32_t tick = MultiReader_sub_reader_tick(self, doc_num);
SegReader *sub_reader = (SegReader*)VA_Fetch(self->sub_readers, tick);
- u32_t offset = IntMap_Get(self->starts, tick);
+ u32_t offset = I32Arr_Get(self->starts, tick);
doc_num -= offset;
return SegReader_Is_Deleted(sub_reader, doc_num);
}
@@ -168,7 +168,7 @@
{
u32_t tick = MultiReader_sub_reader_tick(self, doc_num);
SegReader *sub_reader = (SegReader*)VA_Fetch(self->sub_readers, tick);
- u32_t offset = IntMap_Get(self->starts, tick);
+ u32_t offset = I32Arr_Get(self->starts, tick);
HitDoc *doc = SegReader_Fetch_Doc(sub_reader, doc_num - offset);
HitDoc_Set_Doc_Num(doc, doc_num);
return doc;
@@ -179,12 +179,12 @@
{
u32_t tick = MultiReader_sub_reader_tick(self, doc_num);
SegReader *sub_reader = (SegReader*)VA_Fetch(self->sub_readers, tick);
- u32_t offset = IntMap_Get(self->starts, tick);
+ u32_t offset = I32Arr_Get(self->starts, tick);
doc_num -= offset;
return SegReader_Fetch_Doc_Vec(sub_reader, doc_num);
}

-IntMap*
+I32Array*
MultiReader_seg_starts(MultiReader *self)
{
return REFCOUNT_INC(self->starts);
@@ -199,16 +199,16 @@
u32_t
MultiReader_sub_reader_tick(MultiReader *self, u32_t doc_num)
{
- IntMap *const starts = self->starts;
+ I32Array *const starts = self->starts;
u32_t lo = 0;
u32_t mid;
- u32_t hi_tick = IntMap_Get_Size(starts) - 1;
+ u32_t hi_tick = I32Arr_Get_Size(starts) - 1;
u32_t hi = hi_tick;

while (hi >= lo) {
u32_t mid_start;
mid = (lo + hi) >> 1;
- mid_start = (u32_t)IntMap_Get(starts, mid) + 1;
+ mid_start = (u32_t)I32Arr_Get(starts, mid) + 1;
if (doc_num < mid_start) {
hi = mid - 1;
}
@@ -217,7 +217,7 @@
}
else {
while ( mid < hi_tick
- && IntMap_Get(starts, mid + 1) == (i32_t)mid_start
+ && I32Arr_Get(starts, mid + 1) == (i32_t)mid_start
) {
mid++;
}

Modified: trunk/c_src/KinoSearch/Index/PostingPool.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/PostingPool.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/PostingPool.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -11,7 +11,7 @@
MemoryPool *mem_pool;
InStream *lex_instream;
InStream *post_instream;
- IntMap *doc_map;
+ I32Array *doc_map;
Obj **scratch;
u32_t scratch_cap;
u64_t lex_start;
@@ -52,7 +52,7 @@
void
Assign_Seg(PostingPool *self, Folder *other_folder,
SegInfo *other_seg_info, u32_t doc_base,
- IntMap *doc_map = NULL);
+ I32Array *doc_map = NULL);

/* Iterate through postings currently in RAM. Used when flushing cache to
* disk.

Modified: trunk/c_src/KinoSearch/Index/PostingPool.c
===================================================================
--- trunk/c_src/KinoSearch/Index/PostingPool.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/PostingPool.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -13,7 +13,7 @@
#include "KinoSearch/Store/Folder.h"
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Util/MemoryPool.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

/* Constructor.
*/
@@ -114,7 +114,7 @@

void
PostPool_assign_seg(PostingPool *self, Folder *other_folder,
- SegInfo *other_seg_info, u32_t doc_base, IntMap *doc_map)
+ SegInfo *other_seg_info, u32_t doc_base, I32Array *doc_map)
{
CharBuf *lex_filename;
i32_t field_num = SegInfo_Field_Num(other_seg_info, self->field_name);
@@ -213,7 +213,7 @@
Posting *const main_posting = self->posting;
InStream *const lex_instream = self->lex_instream;
InStream *const post_instream = self->post_instream;
- IntMap *const doc_map = self->doc_map;
+ I32Array *const doc_map = self->doc_map;
const u32_t mem_thresh = self->mem_thresh;
const u32_t doc_base = self->doc_base;
const u64_t lex_end = self->lex_end;
@@ -282,7 +282,7 @@

/* Skip deletions. */
if (doc_map != NULL) {
- const i32_t remapped = IntMap_Get(doc_map,
+ const i32_t remapped = I32Arr_Get(doc_map,
raw_posting->doc_num - doc_base);
if ( !remapped )
continue;

Modified: trunk/c_src/KinoSearch/Index/PostingPoolQueue.c
===================================================================
--- trunk/c_src/KinoSearch/Index/PostingPoolQueue.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/PostingPoolQueue.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -4,7 +4,7 @@
#include "KinoSearch/Index/PostingPool.h"
#include "KinoSearch/Posting/RawPosting.h"
#include "KinoSearch/Store/InStream.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

#define DOESNT_MATTER 1024


Modified: trunk/c_src/KinoSearch/Index/PostingsWriter.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/PostingsWriter.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/PostingsWriter.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -42,7 +42,7 @@

void
Add_Segment(PostingsWriter *self, SegReader *reader,
- IntMap *doc_map = NULL);
+ I32Array *doc_map = NULL);

void
Finish(PostingsWriter *self);

Modified: trunk/c_src/KinoSearch/Index/PostingsWriter.c
===================================================================
--- trunk/c_src/KinoSearch/Index/PostingsWriter.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/PostingsWriter.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -21,7 +21,7 @@
#include "KinoSearch/Store/Folder.h"
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Store/OutStream.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/MemoryPool.h"

/* Initialize a PostingPool for this field. If this is the field's first
@@ -393,7 +393,7 @@

void
PostWriter_add_segment(PostingsWriter *self, SegReader *reader,
- IntMap *doc_map)
+ I32Array *doc_map)
{
Folder *other_folder = SegReader_Get_Folder(reader);
SegInfo *other_seg_info = reader->seg_info;

Modified: trunk/c_src/KinoSearch/Index/SegDataWriter.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/SegDataWriter.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/SegDataWriter.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -85,7 +85,7 @@
*/
abstract void
Add_Segment(SegDataWriter *self, SegReader *reader,
- IntMap *doc_map = NULL);
+ I32Array *doc_map = NULL);

/* Complete the segment and close all streams. If [doc_map] is defined,
* then the documents must be renumbered.

Modified: trunk/c_src/KinoSearch/Index/SegDataWriter.c
===================================================================
--- trunk/c_src/KinoSearch/Index/SegDataWriter.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/SegDataWriter.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -5,7 +5,7 @@
#include "KinoSearch/Store/Folder.h"
#include "KinoSearch/InvIndex.h"
#include "KinoSearch/Index/SegInfo.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Native.h"

SegDataWriter*

Modified: trunk/c_src/KinoSearch/Index/SegInfo.c
===================================================================
--- trunk/c_src/KinoSearch/Index/SegInfo.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/SegInfo.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -2,7 +2,7 @@

#include "KinoSearch/Index/SegInfo.h"
#include "KinoSearch/Index/IndexFileNames.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

SegInfo*
SegInfo_new(const CharBuf *seg_name, Hash *fspecs, Hash *source_metadata)

Modified: trunk/c_src/KinoSearch/Index/SegLexicon.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/SegLexicon.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/SegLexicon.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -63,7 +63,7 @@
i32_t
Get_Size(SegLexicon *self);

- incremented IntMap*
+ incremented I32Array*
Build_Sort_Cache(SegLexicon *self, PostingList *posting_list,
u32_t max_docs);


Modified: trunk/c_src/KinoSearch/Index/SegLexicon.c
===================================================================
--- trunk/c_src/KinoSearch/Index/SegLexicon.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/SegLexicon.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -11,7 +11,7 @@
#include "KinoSearch/Index/SegLexCache.h"
#include "KinoSearch/Store/Folder.h"
#include "KinoSearch/Store/InStream.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

/* Iterate until the state is greater than or equal to the target.
*/
@@ -215,7 +215,7 @@
} while (SegLex_Next(self));
}

-IntMap*
+I32Array*
SegLex_build_sort_cache(SegLexicon *self, PostingList *plist, u32_t max_docs)
{
i32_t *ints = MALLOCATE(max_docs + 1, i32_t);
@@ -238,7 +238,7 @@
term_num++;
}

- return IntMap_new_steal(ints, max_docs + 1);
+ return I32Arr_new_steal(ints, max_docs + 1);
}

void

Modified: trunk/c_src/KinoSearch/Index/SegReader.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/SegReader.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/SegReader.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -59,7 +59,7 @@
incremented DocVector*
Fetch_Doc_Vec(SegReader *self, u32_t doc_num);

- incremented IntMap*
+ incremented I32Array*
Seg_Starts(SegReader *self);

incremented VArray*

Modified: trunk/c_src/KinoSearch/Index/SegReader.c
===================================================================
--- trunk/c_src/KinoSearch/Index/SegReader.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/SegReader.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -17,7 +17,7 @@
#include "KinoSearch/Index/TermVectorsReader.h"
#include "KinoSearch/InvIndex.h"
#include "KinoSearch/Store/LockFactory.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Native.h"

SegReader*
@@ -144,12 +144,12 @@
return TVReader_Doc_Vec(self->tv_reader, doc_num);
}

-IntMap*
+I32Array*
SegReader_seg_starts(SegReader *self)
{
i32_t start = 0;
UNUSED_VAR(self);
- return IntMap_new(&start, 1);
+ return I32Arr_new(&start, 1);
}

VArray*

Modified: trunk/c_src/KinoSearch/Index/SegWriter.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/SegWriter.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/SegWriter.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -37,7 +37,7 @@

void
Add_Segment(SegWriter *self, SegReader *reader,
- IntMap *doc_map = NULL);
+ I32Array *doc_map = NULL);

void
Finish(SegWriter *self);

Modified: trunk/c_src/KinoSearch/Index/SegWriter.c
===================================================================
--- trunk/c_src/KinoSearch/Index/SegWriter.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/SegWriter.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -12,7 +12,7 @@
#include "KinoSearch/Index/SegInfo.h"
#include "KinoSearch/Index/SegReader.h"
#include "KinoSearch/Index/TermVectorsWriter.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Native.h"

SegWriter*
@@ -69,7 +69,7 @@
}

void
-SegWriter_add_segment(SegWriter *self, SegReader *reader, IntMap *doc_map)
+SegWriter_add_segment(SegWriter *self, SegReader *reader, I32Array *doc_map)
{
/* Prepare to bulk add. */
doc_map = DelDocs_Generate_Doc_Map(reader->deldocs,

Modified: trunk/c_src/KinoSearch/Index/TermVector.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/TermVector.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/TermVector.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -9,28 +9,28 @@
CharBuf *field;
CharBuf *text;
u32_t num_pos;
- IntMap *positions;
- IntMap *start_offsets;
- IntMap *end_offsets;
+ I32Array *positions;
+ I32Array *start_offsets;
+ I32Array *end_offsets;

/* Constructor. The object will assume ownership of the positions,
* start_offsets, and end_offsets arrays.
*/
static incremented TermVector*
- new(const CharBuf *field, const CharBuf *text, IntMap *positions,
- IntMap *start_offsets, IntMap *end_offsets);
+ new(const CharBuf *field, const CharBuf *text, I32Array *positions,
+ I32Array *start_offsets, I32Array *end_offsets);

static TermVector*
init(TermVector *self, const CharBuf *field, const CharBuf *text,
- IntMap *positions, IntMap *start_offsets, IntMap *end_offsets);
+ I32Array *positions, I32Array *start_offsets, I32Array *end_offsets);

- IntMap*
+ I32Array*
Get_Positions(TermVector *self);

- IntMap*
+ I32Array*
Get_Start_Offsets(TermVector *self);

- IntMap*
+ I32Array*
Get_End_Offsets(TermVector *self);

public incremented TermVector*

Modified: trunk/c_src/KinoSearch/Index/TermVector.c
===================================================================
--- trunk/c_src/KinoSearch/Index/TermVector.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/TermVector.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -3,11 +3,11 @@
#include "KinoSearch/Index/TermVector.h"
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Store/OutStream.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

TermVector*
-TV_new(const CharBuf *field, const CharBuf *text, IntMap *positions,
- IntMap *start_offsets, IntMap *end_offsets)
+TV_new(const CharBuf *field, const CharBuf *text, I32Array *positions,
+ I32Array *start_offsets, I32Array *end_offsets)
{
TermVector *self = (TermVector*)CREATE(NULL, TERMVECTOR);
return TV_init(self, field, text, positions, start_offsets, end_offsets);
@@ -15,31 +15,31 @@

TermVector*
TV_init(TermVector *self, const CharBuf *field, const CharBuf *text,
- IntMap *positions, IntMap *start_offsets, IntMap *end_offsets)
+ I32Array *positions, I32Array *start_offsets, I32Array *end_offsets)
{
/* Assign. */
self->field = CB_Clone(field);
self->text = CB_Clone(text);
- self->num_pos = IntMap_Get_Size(positions);
+ self->num_pos = I32Arr_Get_Size(positions);
self->positions = REFCOUNT_INC(positions);
self->start_offsets = REFCOUNT_INC(start_offsets);
self->end_offsets = REFCOUNT_INC(end_offsets);

- if ( IntMap_Get_Size(start_offsets) != self->num_pos
- || IntMap_Get_Size(end_offsets) != self->num_pos
+ if ( I32Arr_Get_Size(start_offsets) != self->num_pos
+ || I32Arr_Get_Size(end_offsets) != self->num_pos
) {
CONFESS("Unbalanced arrays: %u32 %u32 %u32", self->num_pos,
- IntMap_Get_Size(start_offsets), IntMap_Get_Size(end_offsets));
+ I32Arr_Get_Size(start_offsets), I32Arr_Get_Size(end_offsets));
}

return self;
}

-IntMap*
+I32Array*
TV_get_positions(TermVector *self) { return self->positions; }
-IntMap*
+I32Array*
TV_get_start_offsets(TermVector *self) { return self->start_offsets; }
-IntMap*
+I32Array*
TV_get_end_offsets(TermVector *self) { return self->end_offsets; }

void
@@ -69,7 +69,7 @@
CharBuf *text = (CharBuf*)CB_deserialize(NULL, instream);
u32_t num_pos = InStream_Read_C32(instream);
i32_t *posits, *starts, *ends;
- IntMap *positions, *start_offsets, *end_offsets;
+ I32Array *positions, *start_offsets, *end_offsets;

/* Read positional data. */
posits = MALLOCATE(num_pos, i32_t);
@@ -80,9 +80,9 @@
starts[i] = InStream_Read_C32(instream);
ends[i] = InStream_Read_C32(instream);
}
- positions = IntMap_new_steal(posits, num_pos);
- start_offsets = IntMap_new_steal(starts, num_pos);
- end_offsets = IntMap_new_steal(ends, num_pos);
+ positions = I32Arr_new_steal(posits, num_pos);
+ start_offsets = I32Arr_new_steal(starts, num_pos);
+ end_offsets = I32Arr_new_steal(ends, num_pos);

self = self ? self : (TermVector*)CREATE(NULL, TERMVECTOR);
self = TV_init(self, field, text, positions, start_offsets, end_offsets);

Modified: trunk/c_src/KinoSearch/Index/TermVectorsReader.c
===================================================================
--- trunk/c_src/KinoSearch/Index/TermVectorsReader.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/TermVectorsReader.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -11,7 +11,7 @@
#include "KinoSearch/Store/OutStream.h"
#include "KinoSearch/Store/Folder.h"
#include "KinoSearch/Util/ByteBuf.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

TermVectorsReader*
TVReader_new(InvIndex *invindex, SegInfo *seg_info)

Modified: trunk/c_src/KinoSearch/Index/TermVectorsWriter.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/TermVectorsWriter.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/TermVectorsWriter.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -25,7 +25,7 @@

void
Add_Segment(TermVectorsWriter *self, SegReader *reader,
- IntMap *doc_map = NULL);
+ I32Array *doc_map = NULL);

void
Finish(TermVectorsWriter *self);

Modified: trunk/c_src/KinoSearch/Index/TermVectorsWriter.c
===================================================================
--- trunk/c_src/KinoSearch/Index/TermVectorsWriter.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Index/TermVectorsWriter.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -16,7 +16,7 @@
#include "KinoSearch/Store/OutStream.h"
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Util/ByteBuf.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

TermVectorsWriter*
TVWriter_new(InvIndex *invindex, SegInfo *seg_info)
@@ -155,7 +155,7 @@

void
TVWriter_add_segment(TermVectorsWriter *self, SegReader *reader,
- IntMap *doc_map)
+ I32Array *doc_map)
{
u32_t max_docs = SegReader_Max_Docs(reader);
/* Bail if the supplied segment is empty. */
@@ -170,7 +170,7 @@
OutStream *tvx_out = self->tvx_out;
for (orig = 1; orig <= max_docs; orig++) {
/* Skip deleted docs. */
- if (doc_map && !IntMap_Get(doc_map, orig))
+ if (doc_map && !I32Arr_Get(doc_map, orig))
continue;

/* Write file pointer. */

Modified: trunk/c_src/KinoSearch/Search/FieldDocCollator.bp
===================================================================
--- trunk/c_src/KinoSearch/Search/FieldDocCollator.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/FieldDocCollator.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -7,7 +7,7 @@
*
* SortSpec is implemented in pure Perl for ease of serialization and sending
* between SearchServer and SearchClient; FieldDocCollator contains references to
- * large IntMap objects, and should not be (cannot be) serialized.
+ * large I32Array objects, and should not be (cannot be) serialized.
*/

class KinoSearch::Search::FieldDocCollator cnick FDocCollator
@@ -15,7 +15,7 @@

u32_t cap;
u32_t size;
- IntMap **sort_caches;
+ I32Array **sort_caches;
bool_t *reversed;
u32_t *cache_sizes;

@@ -28,7 +28,7 @@
/** Add a sort criteria.
*/
void
- Add(FieldDocCollator *self, IntMap *sort_cache, bool_t reverse = false);
+ Add(FieldDocCollator *self, I32Array *sort_cache, bool_t reverse = false);

/** Compare two FieldDocs.
*/

Modified: trunk/c_src/KinoSearch/Search/FieldDocCollator.c
===================================================================
--- trunk/c_src/KinoSearch/Search/FieldDocCollator.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/FieldDocCollator.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -2,7 +2,7 @@

#include "KinoSearch/Search/FieldDocCollator.h"
#include "KinoSearch/Search/FieldDoc.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

FieldDocCollator*
FDocCollator_new()
@@ -39,20 +39,20 @@
}

void
-FDocCollator_add(FieldDocCollator *self, IntMap *sort_cache, bool_t rev)
+FDocCollator_add(FieldDocCollator *self, I32Array *sort_cache, bool_t rev)
{
/* Allocate space. */
if (self->size >= self->cap) {
self->cap += 10;
self->sort_caches
- = REALLOCATE(self->sort_caches, self->cap, IntMap*);
+ = REALLOCATE(self->sort_caches, self->cap, I32Array*);
self->reversed = REALLOCATE(self->reversed, self->cap, bool_t);
self->cache_sizes = REALLOCATE(self->cache_sizes, self->cap, u32_t);
}

self->sort_caches[ self->size ] = REFCOUNT_INC(sort_cache);
self->reversed[ self->size ] = rev;
- self->cache_sizes[ self->size ] = IntMap_Get_Size(sort_cache);
+ self->cache_sizes[ self->size ] = I32Arr_Get_Size(sort_cache);
self->size++;
}

@@ -71,7 +71,7 @@
FDocCollator_compare(FieldDocCollator *self, u32_t doc_num_a, float score_a,
u32_t doc_num_b, float score_b)
{
- IntMap **const sort_caches = self->sort_caches;
+ I32Array **const sort_caches = self->sort_caches;
bool_t *const reversed = self->reversed;
u32_t i;

@@ -79,10 +79,10 @@
const u32_t cache_size = self->cache_sizes[i];
const i32_t sort_num_a
= doc_num_a >= cache_size ? 0
- : IntMap_Get(sort_caches[i], doc_num_a);
+ : I32Arr_Get(sort_caches[i], doc_num_a);
const i32_t sort_num_b
= doc_num_b >= cache_size ? 0
- : IntMap_Get(sort_caches[i], doc_num_b);
+ : I32Arr_Get(sort_caches[i], doc_num_b);

if (sort_num_a != sort_num_b) {
/* This appears to be backwards, but it isn't. Things have to be

Modified: trunk/c_src/KinoSearch/Search/HitCollector.c
===================================================================
--- trunk/c_src/KinoSearch/Search/HitCollector.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/HitCollector.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -3,7 +3,7 @@
#include "KinoSearch/Search/HitCollector.h"
#include "KinoSearch/Search/Tally.h"
#include "KinoSearch/Util/BitVector.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Native.h"

HitCollector*

Modified: trunk/c_src/KinoSearch/Search/MultiSearcher.bp
===================================================================
--- trunk/c_src/KinoSearch/Search/MultiSearcher.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/MultiSearcher.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -18,7 +18,7 @@
static bool_t enable_sorting;

VArray *searchables;
- IntMap *starts;
+ I32Array *starts;
u32_t max_docs;

static incremented MultiSearcher*

Modified: trunk/c_src/KinoSearch/Search/MultiSearcher.c
===================================================================
--- trunk/c_src/KinoSearch/Search/MultiSearcher.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/MultiSearcher.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -17,7 +17,7 @@
#include "KinoSearch/Search/TopDocs.h"
#include "KinoSearch/Search/Compiler.h"
#include "KinoSearch/Searcher.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

bool_t MultiSearcher_enable_sorting = false;

@@ -57,7 +57,7 @@
}

self->max_docs = max_docs;
- self->starts = IntMap_new_steal(starts_array, searchables->size);
+ self->starts = I32Arr_new_steal(starts_array, searchables->size);

return self;
}
@@ -73,11 +73,11 @@
static u32_t
subsearcher_tick(MultiSearcher *self, u32_t doc_num)
{
- IntMap *starts = self->starts;
- u32_t max = IntMap_Get_Size(starts);
+ I32Array *starts = self->starts;
+ u32_t max = I32Arr_Get_Size(starts);
u32_t tick;
for (tick = 1; tick < max; tick++) {
- if ((u32_t)IntMap_Get(starts, tick) > doc_num) {
+ if ((u32_t)I32Arr_Get(starts, tick) > doc_num) {
return tick - 1;
}
}
@@ -89,7 +89,7 @@
{
u32_t tick = subsearcher_tick(self, doc_num);
Searchable *searchable = (Searchable*)VA_Fetch(self->searchables, tick);
- u32_t start = IntMap_Get(self->starts, tick);
+ u32_t start = I32Arr_Get(self->starts, tick);
u32_t sub_doc = doc_num - start;
HitDoc *doc = Searchable_Fetch_Doc(searchable, sub_doc);
HitDoc_Set_Doc_Num(doc, doc_num);
@@ -101,7 +101,7 @@
{
u32_t tick = subsearcher_tick(self, doc_num);
Searchable *searchable = (Searchable*)VA_Fetch(self->searchables, tick);
- u32_t start = IntMap_Get(self->starts, tick);
+ u32_t start = I32Arr_Get(self->starts, tick);
u32_t sub_doc = doc_num - start;
return Searchable_Fetch_Doc_Vec(searchable, sub_doc);
}
@@ -140,7 +140,7 @@
SortSpec *sort_spec)
{
VArray *searchables = self->searchables;
- IntMap *starts = self->starts;
+ I32Array *starts = self->starts;
HitQueue *hit_q = HitQ_new(num_wanted);
u32_t total_hits = 0;
float max_score = 0.0f;
@@ -158,7 +158,7 @@

for (i = 0; i < searchables->size; i++) {
Searchable *searchable = (Searchable*)VA_Fetch(searchables, i);
- u32_t base = (u32_t)IntMap_Get(starts, i);
+ u32_t base = (u32_t)I32Arr_Get(starts, i);
TopDocs *top_docs = Searchable_Top_Docs(searchable,
(Query*)compiler, num_wanted, sort_spec);

@@ -218,10 +218,10 @@
{
u32_t i;
VArray *searchables = self->searchables;
- IntMap *starts = self->starts;
+ I32Array *starts = self->starts;

for (i = 0; i < searchables->size; i++) {
- u32_t start = (u32_t)IntMap_Get(starts, i);
+ u32_t start = (u32_t)I32Arr_Get(starts, i);
Searchable *searchable = (Searchable*)VA_Fetch(searchables, i);
OffsetCollector *offset_coll = OffsetColl_new(collector, start);
Searchable_Collect(searchable, query, (HitCollector*)offset_coll);

Modified: trunk/c_src/KinoSearch/Search/PhraseQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/PhraseQuery.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/PhraseQuery.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -20,7 +20,7 @@
#include "KinoSearch/Store/OutStream.h"
#include "KinoSearch/Util/BitVector.h"
#include "KinoSearch/Util/Freezer.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

/* Shared initialization routine which assumes that it's ok to assume control
* over [field] and [terms], eating their refcounts. */
@@ -326,19 +326,19 @@
if (i == 0) {
/* Set initial positions from first term. */
u32_t j;
- IntMap *positions = term_vector->positions;
- for (j = IntMap_Get_Size(positions); j > 0; j--) {
- BitVec_Set(posit_vec, IntMap_Get(positions, j - 1));
+ I32Array *positions = term_vector->positions;
+ for (j = I32Arr_Get_Size(positions); j > 0; j--) {
+ BitVec_Set(posit_vec, I32Arr_Get(positions, j - 1));
}
}
else {
/* Filter positions using logical "and". */
u32_t j;
- IntMap *positions = term_vector->positions;
+ I32Array *positions = term_vector->positions;

BitVec_Clear_All(other_posit_vec);
- for (j = IntMap_Get_Size(positions); j > 0; j--) {
- i32_t pos = IntMap_Get(positions, j - 1) - i;
+ for (j = I32Arr_Get_Size(positions); j > 0; j--) {
+ i32_t pos = I32Arr_Get(positions, j - 1) - i;
if (pos >= 0) {
BitVec_Set(other_posit_vec, pos);
}
@@ -351,13 +351,13 @@
if (term_vectors->size == terms->size) {
TermVector *first_tv = (TermVector*)VA_Fetch(term_vectors, 0);
TermVector *last_tv = (TermVector*)VA_Fetch(term_vectors, term_vectors->size - 1);
- IntMap *tv_start_positions = first_tv->positions;
- IntMap *tv_end_positions = last_tv->positions;
- IntMap *tv_start_offsets = first_tv->start_offsets;
- IntMap *tv_end_offsets = last_tv->end_offsets;
- u32_t num_terms = terms->size - 1;
- IntMap *valid_posits = BitVec_To_Array(posit_vec);
- u32_t num_valid_posits = IntMap_Get_Size(valid_posits);
+ I32Array *tv_start_positions = first_tv->positions;
+ I32Array *tv_end_positions = last_tv->positions;
+ I32Array *tv_start_offsets = first_tv->start_offsets;
+ I32Array *tv_end_offsets = last_tv->end_offsets;
+ u32_t num_terms = terms->size - 1;
+ I32Array *valid_posits = BitVec_To_Array(posit_vec);
+ u32_t num_valid_posits = I32Arr_Get_Size(valid_posits);
u32_t j = 0;
u32_t posit_tick;
float weight = Compiler_Get_Weight(self);
@@ -365,21 +365,21 @@

/* Add only those starts/ends that belong to a valid position. */
for (posit_tick = 0; posit_tick < num_valid_posits; posit_tick++) {
- i32_t valid_start_posit = IntMap_Get(valid_posits, posit_tick);
+ i32_t valid_start_posit = I32Arr_Get(valid_posits, posit_tick);
i32_t valid_end_posit = valid_start_posit + num_terms;
i32_t start_offset = 0, end_offset = 0;
Span *span;
u32_t max;

- for (max = IntMap_Get_Size(tv_start_positions); i < max; i++) {
- if (IntMap_Get(tv_start_positions, i) == valid_start_posit) {
- start_offset = IntMap_Get(tv_start_offsets, i);
+ for (max = I32Arr_Get_Size(tv_start_positions); i < max; i++) {
+ if (I32Arr_Get(tv_start_positions, i) == valid_start_posit) {
+ start_offset = I32Arr_Get(tv_start_offsets, i);
break;
}
}
- for (max = IntMap_Get_Size(tv_end_positions); j < max; j++) {
- if (IntMap_Get(tv_end_positions, j) == valid_end_posit) {
- end_offset = IntMap_Get(tv_end_offsets, j);
+ for (max = I32Arr_Get_Size(tv_end_positions); j < max; j++) {
+ if (I32Arr_Get(tv_end_positions, j) == valid_end_posit) {
+ end_offset = I32Arr_Get(tv_end_offsets, j);
break;
}
}

Modified: trunk/c_src/KinoSearch/Search/RangeQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/RangeQuery.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/RangeQuery.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -12,7 +12,7 @@
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Store/OutStream.h"
#include "KinoSearch/Util/Freezer.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

/* Determine the lowest term number that should match against a particular
* IndexReader. */
@@ -184,7 +184,7 @@
RangeCompiler_make_scorer(RangeCompiler *self, IndexReader *reader)
{
RangeQuery *parent = (RangeQuery*)self->parent;
- IntMap *sort_cache = IxReader_Fetch_Sort_Cache(reader, parent->field);
+ I32Array *sort_cache = IxReader_Fetch_Sort_Cache(reader, parent->field);

if (!sort_cache) {
return NULL;

Modified: trunk/c_src/KinoSearch/Search/RangeScorer.bp
===================================================================
--- trunk/c_src/KinoSearch/Search/RangeScorer.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/RangeScorer.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -6,15 +6,15 @@
u32_t max_docs;
i32_t lower_bound;
i32_t upper_bound;
- IntMap *sort_cache;
+ I32Array *sort_cache;
Tally *tally;

static incremented RangeScorer*
- new(i32_t lower_bound, i32_t upper_bound, IntMap *sort_cache);
+ new(i32_t lower_bound, i32_t upper_bound, I32Array *sort_cache);

static RangeScorer*
init(RangeScorer *self, i32_t lower_bound, i32_t upper_bound,
- IntMap *sort_cache);
+ I32Array *sort_cache);

u32_t
Next(RangeScorer *self);

Modified: trunk/c_src/KinoSearch/Search/RangeScorer.c
===================================================================
--- trunk/c_src/KinoSearch/Search/RangeScorer.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/RangeScorer.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -2,10 +2,10 @@

#include "KinoSearch/Search/RangeScorer.h"
#include "KinoSearch/Search/Tally.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

RangeScorer*
-RangeScorer_new(i32_t lower_bound, i32_t upper_bound, IntMap *sort_cache)
+RangeScorer_new(i32_t lower_bound, i32_t upper_bound, I32Array *sort_cache)
{
RangeScorer *self = (RangeScorer*)CREATE(NULL, RANGESCORER);
return RangeScorer_init(self, lower_bound, upper_bound, sort_cache);
@@ -13,7 +13,7 @@

RangeScorer*
RangeScorer_init(RangeScorer *self, i32_t lower_bound, i32_t upper_bound,
- IntMap *sort_cache)
+ I32Array *sort_cache)
{
Scorer_init((Scorer*)self, NULL);

@@ -27,7 +27,7 @@
self->sort_cache = REFCOUNT_INC(sort_cache);

/* Derive. */
- self->max_docs = IntMap_Get_Size(sort_cache);
+ self->max_docs = I32Arr_Get_Size(sort_cache);

return self;
}
@@ -49,7 +49,7 @@
return 0;
}
else {
- const i32_t locus = IntMap_Get(self->sort_cache, self->doc_num);
+ const i32_t locus = I32Arr_Get(self->sort_cache, self->doc_num);

if (locus >= self->lower_bound && locus <= self->upper_bound) {
/* Note that any deleted document will fetch -1 from the sort

Modified: trunk/c_src/KinoSearch/Search/Scorer.bp
===================================================================
--- trunk/c_src/KinoSearch/Search/Scorer.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/Scorer.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -66,7 +66,7 @@
void
Collect(Scorer *self, HitCollector *collector, u32_t start = 1,
u32_t limit = 0x7FFFFFFF, u32_t hits_per_seg = 0x7FFFFFFF,
- IntMap *seg_starts = NULL);
+ I32Array *seg_starts = NULL);

/** Return the maximum number of subscorers that can match. Used by
* ORScorer/BooleanScorer to calculate maximum coord bonus. Returns 1 by

Modified: trunk/c_src/KinoSearch/Search/Scorer.c
===================================================================
--- trunk/c_src/KinoSearch/Search/Scorer.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/Scorer.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -4,7 +4,7 @@
#include "KinoSearch/Search/HitCollector.h"
#include "KinoSearch/Search/Similarity.h"
#include "KinoSearch/Search/Tally.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Native.h"

Scorer*
@@ -34,13 +34,13 @@

void
Scorer_collect(Scorer *self, HitCollector *hit_collector, u32_t start,
- u32_t limit, u32_t hits_per_seg, IntMap *seg_starts)
+ u32_t limit, u32_t hits_per_seg, I32Array *seg_starts)
{
u32_t seg_num = 0;
u32_t doc_num_thresh = 0;
u32_t hits_this_seg = 0;
u32_t hits_thresh = hits_per_seg;
- u32_t num_seg_starts = seg_starts ? IntMap_Get_Size(seg_starts) : 0;
+ u32_t num_seg_starts = seg_starts ? I32Arr_Get_Size(seg_starts) : 0;
u32_t doc_num;

if (start == 0)
@@ -72,9 +72,9 @@
else {
/* Get start of upcoming segment. */
i32_t next_start = (seg_num + 1) < num_seg_starts
- ? IntMap_Get(seg_starts, seg_num + 1) : -1;
+ ? I32Arr_Get(seg_starts, seg_num + 1) : -1;
i32_t this_start = seg_num < num_seg_starts
- ? IntMap_Get(seg_starts, seg_num) : -1;
+ ? I32Arr_Get(seg_starts, seg_num) : -1;
seg_num++;

/* Skip docs as appropriate if we're pruning. */

Modified: trunk/c_src/KinoSearch/Search/SortSpec.c
===================================================================
--- trunk/c_src/KinoSearch/Search/SortSpec.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/SortSpec.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -6,7 +6,7 @@
#include "KinoSearch/Index/IndexReader.h"
#include "KinoSearch/Search/FieldDocCollator.h"
#include "KinoSearch/Search/RemoteFieldDoc.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/MSort.h"

SortSpec*
@@ -53,7 +53,7 @@

for (i = 0; i < self->rules->size; i++) {
SortRule *rule = (SortRule*)VA_Fetch(self->rules, i);
- IntMap *sort_cache = IxReader_Fetch_Sort_Cache(reader, rule->field);
+ I32Array *sort_cache = IxReader_Fetch_Sort_Cache(reader, rule->field);
FDocCollator_Add(collator, sort_cache, rule->reverse);
}


Modified: trunk/c_src/KinoSearch/Search/TermQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/TermQuery.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/TermQuery.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -14,7 +14,7 @@
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Store/OutStream.h"
#include "KinoSearch/Util/Freezer.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

TermQuery*
TermQuery_new(const CharBuf *field, const Obj *term)
@@ -229,7 +229,7 @@
TermQuery *const parent = (TermQuery*)self->parent;
VArray *spans = VA_new(0);
TermVector *term_vector;
- IntMap *starts, *ends;
+ I32Array *starts, *ends;
u32_t i, max;
UNUSED_VAR(searchable);

@@ -241,9 +241,9 @@

starts = term_vector->start_offsets;
ends = term_vector->end_offsets;
- for (i = 0, max = IntMap_Get_Size(starts); i < max; i++) {
- i32_t start = IntMap_Get(starts, i);
- i32_t length = IntMap_Get(ends, i) - start;
+ for (i = 0, max = I32Arr_Get_Size(starts); i < max; i++) {
+ i32_t start = I32Arr_Get(starts, i);
+ i32_t length = I32Arr_Get(ends, i) - start;
Span *span = Span_new(start, length, TermCompiler_Get_Weight(self));
VA_Push(spans, (Obj*)span);
REFCOUNT_DEC(span);

Modified: trunk/c_src/KinoSearch/Search/TopDocs.c
===================================================================
--- trunk/c_src/KinoSearch/Search/TopDocs.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Search/TopDocs.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -8,7 +8,7 @@
#include "KinoSearch/Search/SortSpec.h"
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Store/OutStream.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

TopDocs*
TopDocs_new(VArray *score_docs, u32_t total_hits, float max_score)
@@ -65,7 +65,7 @@
for (i = 0; i < num_fields; i++) {
SortRule *rule = (SortRule*)VA_Fetch(sort_rules, i);
CharBuf *field = rule->field;
- IntMap *sort_cache = IxReader_Fetch_Sort_Cache(reader, field);
+ I32Array *sort_cache = IxReader_Fetch_Sort_Cache(reader, field);
Lexicon *lexicon = IxReader_Lexicon(reader, field, NULL);
VA_Push(sort_caches, (Obj*)sort_cache);
VA_Push(lexicons, (Obj*)lexicon);
@@ -78,9 +78,9 @@
u32_t j;
RemoteFieldDoc *remote_doc;
for (j = 0; j < num_fields; j++) {
- IntMap *sort_cache = (IntMap*)VA_Fetch(sort_caches, j);
+ I32Array *sort_cache = (I32Array*)VA_Fetch(sort_caches, j);
Lexicon *lexicon = (Lexicon*)VA_Fetch(lexicons, j);
- i32_t term_num = IntMap_Get(sort_cache, field_doc->doc_num);
+ i32_t term_num = I32Arr_Get(sort_cache, field_doc->doc_num);
CharBuf *field_val;
Lex_Seek_By_Num(lexicon, term_num);
field_val = CB_Clone(Lex_Get_Term(lexicon));

Modified: trunk/c_src/KinoSearch/Searcher.c
===================================================================
--- trunk/c_src/KinoSearch/Searcher.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Searcher.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -18,7 +18,7 @@
#include "KinoSearch/Search/TopDocs.h"
#include "KinoSearch/Search/Compiler.h"
#include "KinoSearch/Schema.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

Searcher*
Searcher_init(Searcher *self, InvIndex *invindex, IndexReader *reader)
@@ -110,7 +110,7 @@
Searcher_collect(Searcher *self, Query *query, HitCollector *collector)
{
IndexReader *reader = self->reader;
- IntMap *seg_starts = NULL;
+ I32Array *seg_starts = NULL;
u32_t hits_per_seg = I32_MAX;
Compiler *compiler;
Scorer *scorer;

Modified: trunk/c_src/KinoSearch/Store/CompoundFileWriter.c
===================================================================
--- trunk/c_src/KinoSearch/Store/CompoundFileWriter.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Store/CompoundFileWriter.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -5,7 +5,7 @@
#include "KinoSearch/Store/Folder.h"
#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Store/OutStream.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"
#include "KinoSearch/Util/Json.h"

/* Helper which does the heavy lifting for CFWriter_consolidate. */

Modified: trunk/c_src/KinoSearch/Util/BitVector.bp
===================================================================
--- trunk/c_src/KinoSearch/Util/BitVector.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Util/BitVector.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -118,7 +118,7 @@

/** Return an array where each element represents a set bit.
*/
- incremented IntMap*
+ incremented I32Array*
To_Array(BitVector *self);

void

Modified: trunk/c_src/KinoSearch/Util/BitVector.c
===================================================================
--- trunk/c_src/KinoSearch/Util/BitVector.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Util/BitVector.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -3,7 +3,7 @@
#include <math.h>

#include "KinoSearch/Util/BitVector.h"
-#include "KinoSearch/Util/IntMap.h"
+#include "KinoSearch/Util/I32Array.h"

#define BITVEC_GROW(self, num) \
do { \
@@ -336,7 +336,7 @@
return count;
}

-IntMap*
+I32Array*
BitVec_to_array(BitVector *self)
{
u32_t count = BitVec_Count(self);
@@ -366,7 +366,7 @@
} while (++num % 8);
}

- return IntMap_new_steal((i32_t*)array, count);
+ return I32Arr_new_steal((i32_t*)array, count);
}

/* Copyright 2006-2008 Marvin Humphrey

Copied: trunk/c_src/KinoSearch/Util/I32Array.bp (from rev 3745, trunk/c_src/KinoSearch/Util/IntMap.bp)
===================================================================
--- trunk/c_src/KinoSearch/Util/I32Array.bp (rev 0)
+++ trunk/c_src/KinoSearch/Util/I32Array.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -0,0 +1,36 @@
+parcel KinoSearch cnick Kino;
+
+class KinoSearch::Util::I32Array cnick I32Arr extends KinoSearch::Obj {
+ i32_t *ints;
+ u32_t size;
+
+ static incremented I32Array*
+ new(i32_t *ints, u32_t size);
+
+ static incremented I32Array*
+ new_steal(i32_t *ints, u32_t size);
+
+ static I32Array*
+ init(I32Array *self, i32_t *ints, u32_t size);
+
+ /* Return the number present at the index requested. If the requested
+ * index is out of range, throw an exception.
+ */
+ i32_t
+ Get(I32Array *self, i32_t num);
+
+ /** Accessor.
+ */
+ u32_t
+ Get_Size(I32Array *self);
+
+ void
+ Destroy(I32Array *self);
+}
+
+/* Copyright 2006-2008 Marvin Humphrey
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * under the same terms as Perl itself.
+ */
+

Copied: trunk/c_src/KinoSearch/Util/I32Array.c (from rev 3745, trunk/c_src/KinoSearch/Util/IntMap.c)
===================================================================
--- trunk/c_src/KinoSearch/Util/I32Array.c (rev 0)
+++ trunk/c_src/KinoSearch/Util/I32Array.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -0,0 +1,53 @@
+#include "KinoSearch/Util/ToolSet.h"
+
+#include "KinoSearch/Util/I32Array.h"
+
+I32Array*
+I32Arr_new(i32_t *ints, u32_t size)
+{
+ I32Array *self = (I32Array*)CREATE(NULL, I32ARRAY);
+ i32_t *ints_copy = MALLOCATE(size, i32_t);
+ memcpy(ints_copy, ints, size * sizeof(i32_t));
+ return I32Arr_init(self, ints_copy, size);
+}
+
+I32Array*
+I32Arr_new_steal(i32_t *ints, u32_t size)
+{
+ I32Array *self = (I32Array*)CREATE(NULL, I32ARRAY);
+ return I32Arr_init(self, ints, size);
+}
+
+I32Array*
+I32Arr_init(I32Array *self, i32_t *ints, u32_t size)
+{
+ self->ints = ints;
+ self->size = size;
+ return self;
+}
+
+i32_t
+I32Arr_get(I32Array *self, i32_t num)
+{
+ if (num < 0 || num >= (i32_t)self->size) {
+ CONFESS("Out of bounds: %i32 > %i32", num, self->size);
+ }
+ return self->ints[num];
+}
+
+u32_t
+I32Arr_get_size(I32Array *self) { return self->size; }
+
+void
+I32Arr_destroy(I32Array *self)
+{
+ free(self->ints);
+ FREE_OBJ(self);
+}
+
+/* Copyright 2006-2008 Marvin Humphrey
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * under the same terms as Perl itself.
+ */
+

Deleted: trunk/c_src/KinoSearch/Util/IntMap.bp
===================================================================
--- trunk/c_src/KinoSearch/Util/IntMap.bp 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Util/IntMap.bp 2008-08-23 01:33:24 UTC (rev 3746)
@@ -1,36 +0,0 @@
-parcel KinoSearch cnick Kino;
-
-class KinoSearch::Util::IntMap extends KinoSearch::Obj {
- i32_t *ints;
- u32_t size;
-
- static incremented IntMap*
- new(i32_t *ints, u32_t size);
-
- static incremented IntMap*
- new_steal(i32_t *ints, u32_t size);
-
- static IntMap*
- init(IntMap *self, i32_t *ints, u32_t size);
-
- /* Return the number present at the index requested. If the requested
- * index is out of range, throw an exception.
- */
- i32_t
- Get(IntMap *self, i32_t num);
-
- /** Accessor.
- */
- u32_t
- Get_Size(IntMap *self);
-
- void
- Destroy(IntMap *self);
-}
-
-/* Copyright 2006-2008 Marvin Humphrey
- *
- * This program is free software; you can redistribute it and/or modify
- * under the same terms as Perl itself.
- */
-

Deleted: trunk/c_src/KinoSearch/Util/IntMap.c
===================================================================
--- trunk/c_src/KinoSearch/Util/IntMap.c 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/c_src/KinoSearch/Util/IntMap.c 2008-08-23 01:33:24 UTC (rev 3746)
@@ -1,53 +0,0 @@
-#include "KinoSearch/Util/ToolSet.h"
-
-#include "KinoSearch/Util/IntMap.h"
-
-IntMap*
-IntMap_new(i32_t *ints, u32_t size)
-{
- IntMap *self = (IntMap*)CREATE(NULL, INTMAP);
- i32_t *ints_copy = MALLOCATE(size, i32_t);
- memcpy(ints_copy, ints, size * sizeof(i32_t));
- return IntMap_init(self, ints_copy, size);
-}
-
-IntMap*
-IntMap_new_steal(i32_t *ints, u32_t size)
-{
- IntMap *self = (IntMap*)CREATE(NULL, INTMAP);
- return IntMap_init(self, ints, size);
-}
-
-IntMap*
-IntMap_init(IntMap *self, i32_t *ints, u32_t size)
-{
- self->ints = ints;
- self->size = size;
- return self;
-}
-
-i32_t
-IntMap_get(IntMap *self, i32_t num)
-{
- if (num < 0 || num >= (i32_t)self->size) {
- CONFESS("Out of bounds: %i32 > %i32", num, self->size);
- }
- return self->ints[num];
-}
-
-u32_t
-IntMap_get_size(IntMap *self) { return self->size; }
-
-void
-IntMap_destroy(IntMap *self)
-{
- free(self->ints);
- FREE_OBJ(self);
-}
-
-/* Copyright 2006-2008 Marvin Humphrey
- *
- * This program is free software; you can redistribute it and/or modify
- * under the same terms as Perl itself.
- */
-

Modified: trunk/perl/MANIFEST
===================================================================
--- trunk/perl/MANIFEST 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/perl/MANIFEST 2008-08-23 01:33:24 UTC (rev 3746)
@@ -189,7 +189,7 @@
lib/KinoSearch/Util/Debug.pm
lib/KinoSearch/Util/DynVirtualTable.pm
lib/KinoSearch/Util/Hash.pm
-lib/KinoSearch/Util/IntMap.pm
+lib/KinoSearch/Util/I32Array.pm
lib/KinoSearch/Util/Json.pm
lib/KinoSearch/Util/MemoryPool.pm
lib/KinoSearch/Util/Native.pm

Modified: trunk/perl/META.yml
===================================================================
--- trunk/perl/META.yml 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/perl/META.yml 2008-08-23 01:33:24 UTC (rev 3746)
@@ -329,8 +329,8 @@
file: lib/KinoSearch/Util/FastObj.pm
KinoSearch::Util::Hash:
file: lib/KinoSearch/Util/Hash.pm
- KinoSearch::Util::IntMap:
- file: lib/KinoSearch/Util/IntMap.pm
+ KinoSearch::Util::I32Array:
+ file: lib/KinoSearch/Util/I32Array.pm
KinoSearch::Util::Json:
file: lib/KinoSearch/Util/Json.pm
KinoSearch::Util::MathUtils:
@@ -701,8 +701,8 @@
- c_src/KinoSearch/Util/Freezer.h
- c_src/KinoSearch/Util/Hash.bp
- c_src/KinoSearch/Util/Hash.c
- - c_src/KinoSearch/Util/IntMap.bp
- - c_src/KinoSearch/Util/IntMap.c
+ - c_src/KinoSearch/Util/I32Array.bp
+ - c_src/KinoSearch/Util/I32Array.c
- c_src/KinoSearch/Util/Json.bp
- c_src/KinoSearch/Util/Json.c
- c_src/KinoSearch/Util/MSort.c
@@ -880,7 +880,7 @@
- lib/KinoSearch/Util/DynVirtualTable.pm
- lib/KinoSearch/Util/FastObj.pm
- lib/KinoSearch/Util/Hash.pm
- - lib/KinoSearch/Util/IntMap.pm
+ - lib/KinoSearch/Util/I32Array.pm
- lib/KinoSearch/Util/Json.pm
- lib/KinoSearch/Util/MathUtils.pm
- lib/KinoSearch/Util/MemoryPool.pm

Copied: trunk/perl/lib/KinoSearch/Util/I32Array.pm (from rev 3745, trunk/perl/lib/KinoSearch/Util/IntMap.pm)
===================================================================
--- trunk/perl/lib/KinoSearch/Util/I32Array.pm (rev 0)
+++ trunk/perl/lib/KinoSearch/Util/I32Array.pm 2008-08-23 01:33:24 UTC (rev 3746)
@@ -0,0 +1,73 @@
+use KinoSearch;
+
+1;
+
+__END__
+
+__XS__
+
+MODULE = KinoSearch PACKAGE = KinoSearch::Util::I32Array
+
+SV*
+new(class_name, ...)
+ kino_ClassNameBuf class_name;
+CODE:
+{
+ HV *const args_hash = build_args_hash( &(ST(0)), 1, items,
+ "KinoSearch::Util::I32Array::new_PARAMS");
+ AV *ints_av = maybe_extract_av(args_hash, SNL("ints"));
+ kino_I32Array *self = NULL;
+
+ if (ints_av) {
+ chy_i32_t size = av_len(ints_av) + 1;
+ chy_i32_t *ints = KINO_MALLOCATE(size, chy_i32_t);
+ chy_i32_t i;
+
+ for (i = 0; i < size; i++) {
+ SV **const sv_ptr = av_fetch(ints_av, i, 0);
+ ints[i] = (sv_ptr && SvOK(*sv_ptr)) ? SvIV(*sv_ptr) : 0;
+ }
+ self = (kino_I32Array*)KINO_CREATE((kino_CharBuf*)&class_name, KINO_I32ARRAY);
+ kino_I32Arr_init(self, ints, size);
+ }
+ else {
+ CONFESS("Missing required param 'ints'");
+ }
+
+ KOBJ_TO_SV_NOINC(self, RETVAL);
+}
+OUTPUT: RETVAL
+
+SV*
+to_arrayref(self)
+ kino_I32Array *self;
+CODE:
+{
+ AV *out_av = newAV();
+ chy_u32_t i;
+ chy_u32_t size = Kino_I32Arr_Get_Size(self);
+
+ av_extend(out_av, size);
+ for (i = 0; i < size; i++) {
+ chy_i32_t result = Kino_I32Arr_Get(self, i);
+ SV* result_sv = result == -1 ? newSV(0) : newSViv(result);
+ av_push(out_av, result_sv);
+ }
+ RETVAL = newRV_noinc((SV*)out_av);
+}
+OUTPUT: RETVAL
+
+__AUTO_XS__
+
+{ "KinoSearch::Util::I32Array" => {
+ bind_methods => [qw( get get_size )],
+ }
+}
+
+__COPYRIGHT__
+
+Copyright 2005-2008 Marvin Humphrey
+
+This program is free software; you can redistribute it and/or modify
+under the same terms as Perl itself.
+

Deleted: trunk/perl/lib/KinoSearch/Util/IntMap.pm
===================================================================
--- trunk/perl/lib/KinoSearch/Util/IntMap.pm 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/perl/lib/KinoSearch/Util/IntMap.pm 2008-08-23 01:33:24 UTC (rev 3746)
@@ -1,73 +0,0 @@
-use KinoSearch;
-
-1;
-
-__END__
-
-__XS__
-
-MODULE = KinoSearch PACKAGE = KinoSearch::Util::IntMap
-
-SV*
-new(class_name, ...)
- kino_ClassNameBuf class_name;
-CODE:
-{
- HV *const args_hash = build_args_hash( &(ST(0)), 1, items,
- "KinoSearch::Util::IntMap::new_PARAMS");
- AV *ints_av = maybe_extract_av(args_hash, SNL("ints"));
- kino_IntMap *self = NULL;
-
- if (ints_av) {
- chy_i32_t size = av_len(ints_av) + 1;
- chy_i32_t *ints = KINO_MALLOCATE(size, chy_i32_t);
- chy_i32_t i;
-
- for (i = 0; i < size; i++) {
- SV **const sv_ptr = av_fetch(ints_av, i, 0);
- ints[i] = (sv_ptr && SvOK(*sv_ptr)) ? SvIV(*sv_ptr) : 0;
- }
- self = (kino_IntMap*)KINO_CREATE((kino_CharBuf*)&class_name, KINO_INTMAP);
- kino_IntMap_init(self, ints, size);
- }
- else {
- CONFESS("Missing required param 'ints'");
- }
-
- KOBJ_TO_SV_NOINC(self, RETVAL);
-}
-OUTPUT: RETVAL
-
-SV*
-to_arrayref(self)
- kino_IntMap *self;
-CODE:
-{
- AV *out_av = newAV();
- chy_u32_t i;
- chy_u32_t size = Kino_IntMap_Get_Size(self);
-
- av_extend(out_av, size);
- for (i = 0; i < size; i++) {
- chy_i32_t result = Kino_IntMap_Get(self, i);
- SV* result_sv = result == -1 ? newSV(0) : newSViv(result);
- av_push(out_av, result_sv);
- }
- RETVAL = newRV_noinc((SV*)out_av);
-}
-OUTPUT: RETVAL
-
-__AUTO_XS__
-
-{ "KinoSearch::Util::IntMap" => {
- bind_methods => [qw( get get_size )],
- }
-}
-
-__COPYRIGHT__
-
-Copyright 2005-2008 Marvin Humphrey
-
-This program is free software; you can redistribute it and/or modify
-under the same terms as Perl itself.
-

Modified: trunk/perl/lib/KinoSearch.pm
===================================================================
--- trunk/perl/lib/KinoSearch.pm 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/perl/lib/KinoSearch.pm 2008-08-23 01:33:24 UTC (rev 3746)
@@ -508,7 +508,7 @@
}

{
- package KinoSearch::Util::IntMap;
+ package KinoSearch::Util::I32Array;
our %new_PARAMS = ( ints => undef );
}


Modified: trunk/perl/t/217-multi_lexicon.t
===================================================================
--- trunk/perl/t/217-multi_lexicon.t 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/perl/t/217-multi_lexicon.t 2008-08-23 01:33:24 UTC (rev 3746)
@@ -102,7 +102,7 @@
max_docs => $reader->max_docs,
posting_list => $reader->posting_list( field => 'content' ),
);
- isa_ok( $intmap, 'KinoSearch::Util::IntMap' );
+ isa_ok( $intmap, 'KinoSearch::Util::I32Array' );

ok( $lexicon->get_size, 'MultiLexicon->get_size' );


Modified: trunk/perl/t/513-scorer.t
===================================================================
--- trunk/perl/t/513-scorer.t 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/perl/t/513-scorer.t 2008-08-23 01:33:24 UTC (rev 3746)
@@ -50,7 +50,7 @@
# Lie about segment starts.
$args{seg_starts} ||= [];
my $seg_starts
- = KinoSearch::Util::IntMap->new( ints => $args{seg_starts} );
+ = KinoSearch::Util::I32Array->new( ints => $args{seg_starts} );

my $scorer = KSx::Search::MockScorer->new(
doc_nums => [ 1 .. 10 ],

Modified: trunk/perl/t/520-score_doc.t
===================================================================
--- trunk/perl/t/520-score_doc.t 2008-08-23 01:15:30 UTC (rev 3745)
+++ trunk/perl/t/520-score_doc.t 2008-08-23 01:33:24 UTC (rev 3746)
@@ -10,7 +10,7 @@
}

use KinoSearch::Search::FieldDocCollator;
-use KinoSearch::Util::IntMap;
+use KinoSearch::Util::I32Array;
use Storable qw( freeze thaw );

my $score_doc = KinoSearch::Search::ScoreDoc->new(
@@ -25,7 +25,7 @@
is( $score_doc_copy->get_score, $score_doc->get_score,
"score survives serialization" );

-my $map = KinoSearch::Util::IntMap->new( ints => [ 1, 0, 20 ] );
+my $map = KinoSearch::Util::I32Array->new( ints => [ 1, 0, 20 ] );
my $collator = KinoSearch::Search::FieldDocCollator->new;
$collator->add( sort_cache => $map );



_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits