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/19 06:26:02 UTC
[lucy-commits] [05/11] git commit: refs/heads/sortfieldwriter2 - Update for changes
to SortEx API.
Update for changes to SortEx API.
Since the changes on branch "sortex_ptr_only" made it to master first,
this branch had to be updated. SortExternal now only handles objects
rather than arbitrary data, making it possible to remove one level of
indirection.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/2714f5b8
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/2714f5b8
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/2714f5b8
Branch: refs/heads/sortfieldwriter2
Commit: 2714f5b81b0573fdb6193be96da98ce657886b5f
Parents: 63043ed
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Wed Jun 18 19:00:28 2014 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Wed Jun 18 21:23:00 2014 -0700
----------------------------------------------------------------------
core/Lucy/Test/Util/TestSortExternal.c | 60 +++++++++++++----------------
core/Lucy/Util/BBSortEx.c | 8 ++--
2 files changed, 30 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/2714f5b8/core/Lucy/Test/Util/TestSortExternal.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Util/TestSortExternal.c b/core/Lucy/Test/Util/TestSortExternal.c
index 26f10ea..2e04c83 100644
--- a/core/Lucy/Test/Util/TestSortExternal.c
+++ b/core/Lucy/Test/Util/TestSortExternal.c
@@ -65,16 +65,13 @@ static void
test_bbsortex(TestBatchRunner *runner) {
BBSortEx *sortex = BBSortEx_new(4, NULL);
- INCREF(c_bb);
- BBSortEx_Feed(sortex, &c_bb);
- TEST_INT_EQ(runner, BBSortEx_Cache_Count(sortex), 1,
+ BBSortEx_Feed(sortex, INCREF(c_bb));
+ TEST_INT_EQ(runner, BBSortEx_Buffer_Count(sortex), 1,
"feed elem into cache");
- INCREF(b_bb);
- INCREF(d_bb);
- BBSortEx_Feed(sortex, &b_bb);
- BBSortEx_Feed(sortex, &d_bb);
- BBSortEx_Sort_Cache(sortex);
+ BBSortEx_Feed(sortex, INCREF(b_bb));
+ BBSortEx_Feed(sortex, INCREF(d_bb));
+ BBSortEx_Sort_Buffer(sortex);
{
VArray *cache = BBSortEx_Peek_Cache(sortex);
@@ -87,9 +84,8 @@ test_bbsortex(TestBatchRunner *runner) {
DECREF(cache);
}
- INCREF(a_bb);
- BBSortEx_Feed(sortex, &a_bb);
- TEST_INT_EQ(runner, BBSortEx_Cache_Count(sortex), 0,
+ BBSortEx_Feed(sortex, INCREF(a_bb));
+ TEST_INT_EQ(runner, BBSortEx_Buffer_Count(sortex), 0,
"cache flushed automatically when mem_thresh crossed");
TEST_INT_EQ(runner, BBSortEx_Get_Num_Runs(sortex), 1, "run added");
@@ -103,9 +99,9 @@ test_bbsortex(TestBatchRunner *runner) {
{
VArray *got = VA_new(7);
- void *data;
- while (NULL != (data = BBSortEx_Fetch(sortex))) {
- VA_Push(got, *(Obj**)data);
+ Obj *object;
+ while (NULL != (object = BBSortEx_Fetch(sortex))) {
+ VA_Push(got, object);
}
VArray *wanted = VA_new(7);
@@ -128,32 +124,29 @@ test_bbsortex(TestBatchRunner *runner) {
}
static void
-test_clear_cache(TestBatchRunner *runner) {
+test_clear_buffer(TestBatchRunner *runner) {
BBSortEx *sortex = BBSortEx_new(4, NULL);
- INCREF(c_bb);
- BBSortEx_Feed(sortex, &c_bb);
- BBSortEx_Clear_Cache(sortex);
- TEST_INT_EQ(runner, BBSortEx_Cache_Count(sortex), 0, "Clear_Cache");
+ BBSortEx_Feed(sortex, INCREF(c_bb));
+ BBSortEx_Clear_Buffer(sortex);
+ TEST_INT_EQ(runner, BBSortEx_Buffer_Count(sortex), 0, "Clear_Buffer");
- INCREF(b_bb);
- INCREF(a_bb);
- BBSortEx_Feed(sortex, &b_bb);
- BBSortEx_Feed(sortex, &a_bb);
+ BBSortEx_Feed(sortex, INCREF(b_bb));
+ BBSortEx_Feed(sortex, INCREF(a_bb));
BBSortEx_Flush(sortex);
BBSortEx_Flip(sortex);
- void *data = BBSortEx_Peek(sortex);
- TEST_TRUE(runner, BB_Equals(a_bb, *(Obj**)data), "Peek");
+ Obj *object = BBSortEx_Peek(sortex);
+ TEST_TRUE(runner, BB_Equals(a_bb, object), "Peek");
VArray *got = VA_new(2);
- while (NULL != (data = BBSortEx_Fetch(sortex))) {
- VA_Push(got, *(Obj**)data);
+ while (NULL != (object = BBSortEx_Fetch(sortex))) {
+ VA_Push(got, object);
}
VArray *wanted = VA_new(2);
VA_Push(wanted, INCREF(a_bb));
VA_Push(wanted, INCREF(b_bb));
TEST_TRUE(runner, VA_Equals(got, (Obj*)wanted),
- "elements cleared via Clear_Cache truly cleared");
+ "elements cleared via Clear_Buffer truly cleared");
DECREF(wanted);
DECREF(got);
@@ -177,15 +170,14 @@ S_test_sort(TestBatchRunner *runner, VArray *bytebufs, uint32_t mem_thresh,
shuffled[i] = temp;
}
for (int i = 0; i < size; ++i) {
- INCREF(shuffled[i]);
- BBSortEx_Feed(sortex, &shuffled[i]);
+ BBSortEx_Feed(sortex, INCREF(shuffled[i]));
}
BBSortEx_Flip(sortex);
VArray *got = VA_new(size);
- void *data;
- while (NULL != (data = BBSortEx_Fetch(sortex))) {
- VA_Push(got, *(Obj**)data);
+ Obj *object;
+ while (NULL != (object = BBSortEx_Fetch(sortex))) {
+ VA_Push(got, object);
}
TEST_TRUE(runner, VA_Equals(got, (Obj*)bytebufs), test_name);
@@ -284,7 +276,7 @@ TestSortExternal_Run_IMP(TestSortExternal *self, TestBatchRunner *runner) {
srand((unsigned int)time((time_t*)NULL));
S_init_bytebufs();
test_bbsortex(runner);
- test_clear_cache(runner);
+ test_clear_buffer(runner);
test_sort_letters(runner);
test_sort_nothing(runner);
test_sort_packed_ints(runner);
http://git-wip-us.apache.org/repos/asf/lucy/blob/2714f5b8/core/Lucy/Util/BBSortEx.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/BBSortEx.c b/core/Lucy/Util/BBSortEx.c
index 5f9df9a..c9201bb 100644
--- a/core/Lucy/Util/BBSortEx.c
+++ b/core/Lucy/Util/BBSortEx.c
@@ -172,12 +172,12 @@ BBSortEx_Compare_IMP(BBSortEx *self, void *va, void *vb) {
VArray*
BBSortEx_Peek_Cache_IMP(BBSortEx *self) {
BBSortExIVARS *const ivars = BBSortEx_IVARS(self);
- uint32_t count = ivars->cache_max - ivars->cache_tick;
- Obj **cache = (Obj**)ivars->cache;
+ uint32_t count = ivars->buf_max - ivars->buf_tick;
+ Obj **buffer = ivars->buffer;
VArray *retval = VA_new(count);
- for (uint32_t i = ivars->cache_tick; i < ivars->cache_max; ++i) {
- VA_Push(retval, INCREF(cache[i]));
+ for (uint32_t i = ivars->buf_tick; i < ivars->buf_max; ++i) {
+ VA_Push(retval, INCREF(buffer[i]));
}
return retval;