Const SortCache ords pointers
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/97dc3b3f Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/97dc3b3f Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/97dc3b3f Branch: refs/heads/master Commit: 97dc3b3f99158bf94b1ce7eec9059d2cf9f2a6f1 Parents: 5640701 Author: Nick Wellnhofer <[email protected]> Authored: Tue Aug 12 21:11:34 2014 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Tue Aug 12 21:36:11 2014 +0200 ---------------------------------------------------------------------- core/Lucy/Index/SortCache.c | 6 +++--- core/Lucy/Index/SortCache.cfh | 22 +++++++++---------- core/Lucy/Index/SortCache/NumericSortCache.c | 4 ++-- core/Lucy/Index/SortCache/TextSortCache.c | 2 +- core/Lucy/Search/Collector/SortCollector.c | 26 +++++++++++------------ core/Lucy/Search/Collector/SortCollector.cfh | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/97dc3b3f/core/Lucy/Index/SortCache.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/SortCache.c b/core/Lucy/Index/SortCache.c index 3fe006f..c451da6 100644 --- a/core/Lucy/Index/SortCache.c +++ b/core/Lucy/Index/SortCache.c @@ -22,8 +22,8 @@ SortCache* SortCache_init(SortCache *self, String *field, FieldType *type, - void *ords, int32_t cardinality, int32_t doc_max, int32_t null_ord, - int32_t ord_width) { + const void *ords, int32_t cardinality, int32_t doc_max, + int32_t null_ord, int32_t ord_width) { SortCacheIVARS *const ivars = SortCache_IVARS(self); // Init. @@ -143,7 +143,7 @@ SortCache_Find_IMP(SortCache *self, Obj *term) { } } -void* +const void* SortCache_Get_Ords_IMP(SortCache *self) { return SortCache_IVARS(self)->ords; } http://git-wip-us.apache.org/repos/asf/lucy/blob/97dc3b3f/core/Lucy/Index/SortCache.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/SortCache.cfh b/core/Lucy/Index/SortCache.cfh index 380c28d..ff3408c 100644 --- a/core/Lucy/Index/SortCache.cfh +++ b/core/Lucy/Index/SortCache.cfh @@ -20,18 +20,18 @@ parcel Lucy; */ class Lucy::Index::SortCache inherits Clownfish::Obj { - String *field; - FieldType *type; - void *ords; - int32_t doc_max; - int32_t cardinality; - int32_t ord_width; - int32_t null_ord; - bool native_ords; + String *field; + FieldType *type; + const void *ords; + int32_t doc_max; + int32_t cardinality; + int32_t ord_width; + int32_t null_ord; + bool native_ords; public inert SortCache* - init(SortCache *self, String *field, FieldType *type, - void *ords, int32_t cardinality, int32_t doc_max, int32_t null_ord = -1, + init(SortCache *self, String *field, FieldType *type, const void *ords, + int32_t cardinality, int32_t doc_max, int32_t null_ord = -1, int32_t ord_width); /** Return the value for ordinal <code>ord</code>, or NULL if the value @@ -40,7 +40,7 @@ class Lucy::Index::SortCache inherits Clownfish::Obj { public abstract nullable incremented Obj* Value(SortCache *self, int32_t ord); - public void* + public const void* Get_Ords(SortCache *self); public int32_t http://git-wip-us.apache.org/repos/asf/lucy/blob/97dc3b3f/core/Lucy/Index/SortCache/NumericSortCache.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/SortCache/NumericSortCache.c b/core/Lucy/Index/SortCache/NumericSortCache.c index 77d98e0..e801dff 100644 --- a/core/Lucy/Index/SortCache/NumericSortCache.c +++ b/core/Lucy/Index/SortCache/NumericSortCache.c @@ -41,8 +41,8 @@ NumSortCache_init(NumericSortCache *self, String *field, } // Mmap ords and super-init. - int64_t ord_len = InStream_Length(ord_in); - void *ords = InStream_Buf(ord_in, (size_t)ord_len); + int64_t ord_len = InStream_Length(ord_in); + const void *ords = InStream_Buf(ord_in, (size_t)ord_len); SortCache_init((SortCache*)self, field, type, ords, cardinality, doc_max, null_ord, ord_width); NumericSortCacheIVARS *const ivars = NumSortCache_IVARS(self); http://git-wip-us.apache.org/repos/asf/lucy/blob/97dc3b3f/core/Lucy/Index/SortCache/TextSortCache.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/SortCache/TextSortCache.c b/core/Lucy/Index/SortCache/TextSortCache.c index 8b58dbf..f3596cd 100644 --- a/core/Lucy/Index/SortCache/TextSortCache.c +++ b/core/Lucy/Index/SortCache/TextSortCache.c @@ -46,7 +46,7 @@ TextSortCache_init(TextSortCache *self, String *field, // Memory map ords and super-init. int64_t ord_len = InStream_Length(ord_in); - void *ords = InStream_Buf(ord_in, (size_t)ord_len); + const void *ords = InStream_Buf(ord_in, (size_t)ord_len); SortCache_init((SortCache*)self, field, type, ords, cardinality, doc_max, null_ord, ord_width); TextSortCacheIVARS *const ivars = TextSortCache_IVARS(self); http://git-wip-us.apache.org/repos/asf/lucy/blob/97dc3b3f/core/Lucy/Search/Collector/SortCollector.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Search/Collector/SortCollector.c b/core/Lucy/Search/Collector/SortCollector.c index 80561b0..db5d742 100644 --- a/core/Lucy/Search/Collector/SortCollector.c +++ b/core/Lucy/Search/Collector/SortCollector.c @@ -114,7 +114,7 @@ SortColl_init(SortCollector *self, Schema *schema, SortSpec *sort_spec, ivars->rules = rules; // absorb refcount. ivars->num_rules = num_rules; ivars->sort_caches = (SortCache**)CALLOCATE(num_rules, sizeof(SortCache*)); - ivars->ord_arrays = (void**)CALLOCATE(num_rules, sizeof(void*)); + ivars->ord_arrays = (const void**)CALLOCATE(num_rules, sizeof(void*)); ivars->actions = (uint8_t*)CALLOCATE(num_rules, sizeof(uint8_t)); // Build up an array of "actions" which we will execute during each call @@ -344,7 +344,7 @@ SortColl_Collect_IMP(SortCollector *self, int32_t doc_id) { static CFISH_INLINE int32_t SI_compare_by_ord1(SortCollectorIVARS *ivars, uint32_t tick, int32_t a, int32_t b) { - void *const ords = ivars->ord_arrays[tick]; + const void *const ords = ivars->ord_arrays[tick]; int32_t a_ord = NumUtil_u1get(ords, a); int32_t b_ord = NumUtil_u1get(ords, b); return a_ord - b_ord; @@ -352,7 +352,7 @@ SI_compare_by_ord1(SortCollectorIVARS *ivars, uint32_t tick, static CFISH_INLINE int32_t SI_compare_by_ord2(SortCollectorIVARS *ivars, uint32_t tick, int32_t a, int32_t b) { - void *const ords = ivars->ord_arrays[tick]; + const void *const ords = ivars->ord_arrays[tick]; int32_t a_ord = NumUtil_u2get(ords, a); int32_t b_ord = NumUtil_u2get(ords, b); return a_ord - b_ord; @@ -360,7 +360,7 @@ SI_compare_by_ord2(SortCollectorIVARS *ivars, uint32_t tick, static CFISH_INLINE int32_t SI_compare_by_ord4(SortCollectorIVARS *ivars, uint32_t tick, int32_t a, int32_t b) { - void *const ords = ivars->ord_arrays[tick]; + const void *const ords = ivars->ord_arrays[tick]; int32_t a_ord = NumUtil_u4get(ords, a); int32_t b_ord = NumUtil_u4get(ords, b); return a_ord - b_ord; @@ -368,7 +368,7 @@ SI_compare_by_ord4(SortCollectorIVARS *ivars, uint32_t tick, static CFISH_INLINE int32_t SI_compare_by_ord8(SortCollectorIVARS *ivars, uint32_t tick, int32_t a, int32_t b) { - uint8_t *ords = (uint8_t*)ivars->ord_arrays[tick]; + const uint8_t *ords = (const uint8_t*)ivars->ord_arrays[tick]; int32_t a_ord = ords[a]; int32_t b_ord = ords[b]; return a_ord - b_ord; @@ -376,9 +376,9 @@ SI_compare_by_ord8(SortCollectorIVARS *ivars, uint32_t tick, static CFISH_INLINE int32_t SI_compare_by_ord16(SortCollectorIVARS *ivars, uint32_t tick, int32_t a, int32_t b) { - uint8_t *ord_bytes = (uint8_t*)ivars->ord_arrays[tick]; - uint8_t *address_a = ord_bytes + a * sizeof(uint16_t); - uint8_t *address_b = ord_bytes + b * sizeof(uint16_t); + const uint8_t *ord_bytes = (const uint8_t*)ivars->ord_arrays[tick]; + const uint8_t *address_a = ord_bytes + a * sizeof(uint16_t); + const uint8_t *address_b = ord_bytes + b * sizeof(uint16_t); int32_t ord_a = NumUtil_decode_bigend_u16(address_a); int32_t ord_b = NumUtil_decode_bigend_u16(address_b); return ord_a - ord_b; @@ -386,9 +386,9 @@ SI_compare_by_ord16(SortCollectorIVARS *ivars, uint32_t tick, static CFISH_INLINE int32_t SI_compare_by_ord32(SortCollectorIVARS *ivars, uint32_t tick, int32_t a, int32_t b) { - uint8_t *ord_bytes = (uint8_t*)ivars->ord_arrays[tick]; - uint8_t *address_a = ord_bytes + a * sizeof(uint32_t); - uint8_t *address_b = ord_bytes + b * sizeof(uint32_t); + const uint8_t *ord_bytes = (const uint8_t*)ivars->ord_arrays[tick]; + const uint8_t *address_a = ord_bytes + a * sizeof(uint32_t); + const uint8_t *address_b = ord_bytes + b * sizeof(uint32_t); int32_t ord_a = NumUtil_decode_bigend_u32(address_a); int32_t ord_b = NumUtil_decode_bigend_u32(address_b); return ord_a - ord_b; @@ -396,7 +396,7 @@ SI_compare_by_ord32(SortCollectorIVARS *ivars, uint32_t tick, static CFISH_INLINE int32_t SI_compare_by_native_ord16(SortCollectorIVARS *ivars, uint32_t tick, int32_t a, int32_t b) { - uint16_t *ords = (uint16_t*)ivars->ord_arrays[tick]; + const uint16_t *ords = (const uint16_t*)ivars->ord_arrays[tick]; int32_t a_ord = ords[a]; int32_t b_ord = ords[b]; return a_ord - b_ord; @@ -404,7 +404,7 @@ SI_compare_by_native_ord16(SortCollectorIVARS *ivars, uint32_t tick, static CFISH_INLINE int32_t SI_compare_by_native_ord32(SortCollectorIVARS *ivars, uint32_t tick, int32_t a, int32_t b) { - int32_t *ords = (int32_t*)ivars->ord_arrays[tick]; + const int32_t *ords = (const int32_t*)ivars->ord_arrays[tick]; return ords[a] - ords[b]; } http://git-wip-us.apache.org/repos/asf/lucy/blob/97dc3b3f/core/Lucy/Search/Collector/SortCollector.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Search/Collector/SortCollector.cfh b/core/Lucy/Search/Collector/SortCollector.cfh index f4e8346..84ef161 100644 --- a/core/Lucy/Search/Collector/SortCollector.cfh +++ b/core/Lucy/Search/Collector/SortCollector.cfh @@ -30,7 +30,7 @@ class Lucy::Search::Collector::SortCollector nickname SortColl MatchDoc *bumped; VArray *rules; SortCache **sort_caches; - void **ord_arrays; + const void **ord_arrays; uint8_t *actions; uint8_t *auto_actions; uint8_t *derived_actions;
