You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2014/06/18 03:06:36 UTC
[lucy-commits] [14/16] git commit: refs/heads/master - Rename some methods in
SortExternal.
Rename some methods in SortExternal.
Replace "cache" with "buffer" in a few method names.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/3b0c585b
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/3b0c585b
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/3b0c585b
Branch: refs/heads/master
Commit: 3b0c585b559bfc9cc8f84820c248c61223a8521a
Parents: 4cff84b
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Fri Jan 11 15:06:45 2013 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sat Apr 26 16:01:52 2014 -0700
----------------------------------------------------------------------
core/Lucy/Index/PostingPool.c | 16 ++++++++--------
core/Lucy/Index/SortFieldWriter.c | 24 ++++++++++++------------
core/Lucy/Index/SortFieldWriter.cfh | 2 +-
core/Lucy/Util/BBSortEx.c | 18 +++++++++---------
core/Lucy/Util/BBSortEx.cfh | 2 +-
core/Lucy/Util/SortExternal.c | 28 ++++++++++++++--------------
core/Lucy/Util/SortExternal.cfh | 8 ++++----
perl/t/015-sort_external.t | 20 ++++++++++----------
8 files changed, 59 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/3b0c585b/core/Lucy/Index/PostingPool.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingPool.c b/core/Lucy/Index/PostingPool.c
index 9c538ed..3088f34 100644
--- a/core/Lucy/Index/PostingPool.c
+++ b/core/Lucy/Index/PostingPool.c
@@ -190,16 +190,16 @@ PostPool_Flip_IMP(PostingPool *self) {
DECREF(post_temp_path);
}
- PostPool_Sort_Cache(self);
+ PostPool_Sort_Buffer(self);
if (num_runs && (ivars->buf_max - ivars->buf_tick) > 0) {
- uint32_t num_items = PostPool_Cache_Count(self);
+ uint32_t num_items = PostPool_Buffer_Count(self);
// Cheap imitation of flush. FIXME.
PostingPool *run
= PostPool_new(ivars->schema, ivars->snapshot, ivars->segment,
ivars->polyreader, ivars->field, ivars->lex_writer,
ivars->mem_pool, ivars->lex_temp_out,
ivars->post_temp_out, ivars->skip_out);
- PostPool_Grow_Cache(run, num_items);
+ PostPool_Grow_Buffer(run, num_items);
PostingPoolIVARS *const run_ivars = PostPool_IVARS(run);
memcpy(run_ivars->buffer, (ivars->buffer) + ivars->buf_tick,
@@ -264,7 +264,7 @@ PostPool_Flush_IMP(PostingPool *self) {
PostingPoolIVARS *const ivars = PostPool_IVARS(self);
// Don't add a run unless we have data to put in it.
- if (PostPool_Cache_Count(self) == 0) { return; }
+ if (PostPool_Buffer_Count(self) == 0) { return; }
PostingPool *run
= PostPool_new(ivars->schema, ivars->snapshot, ivars->segment,
@@ -288,7 +288,7 @@ PostPool_Flush_IMP(PostingPool *self) {
ivars->lex_temp_out);
run_ivars->lex_start = OutStream_Tell(ivars->lex_temp_out);
run_ivars->post_start = OutStream_Tell(ivars->post_temp_out);
- PostPool_Sort_Cache(self);
+ PostPool_Sort_Buffer(self);
S_write_terms_and_postings(run, post_writer, NULL);
run_ivars->lex_end = OutStream_Tell(ivars->lex_temp_out);
@@ -300,7 +300,7 @@ PostPool_Flush_IMP(PostingPool *self) {
run_ivars->buf_tick = 0;
run_ivars->buf_max = 0;
run_ivars->buf_cap = 0;
- PostPool_Clear_Cache(self);
+ PostPool_Clear_Buffer(self);
// Add the run to the array.
PostPool_Add_Run(self, (SortExternal*)run);
@@ -517,7 +517,7 @@ PostPool_Refill_IMP(PostingPool *self) {
// Add to the run's cache.
if (num_elems >= ivars->buf_cap) {
size_t new_cap = Memory_oversize(num_elems + 1, sizeof(Obj*));
- PostPool_Grow_Cache(self, new_cap);
+ PostPool_Grow_Buffer(self, new_cap);
}
ivars->buffer[num_elems] = (Obj*)rawpost;
num_elems++;
@@ -547,7 +547,7 @@ S_fresh_flip(PostingPool *self, InStream *lex_temp_in,
ivars->flipped = true;
// Sort RawPostings in cache, if any.
- PostPool_Sort_Cache(self);
+ PostPool_Sort_Buffer(self);
// Bail if never flushed.
if (ivars->lex_end == 0) { return; }
http://git-wip-us.apache.org/repos/asf/lucy/blob/3b0c585b/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index 1a0d5ff..9cdf47a 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -127,7 +127,7 @@ SortFieldWriter_init(SortFieldWriter *self, Schema *schema,
}
void
-SortFieldWriter_Clear_Cache_IMP(SortFieldWriter *self) {
+SortFieldWriter_Clear_Buffer_IMP(SortFieldWriter *self) {
SortFieldWriterIVARS *const ivars = SortFieldWriter_IVARS(self);
if (ivars->uniq_vals) {
if (ivars->last_val) {
@@ -137,9 +137,9 @@ SortFieldWriter_Clear_Cache_IMP(SortFieldWriter *self) {
}
Hash_Clear(ivars->uniq_vals);
}
- SortFieldWriter_Clear_Cache_t super_clear_cache
- = SUPER_METHOD_PTR(SORTFIELDWRITER, LUCY_SortFieldWriter_Clear_Cache);
- super_clear_cache(self);
+ SortFieldWriter_Clear_Buffer_t super_clear_buffer
+ = SUPER_METHOD_PTR(SORTFIELDWRITER, LUCY_SortFieldWriter_Clear_Buffer);
+ super_clear_buffer(self);
// Note that we have not called MemPool_Release_All() on our memory pool.
// This is because the pool is shared amongst multiple SortFieldWriters
// which belong to a parent SortWriter; it is the responsibility of the
@@ -378,13 +378,13 @@ SortFieldWriter_Flush_IMP(SortFieldWriter *self) {
SortFieldWriterIVARS *const ivars = SortFieldWriter_IVARS(self);
// Don't add a run unless we have data to put in it.
- if (SortFieldWriter_Cache_Count(self) == 0) { return; }
+ if (SortFieldWriter_Buffer_Count(self) == 0) { return; }
OutStream *const temp_ord_out = ivars->temp_ord_out;
OutStream *const temp_ix_out = ivars->temp_ix_out;
OutStream *const temp_dat_out = ivars->temp_dat_out;
- SortFieldWriter_Sort_Cache(self);
+ SortFieldWriter_Sort_Buffer(self);
SortFieldWriter *run
= SortFieldWriter_new(ivars->schema, ivars->snapshot, ivars->segment,
ivars->polyreader, ivars->field, ivars->mem_pool,
@@ -415,7 +415,7 @@ SortFieldWriter_Flush_IMP(SortFieldWriter *self) {
run_ivars->buf_tick = 0;
run_ivars->buf_cap = 0;
ivars->buf_tick = ivars->buf_max;
- SortFieldWriter_Clear_Cache(self);
+ SortFieldWriter_Clear_Buffer(self);
// Record stream ends.
run_ivars->ord_end = OutStream_Tell(temp_ord_out);
@@ -434,12 +434,12 @@ SortFieldWriter_Refill_IMP(SortFieldWriter *self) {
if (!ivars->sort_cache) { return 0; }
// Sanity check, then reset the cache and prepare to start loading items.
- uint32_t buf_count = SortFieldWriter_Cache_Count(self);
+ uint32_t buf_count = SortFieldWriter_Buffer_Count(self);
if (buf_count) {
THROW(ERR, "Refill called but cache contains %u32 items",
buf_count);
}
- SortFieldWriter_Clear_Cache(self);
+ SortFieldWriter_Clear_Buffer(self);
MemPool_Release_All(ivars->mem_pool);
S_lazy_init_sorted_ids(self);
@@ -480,7 +480,7 @@ SortFieldWriter_Refill_IMP(SortFieldWriter *self) {
ivars->run_tick++;
}
ivars->run_ord++;
- SortFieldWriter_Sort_Cache(self);
+ SortFieldWriter_Sort_Buffer(self);
if (ivars->run_ord >= ivars->run_cardinality) {
DECREF(ivars->sort_cache);
@@ -493,7 +493,7 @@ SortFieldWriter_Refill_IMP(SortFieldWriter *self) {
void
SortFieldWriter_Flip_IMP(SortFieldWriter *self) {
SortFieldWriterIVARS *const ivars = SortFieldWriter_IVARS(self);
- uint32_t num_items = SortFieldWriter_Cache_Count(self);
+ uint32_t num_items = SortFieldWriter_Buffer_Count(self);
uint32_t num_runs = VA_Get_Size(ivars->runs);
if (ivars->flipped) { THROW(ERR, "Can't call Flip() twice"); }
@@ -506,7 +506,7 @@ SortFieldWriter_Flip_IMP(SortFieldWriter *self) {
}
if (num_items) {
- SortFieldWriter_Sort_Cache(self);
+ SortFieldWriter_Sort_Buffer(self);
}
else if (num_runs) {
Folder *folder = PolyReader_Get_Folder(ivars->polyreader);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3b0c585b/core/Lucy/Index/SortFieldWriter.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.cfh b/core/Lucy/Index/SortFieldWriter.cfh
index 00e85c1..8f749cc 100644
--- a/core/Lucy/Index/SortFieldWriter.cfh
+++ b/core/Lucy/Index/SortFieldWriter.cfh
@@ -88,7 +88,7 @@ class Lucy::Index::SortFieldWriter
Compare(SortFieldWriter *self, void *va, void *vb);
void
- Clear_Cache(SortFieldWriter *self);
+ Clear_Buffer(SortFieldWriter *self);
int32_t
Get_Null_Ord(SortFieldWriter *self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3b0c585b/core/Lucy/Util/BBSortEx.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/BBSortEx.c b/core/Lucy/Util/BBSortEx.c
index 156ab02..662a570 100644
--- a/core/Lucy/Util/BBSortEx.c
+++ b/core/Lucy/Util/BBSortEx.c
@@ -50,12 +50,12 @@ BBSortEx_Destroy_IMP(BBSortEx *self) {
}
void
-BBSortEx_Clear_Cache_IMP(BBSortEx *self) {
+BBSortEx_Clear_Buffer_IMP(BBSortEx *self) {
BBSortExIVARS *const ivars = BBSortEx_IVARS(self);
ivars->mem_consumed = 0;
- BBSortEx_Clear_Cache_t super_clear_cache
- = SUPER_METHOD_PTR(BBSORTEX, LUCY_BBSortEx_Clear_Cache);
- super_clear_cache(self);
+ BBSortEx_Clear_Buffer_t super_clear_buffer
+ = SUPER_METHOD_PTR(BBSORTEX, LUCY_BBSortEx_Clear_Buffer);
+ super_clear_buffer(self);
}
void
@@ -84,7 +84,7 @@ BBSortEx_Flush_IMP(BBSortEx *self) {
else { elems = VA_new(buf_count); }
// Sort, then create a new run.
- BBSortEx_Sort_Cache(self);
+ BBSortEx_Sort_Buffer(self);
for (uint32_t i = ivars->buf_tick; i < ivars->buf_max; i++) {
VA_Push(elems, buffer[i]);
}
@@ -94,7 +94,7 @@ BBSortEx_Flush_IMP(BBSortEx *self) {
// Blank the cache vars.
ivars->buf_tick += buf_count;
- BBSortEx_Clear_Cache(self);
+ BBSortEx_Clear_Buffer(self);
}
uint32_t
@@ -128,9 +128,9 @@ BBSortEx_Refill_IMP(BBSortEx *self) {
}
if (ivars->buf_max == ivars->buf_cap) {
- BBSortEx_Grow_Cache(self,
- Memory_oversize(ivars->buf_max + 1,
- sizeof(Obj*)));
+ BBSortEx_Grow_Buffer(self,
+ Memory_oversize(ivars->buf_max + 1,
+ sizeof(Obj*)));
}
ivars->buffer[ivars->buf_max++] = INCREF(elem);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3b0c585b/core/Lucy/Util/BBSortEx.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/BBSortEx.cfh b/core/Lucy/Util/BBSortEx.cfh
index 3ba7531..8ef64c8 100644
--- a/core/Lucy/Util/BBSortEx.cfh
+++ b/core/Lucy/Util/BBSortEx.cfh
@@ -43,7 +43,7 @@ class Lucy::Util::BBSortEx
Refill(BBSortEx *self);
void
- Clear_Cache(BBSortEx *self);
+ Clear_Buffer(BBSortEx *self);
void
Flip(BBSortEx *self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3b0c585b/core/Lucy/Util/SortExternal.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.c b/core/Lucy/Util/SortExternal.c
index ce42550..c7dff90 100644
--- a/core/Lucy/Util/SortExternal.c
+++ b/core/Lucy/Util/SortExternal.c
@@ -21,7 +21,7 @@
// Refill the main cache, drawing from the caches of all runs.
static void
-S_refill_cache(SortExternal *self, SortExternalIVARS *ivars);
+S_refill_buffer(SortExternal *self, SortExternalIVARS *ivars);
// Absorb all the items which are "in-range" from all the Runs into the main
// cache.
@@ -68,7 +68,7 @@ SortEx_Destroy_IMP(SortExternal *self) {
FREEMEM(ivars->slice_sizes);
FREEMEM(ivars->slice_starts);
if (ivars->buffer) {
- SortEx_Clear_Cache(self);
+ SortEx_Clear_Buffer(self);
FREEMEM(ivars->buffer);
}
DECREF(ivars->runs);
@@ -76,7 +76,7 @@ SortEx_Destroy_IMP(SortExternal *self) {
}
void
-SortEx_Clear_Cache_IMP(SortExternal *self) {
+SortEx_Clear_Buffer_IMP(SortExternal *self) {
SortExternalIVARS *const ivars = SortEx_IVARS(self);
Obj **const buffer = ivars->buffer;
const uint32_t max = ivars->buf_max;
@@ -92,7 +92,7 @@ SortEx_Feed_IMP(SortExternal *self, Obj *item) {
SortExternalIVARS *const ivars = SortEx_IVARS(self);
if (ivars->buf_max == ivars->buf_cap) {
size_t amount = Memory_oversize(ivars->buf_max + 1, sizeof(Obj*));
- SortEx_Grow_Cache(self, amount);
+ SortEx_Grow_Buffer(self, amount);
}
ivars->buffer[ivars->buf_max] = item;
ivars->buf_max++;
@@ -101,7 +101,7 @@ SortEx_Feed_IMP(SortExternal *self, Obj *item) {
static CFISH_INLINE Obj*
SI_peek(SortExternal *self, SortExternalIVARS *ivars) {
if (ivars->buf_tick >= ivars->buf_max) {
- S_refill_cache(self, ivars);
+ S_refill_buffer(self, ivars);
}
if (ivars->buf_max > 0) {
@@ -127,10 +127,10 @@ SortEx_Peek_IMP(SortExternal *self) {
}
void
-SortEx_Sort_Cache_IMP(SortExternal *self) {
+SortEx_Sort_Buffer_IMP(SortExternal *self) {
SortExternalIVARS *const ivars = SortEx_IVARS(self);
if (ivars->buf_tick != 0) {
- THROW(ERR, "Cant Sort_Cache() after fetching %u32 items", ivars->buf_tick);
+ THROW(ERR, "Cant Sort_Buffer() after fetching %u32 items", ivars->buf_tick);
}
if (ivars->buf_max != 0) {
VTable *vtable = SortEx_Get_VTable(self);
@@ -169,7 +169,7 @@ void
SortEx_Shrink_IMP(SortExternal *self) {
SortExternalIVARS *const ivars = SortEx_IVARS(self);
if (ivars->buf_max - ivars->buf_tick > 0) {
- size_t buf_count = SortEx_Cache_Count(self);
+ size_t buf_count = SortEx_Buffer_Count(self);
size_t size = buf_count * sizeof(Obj*);
if (ivars->buf_tick > 0) {
Obj **start = ivars->buffer + ivars->buf_tick;
@@ -198,15 +198,15 @@ SortEx_Shrink_IMP(SortExternal *self) {
}
static void
-S_refill_cache(SortExternal *self, SortExternalIVARS *ivars) {
+S_refill_buffer(SortExternal *self, SortExternalIVARS *ivars) {
// Reset cache vars.
- SortEx_Clear_Cache(self);
+ SortEx_Clear_Buffer(self);
// Make sure all runs have at least one item in the cache.
uint32_t i = 0;
while (i < VA_Get_Size(ivars->runs)) {
SortExternal *const run = (SortExternal*)VA_Fetch(ivars->runs, i);
- if (SortEx_Cache_Count(run) > 0 || SortEx_Refill(run) > 0) {
+ if (SortEx_Buffer_Count(run) > 0 || SortEx_Refill(run) > 0) {
i++; // Run has some elements, so keep.
}
else {
@@ -276,7 +276,7 @@ S_absorb_slices(SortExternal *self, SortExternalIVARS *ivars,
if (ivars->buf_max + slice_size > ivars->buf_cap) {
size_t cap = Memory_oversize(ivars->buf_max + slice_size,
sizeof(Obj*));
- SortEx_Grow_Cache(self, cap);
+ SortEx_Grow_Buffer(self, cap);
}
memcpy(ivars->buffer + ivars->buf_max,
run_ivars->buffer + run_ivars->buf_tick,
@@ -338,7 +338,7 @@ S_absorb_slices(SortExternal *self, SortExternalIVARS *ivars,
}
void
-SortEx_Grow_Cache_IMP(SortExternal *self, uint32_t cap) {
+SortEx_Grow_Buffer_IMP(SortExternal *self, uint32_t cap) {
SortExternalIVARS *const ivars = SortEx_IVARS(self);
if (cap > ivars->buf_cap) {
ivars->buffer = (Obj**)REALLOCATE(ivars->buffer, cap * sizeof(Obj*));
@@ -375,7 +375,7 @@ SortEx_Set_Mem_Thresh_IMP(SortExternal *self, uint32_t mem_thresh) {
}
uint32_t
-SortEx_Cache_Count_IMP(SortExternal *self) {
+SortEx_Buffer_Count_IMP(SortExternal *self) {
SortExternalIVARS *const ivars = SortEx_IVARS(self);
return ivars->buf_max - ivars->buf_tick;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3b0c585b/core/Lucy/Util/SortExternal.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.cfh b/core/Lucy/Util/SortExternal.cfh
index 9674f92..917f5df 100644
--- a/core/Lucy/Util/SortExternal.cfh
+++ b/core/Lucy/Util/SortExternal.cfh
@@ -109,7 +109,7 @@ abstract class Lucy::Util::SortExternal nickname SortEx
/** Sort all items currently in the main cache.
*/
void
- Sort_Cache(SortExternal *self);
+ Sort_Buffer(SortExternal *self);
/** Reset cache variables so that cache gives the appearance of having
* been initialized.
@@ -117,17 +117,17 @@ abstract class Lucy::Util::SortExternal nickname SortEx
* Subclasses may take steps to release items held in cache, if any.
*/
void
- Clear_Cache(SortExternal *self);
+ Clear_Buffer(SortExternal *self);
/** Return the number of items presently in the cache.
*/
uint32_t
- Cache_Count(SortExternal *self);
+ Buffer_Count(SortExternal *self);
/** Allocate more memory to the cache.
*/
void
- Grow_Cache(SortExternal *self, uint32_t cap);
+ Grow_Buffer(SortExternal *self, uint32_t cap);
void
Set_Mem_Thresh(SortExternal *self, uint32_t mem_thresh);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3b0c585b/perl/t/015-sort_external.t
----------------------------------------------------------------------
diff --git a/perl/t/015-sort_external.t b/perl/t/015-sort_external.t
index 134e7c7..b656abf 100644
--- a/perl/t/015-sort_external.t
+++ b/perl/t/015-sort_external.t
@@ -21,24 +21,24 @@ use List::Util qw( shuffle );
use Lucy::Test;
use bytes qw();
-my ( $sortex, $cache, @orig, @sort_output );
+my ( $sortex, $buffer, @orig, @sort_output );
$sortex = Lucy::Util::BBSortEx->new( mem_thresh => 4 );
$sortex->feed( new_bytebuf('c') );
-is( $sortex->cache_count, 1, "feed elem into cache" );
+is( $sortex->buffer_count, 1, "feed elem into buffer" );
$sortex->feed( new_bytebuf('b') );
$sortex->feed( new_bytebuf('d') );
-$sortex->sort_cache;
+$sortex->sort_buffer;
SKIP: {
skip( "Restore when porting test to C", 1 );
- $cache = $sortex->_peek_cache;
- is_deeply( $cache, [qw( b c d )], "sort cache" );
+ $buffer = $sortex->_peek_buffer;
+ is_deeply( $buffer, [qw( b c d )], "sort buffer" );
}
$sortex->feed( new_bytebuf('a') );
-is( $sortex->cache_count, 0,
- "cache flushed automatically when mem_thresh crossed" );
+is( $sortex->buffer_count, 0,
+ "buffer flushed automatically when mem_thresh crossed" );
#is( $sortex->get_num_runs, 1, "run added" );
my @bytebufs = map { new_bytebuf($_) } qw( x y z );
@@ -55,8 +55,8 @@ is_deeply( \@sort_output, \@orig, "Add_Run" );
$sortex = Lucy::Util::BBSortEx->new( mem_thresh => 4 );
$sortex->feed( new_bytebuf('c') );
-$sortex->clear_cache;
-is( $sortex->cache_count, 0, "Clear_Cache" );
+$sortex->clear_buffer;
+is( $sortex->buffer_count, 0, "Clear_Buffer" );
$sortex->feed( new_bytebuf('b') );
$sortex->feed( new_bytebuf('a') );
$sortex->flush;
@@ -68,7 +68,7 @@ while ( defined( my $result = $sortex->fetch ) ) {
push @sort_output, $result;
}
is_deeply( \@sort_output, \@orig,
- "elements cleared via Clear_Cache truly cleared" );
+ "elements cleared via Clear_Buffer truly cleared" );
@orig = ();
@sort_output = ();