You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2014/08/12 21:56:36 UTC

[1/5] git commit: refs/heads/const_pointers - Const LexIndex offsets

Repository: lucy
Updated Branches:
  refs/heads/const_pointers [created] 049ae7319


Const LexIndex offsets


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/093dc8b2
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/093dc8b2
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/093dc8b2

Branch: refs/heads/const_pointers
Commit: 093dc8b2f49436c6cc29a36ffd18967bfb5ac51d
Parents: 97dc3b3
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Aug 12 21:14:46 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Aug 12 21:36:11 2014 +0200

----------------------------------------------------------------------
 core/Lucy/Index/LexIndex.c   |  4 ++--
 core/Lucy/Index/LexIndex.cfh | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/093dc8b2/core/Lucy/Index/LexIndex.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/LexIndex.c b/core/Lucy/Index/LexIndex.c
index d1b4b16..91e8d03 100644
--- a/core/Lucy/Index/LexIndex.c
+++ b/core/Lucy/Index/LexIndex.c
@@ -83,8 +83,8 @@ LexIndex_init(LexIndex *self, Schema *schema, Folder *folder,
     ivars->index_interval = Arch_Index_Interval(arch);
     ivars->skip_interval  = Arch_Skip_Interval(arch);
     ivars->size    = (int32_t)(InStream_Length(ivars->ixix_in) / sizeof(int64_t));
-    ivars->offsets = (int64_t*)InStream_Buf(ivars->ixix_in,
-                                           (size_t)InStream_Length(ivars->ixix_in));
+    ivars->offsets = (const int64_t*)InStream_Buf(ivars->ixix_in,
+            (size_t)InStream_Length(ivars->ixix_in));
 
     DECREF(ixix_file);
     DECREF(ix_file);

http://git-wip-us.apache.org/repos/asf/lucy/blob/093dc8b2/core/Lucy/Index/LexIndex.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/LexIndex.cfh b/core/Lucy/Index/LexIndex.cfh
index 3d197fe..1d360aa 100644
--- a/core/Lucy/Index/LexIndex.cfh
+++ b/core/Lucy/Index/LexIndex.cfh
@@ -18,16 +18,16 @@ parcel Lucy;
 
 class Lucy::Index::LexIndex inherits Lucy::Index::Lexicon {
 
-    FieldType   *field_type;
-    InStream    *ixix_in;
-    InStream    *ix_in;
-    int64_t     *offsets;
-    int32_t      tick;
-    int32_t      size;
-    int32_t      index_interval;
-    int32_t      skip_interval;
-    TermStepper *term_stepper;
-    TermInfo    *tinfo;
+    FieldType     *field_type;
+    InStream      *ixix_in;
+    InStream      *ix_in;
+    const int64_t *offsets;
+    int32_t        tick;
+    int32_t        size;
+    int32_t        index_interval;
+    int32_t        skip_interval;
+    TermStepper   *term_stepper;
+    TermInfo      *tinfo;
 
     inert incremented LexIndex*
     new(Schema *schema, Folder *folder, Segment *segment,


[3/5] git commit: refs/heads/const_pointers - Pass const pointers to NumUtil decode functions

Posted by nw...@apache.org.
Pass const pointers to NumUtil decode functions


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/4e1caaf8
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/4e1caaf8
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/4e1caaf8

Branch: refs/heads/const_pointers
Commit: 4e1caaf82a539f07d4ae98828e197f29b405f601
Parents: d4fc5d4
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Aug 10 02:19:53 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Aug 12 21:36:11 2014 +0200

----------------------------------------------------------------------
 core/Lucy/Index/DocVector.c             | 16 ++++++++--------
 core/Lucy/Index/Posting/ScorePosting.c  |  2 +-
 core/Lucy/Store/InStream.c              |  4 ++--
 core/Lucy/Store/InStream.cfh            |  2 +-
 core/Lucy/Test/Store/TestIOPrimitives.c |  2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Index/DocVector.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocVector.c b/core/Lucy/Index/DocVector.c
index daeba31..0cb0aae 100644
--- a/core/Lucy/Index/DocVector.c
+++ b/core/Lucy/Index/DocVector.c
@@ -120,10 +120,10 @@ DocVec_Term_Vector_IMP(DocVector *self, String *field,
 
 static Hash*
 S_extract_tv_cache(ByteBuf *field_buf) {
-    Hash    *tv_cache  = Hash_new(0);
-    char    *tv_string = BB_Get_Buf(field_buf);
-    int32_t  num_terms = NumUtil_decode_c32(&tv_string);
-    CharBuf *text_buf  = CB_new(0);
+    Hash       *tv_cache  = Hash_new(0);
+    const char *tv_string = BB_Get_Buf(field_buf);
+    int32_t     num_terms = NumUtil_decode_c32(&tv_string);
+    CharBuf    *text_buf  = CB_new(0);
 
     // Read the number of highlightable terms in the field.
     for (int32_t i = 0; i < num_terms; i++) {
@@ -136,8 +136,8 @@ S_extract_tv_cache(ByteBuf *field_buf) {
         tv_string += len;
 
         // Get positions & offsets string.
-        char *bookmark_ptr      = tv_string;
-        int32_t num_positions   = NumUtil_decode_c32(&tv_string);
+        const char *bookmark_ptr  = tv_string;
+        int32_t     num_positions = NumUtil_decode_c32(&tv_string);
         while (num_positions--) {
             // Leave nums compressed to save a little mem.
             NumUtil_skip_cint(&tv_string);
@@ -161,8 +161,8 @@ static TermVector*
 S_extract_tv_from_tv_buf(String *field, String *term_text,
                          ByteBuf *tv_buf) {
     TermVector *retval      = NULL;
-    char       *posdata     = BB_Get_Buf(tv_buf);
-    char       *posdata_end = posdata + BB_Get_Size(tv_buf);
+    const char *posdata     = BB_Get_Buf(tv_buf);
+    const char *posdata_end = posdata + BB_Get_Size(tv_buf);
     int32_t    *positions   = NULL;
     int32_t    *starts      = NULL;
     int32_t    *ends        = NULL;

http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Index/Posting/ScorePosting.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Posting/ScorePosting.c b/core/Lucy/Index/Posting/ScorePosting.c
index f812c5b..18b4692 100644
--- a/core/Lucy/Index/Posting/ScorePosting.c
+++ b/core/Lucy/Index/Posting/ScorePosting.c
@@ -134,7 +134,7 @@ ScorePost_Read_Record_IMP(ScorePosting *self, InStream *instream) {
     ScorePostingIVARS *const ivars = ScorePost_IVARS(self);
     uint32_t  position = 0;
     const size_t max_start_bytes = (C32_MAX_BYTES * 2) + 1;
-    char *buf = InStream_Buf(instream, max_start_bytes);
+    const char *buf = InStream_Buf(instream, max_start_bytes);
     const uint32_t doc_code = NumUtil_decode_c32(&buf);
     const uint32_t doc_delta = doc_code >> 1;
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Store/InStream.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/InStream.c b/core/Lucy/Store/InStream.c
index 366caca..8a47ff7 100644
--- a/core/Lucy/Store/InStream.c
+++ b/core/Lucy/Store/InStream.c
@@ -318,7 +318,7 @@ InStream_Buf_IMP(InStream *self, size_t request) {
 }
 
 void
-InStream_Advance_Buf_IMP(InStream *self, char *buf) {
+InStream_Advance_Buf_IMP(InStream *self, const char *buf) {
     InStreamIVARS *const ivars = InStream_IVARS(self);
     if (buf > ivars->limit) {
         int64_t overrun = CHY_PTR_TO_I64(buf) - CHY_PTR_TO_I64(ivars->limit);
@@ -330,7 +330,7 @@ InStream_Advance_Buf_IMP(InStream *self, char *buf) {
         THROW(ERR, "Can't Advance_Buf backwards: (underrun: %i64))", underrun);
     }
     else {
-        ivars->buf = buf;
+        ivars->buf += buf - ivars->buf;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Store/InStream.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/InStream.cfh b/core/Lucy/Store/InStream.cfh
index 88a099f..6a7a89c 100644
--- a/core/Lucy/Store/InStream.cfh
+++ b/core/Lucy/Store/InStream.cfh
@@ -123,7 +123,7 @@ class Lucy::Store::InStream inherits Clownfish::Obj {
      * Advance_Buf() to update the InStream object.
      */
     final void
-    Advance_Buf(InStream *self, char *buf);
+    Advance_Buf(InStream *self, const char *buf);
 
     /** Read <code>len</code> bytes from the InStream into <code>buf</code>.
      */

http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Test/Store/TestIOPrimitives.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestIOPrimitives.c b/core/Lucy/Test/Store/TestIOPrimitives.c
index 66caf76..30008d6 100644
--- a/core/Lucy/Test/Store/TestIOPrimitives.c
+++ b/core/Lucy/Test/Store/TestIOPrimitives.c
@@ -319,7 +319,7 @@ test_c64(TestBatchRunner *runner) {
     raw_instream = InStream_open((Obj*)raw_file);
     for (i = 0; i < 1000; i++) {
         char  buffer[10];
-        char *buf = buffer;
+        const char *buf = buffer;
         size_t size = InStream_Read_Raw_C64(raw_instream, buffer);
         uint64_t got = NumUtil_decode_c64(&buf);
         UNUSED_VAR(size);


[2/5] git commit: refs/heads/const_pointers - Const SortCache ords pointers

Posted by nw...@apache.org.
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/const_pointers
Commit: 97dc3b3f99158bf94b1ce7eec9059d2cf9f2a6f1
Parents: 5640701
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Aug 12 21:11:34 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
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;


[5/5] git commit: refs/heads/const_pointers - Const InStream buffer

Posted by nw...@apache.org.
Const InStream buffer


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/049ae731
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/049ae731
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/049ae731

Branch: refs/heads/const_pointers
Commit: 049ae73194f79344e5c80b95459d21538ebcace7
Parents: 093dc8b
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Aug 12 21:19:43 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Aug 12 21:37:35 2014 +0200

----------------------------------------------------------------------
 core/Lucy/Index/BitVecDelDocs.c     | 1 +
 core/Lucy/Store/InStream.c          | 4 ++--
 core/Lucy/Store/InStream.cfh        | 6 +++---
 core/Lucy/Test/Store/TestIOChunks.c | 8 ++++----
 core/Lucy/Util/Json.c               | 2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/049ae731/core/Lucy/Index/BitVecDelDocs.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/BitVecDelDocs.c b/core/Lucy/Index/BitVecDelDocs.c
index 24b49a0..4cd1e50 100644
--- a/core/Lucy/Index/BitVecDelDocs.c
+++ b/core/Lucy/Index/BitVecDelDocs.c
@@ -39,6 +39,7 @@ BitVecDelDocs_init(BitVecDelDocs *self, Folder *folder,
         DECREF(self);
         RETHROW(error);
     }
+    // Cast away const-ness of buffer as we have no immutable BitVector.
     int32_t len    = (int32_t)InStream_Length(ivars->instream);
     ivars->bits    = (uint8_t*)InStream_Buf(ivars->instream, len);
     ivars->cap     = (uint32_t)(len * 8);

http://git-wip-us.apache.org/repos/asf/lucy/blob/049ae731/core/Lucy/Store/InStream.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/InStream.c b/core/Lucy/Store/InStream.c
index 8a47ff7..43881e8 100644
--- a/core/Lucy/Store/InStream.c
+++ b/core/Lucy/Store/InStream.c
@@ -286,7 +286,7 @@ InStream_Length_IMP(InStream *self) {
     return InStream_IVARS(self)->len;
 }
 
-char*
+const char*
 InStream_Buf_IMP(InStream *self, size_t request) {
     InStreamIVARS *const ivars = InStream_IVARS(self);
     const int64_t bytes_in_buf
@@ -330,7 +330,7 @@ InStream_Advance_Buf_IMP(InStream *self, const char *buf) {
         THROW(ERR, "Can't Advance_Buf backwards: (underrun: %i64))", underrun);
     }
     else {
-        ivars->buf += buf - ivars->buf;
+        ivars->buf = buf;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/049ae731/core/Lucy/Store/InStream.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/InStream.cfh b/core/Lucy/Store/InStream.cfh
index 6a7a89c..9e57ee0 100644
--- a/core/Lucy/Store/InStream.cfh
+++ b/core/Lucy/Store/InStream.cfh
@@ -35,8 +35,8 @@ class Lucy::Store::InStream inherits Clownfish::Obj {
 
     int64_t     offset;
     int64_t     len;
-    char       *buf;
-    char       *limit;
+    const char *buf;
+    const char *limit;
     String     *filename;
     FileHandle *file_handle;
     FileWindow *window;
@@ -115,7 +115,7 @@ class Lucy::Store::InStream inherits Clownfish::Obj {
      * @param request Advisory byte size request.
      * @return Pointer to the InStream's internal buffer.
      */
-    final char*
+    final const char*
     Buf(InStream *self, size_t request);
 
     /** Set the buf to a new value, checking for overrun.  The idiom is for

http://git-wip-us.apache.org/repos/asf/lucy/blob/049ae731/core/Lucy/Test/Store/TestIOChunks.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestIOChunks.c b/core/Lucy/Test/Store/TestIOChunks.c
index 1df0651..c09d665 100644
--- a/core/Lucy/Test/Store/TestIOChunks.c
+++ b/core/Lucy/Test/Store/TestIOChunks.c
@@ -80,7 +80,7 @@ test_Buf(TestBatchRunner *runner) {
     OutStream  *outstream = OutStream_open((Obj*)file);
     size_t      size      = IO_STREAM_BUF_SIZE * 2 + 5;
     InStream   *instream;
-    char       *buf;
+    const char *buf;
 
     for (uint32_t i = 0; i < size; i++) {
         OutStream_Write_U8(outstream, 'a');
@@ -104,9 +104,9 @@ test_Buf(TestBatchRunner *runner) {
     TEST_INT_EQ(runner, ivars->limit - buf, IO_STREAM_BUF_SIZE,
                 "Requesting over limit triggers refill");
 
-    int64_t  expected = InStream_Length(instream) - InStream_Tell(instream);
-    char    *buff     = InStream_Buf(instream, 100000);
-    int64_t  got      = CHY_PTR_TO_I64(ivars->limit) - CHY_PTR_TO_I64(buff);
+    int64_t     expected = InStream_Length(instream) - InStream_Tell(instream);
+    const char *buff     = InStream_Buf(instream, 100000);
+    int64_t     got      = CHY_PTR_TO_I64(ivars->limit) - CHY_PTR_TO_I64(buff);
     TEST_TRUE(runner, got == expected,
               "Requests greater than file size get pared down");
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/049ae731/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index cb8625c..1d8ea9c 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -108,7 +108,7 @@ Json_slurp_json(Folder *folder, String *path) {
         return NULL;
     }
     size_t len = (size_t)InStream_Length(instream);
-    char *buf = InStream_Buf(instream, len);
+    const char *buf = InStream_Buf(instream, len);
     Obj *dump = S_parse_json(buf, len);
     InStream_Close(instream);
     DECREF(instream);


[4/5] git commit: refs/heads/const_pointers - Const a few char pointers

Posted by nw...@apache.org.
Const a few char pointers


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/5640701c
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/5640701c
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/5640701c

Branch: refs/heads/const_pointers
Commit: 5640701c67fbf4e36792110fc2536af949e14e2e
Parents: 4e1caaf
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Aug 10 19:20:35 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Aug 12 21:36:11 2014 +0200

----------------------------------------------------------------------
 core/Lucy/Index/DocWriter.c       | 8 ++++----
 core/Lucy/Index/HighlightWriter.c | 3 +--
 core/Lucy/Store/RAMFileHandle.c   | 2 +-
 core/LucyX/Search/MockMatcher.c   | 2 +-
 4 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/5640701c/core/Lucy/Index/DocWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocWriter.c b/core/Lucy/Index/DocWriter.c
index cb4e7ef..8b70d14 100644
--- a/core/Lucy/Index/DocWriter.c
+++ b/core/Lucy/Index/DocWriter.c
@@ -122,8 +122,8 @@ DocWriter_Add_Inverted_Doc_IMP(DocWriter *self, Inverter *inverter,
                     break;
                 }
                 case FType_BLOB: {
-                    char   *buf  = BB_Get_Buf((ByteBuf*)value);
-                    size_t  size = BB_Get_Size((ByteBuf*)value);
+                    const char *buf  = BB_Get_Buf((ByteBuf*)value);
+                    size_t      size = BB_Get_Size((ByteBuf*)value);
                     OutStream_Write_C32(dat_out, size);
                     OutStream_Write_Bytes(dat_out, buf, size);
                     break;
@@ -183,8 +183,8 @@ DocWriter_Add_Segment_IMP(DocWriter *self, SegReader *reader,
 
                 // Copy record over.
                 DefDocReader_Read_Record(doc_reader, buffer, i);
-                char *buf   = BB_Get_Buf(buffer);
-                size_t size = BB_Get_Size(buffer);
+                const char *buf  = BB_Get_Buf(buffer);
+                size_t      size = BB_Get_Size(buffer);
                 OutStream_Write_Bytes(dat_out, buf, size);
 
                 // Write file pointer.

http://git-wip-us.apache.org/repos/asf/lucy/blob/5640701c/core/Lucy/Index/HighlightWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/HighlightWriter.c b/core/Lucy/Index/HighlightWriter.c
index 501d522..9655455 100644
--- a/core/Lucy/Index/HighlightWriter.c
+++ b/core/Lucy/Index/HighlightWriter.c
@@ -143,7 +143,6 @@ HLWriter_TV_Buf_IMP(HighlightWriter *self, Inversion *inversion) {
     size_t      last_len = 0;
     ByteBuf    *tv_buf = BB_new(20 + Inversion_Get_Size(inversion) * 8);
     uint32_t    num_postings = 0;
-    char       *dest;
     Token     **tokens;
     uint32_t    freq;
     UNUSED_VAR(self);
@@ -202,7 +201,7 @@ HLWriter_TV_Buf_IMP(HighlightWriter *self, Inversion *inversion) {
     }
 
     // Go back and start the term vector string with the posting count.
-    dest = BB_Get_Buf(tv_buf);
+    char *dest = BB_Get_Buf(tv_buf);
     NumUtil_encode_padded_c32(num_postings, &dest);
 
     return tv_buf;

http://git-wip-us.apache.org/repos/asf/lucy/blob/5640701c/core/Lucy/Store/RAMFileHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/RAMFileHandle.c b/core/Lucy/Store/RAMFileHandle.c
index ce9cba0..8db9f60 100644
--- a/core/Lucy/Store/RAMFileHandle.c
+++ b/core/Lucy/Store/RAMFileHandle.c
@@ -129,7 +129,7 @@ RAMFH_Read_IMP(RAMFileHandle *self, char *dest, int64_t offset, size_t len) {
         return false;
     }
     else {
-        char *const source = BB_Get_Buf(ivars->contents) + offset;
+        const char *const source = BB_Get_Buf(ivars->contents) + offset;
         memcpy(dest, source, len);
         return true;
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/5640701c/core/LucyX/Search/MockMatcher.c
----------------------------------------------------------------------
diff --git a/core/LucyX/Search/MockMatcher.c b/core/LucyX/Search/MockMatcher.c
index e340e78..867d7a2 100644
--- a/core/LucyX/Search/MockMatcher.c
+++ b/core/LucyX/Search/MockMatcher.c
@@ -60,7 +60,7 @@ MockMatcher_Score_IMP(MockMatcher* self) {
     if (!ivars->scores) {
         THROW(ERR, "Can't call Score() unless scores supplied");
     }
-    float *raw_scores = (float*)BB_Get_Buf(ivars->scores);
+    const float *raw_scores = (const float*)BB_Get_Buf(ivars->scores);
     return raw_scores[ivars->tick];
 }