- while (i_more)
- {
- if (i_mode!=0)
- { /* ignore deletes here, should not happen */
-
- c_ptr=codebuff;
- i_ptr=i_item;
- (*is->method->code_item)(ISAMD_ENCODE, encoder_data, &c_ptr, &i_ptr);
- codelen = c_ptr - codebuff;
- assert ( (codelen<128) && (codelen>0));
- if (is->method->debug >3)
- logf(LOG_LOG,"isamd:build: coded into %s (nk=%d)",
- hexdump(codebuff, c_ptr-codebuff,hexbuff), firstpp->numKeys+1);
-
- if (pp->offset + codelen > maxsize )
- { /* oops, block full - get a new one */
- if (firstpp==pp)
- { /* special case: it was the first block. Save much later */
- if (0==firstpp->pos)
- { /* firstpp not allocated yet, do so now, */
- /* to keep blocks in order. Don't save yet, though */
- firstpp->pos = isamd_alloc_block(is, firstpp->cat);
- }
- newblock = isamd_alloc_block(is, firstpp->cat);
- firstpp->next = isamd_addr(newblock,firstpp->cat);
- /* keep the largest category */
- pp=isamd_pp_open(is,isamd_addr(0,firstpp->cat));/*don't load*/
- pp->pos=newblock;
- pp->size = pp->offset = ISAMD_BLOCK_OFFSET_N;
- pp->next=0;
- if (is->method->debug >3)
- logf(LOG_LOG,"isamd_build: Alloc2 f=%d (%d:%d) n=%d(%d:%d)",
- isamd_addr(firstpp->pos,firstpp->cat),
- firstpp->cat, firstpp->pos,
- isamd_addr(pp->pos,pp->cat), pp->cat, pp->pos );
- }
- else
- { /* it was not the first block */
- newblock = isamd_alloc_block(is, firstpp->cat);
- pp->next = isamd_addr(newblock,firstpp->cat);
- isamd_buildlaterblock(pp);
- isamd_write_block(is,pp->cat,pp->pos,pp->buf);
- pp->size = pp->offset = ISAMD_BLOCK_OFFSET_N;
- pp->next=0;
- pp->cat = firstpp->cat;
- pp->pos = isamd_block(firstpp->next);
- }
- /* reset encoging and code again */
- (*is->method->code_reset)(encoder_data);
- c_ptr=codebuff;
- i_ptr=i_item;
- (*is->method->code_item)(ISAMD_ENCODE, encoder_data, &c_ptr, &i_ptr);
- codelen = c_ptr - codebuff;
- assert ( (codelen<128) && (codelen>0));
- if (is->method->debug >3)
- logf(LOG_LOG,"isamd:build: recoded into %s (nk=%d)",
- hexdump(codebuff, c_ptr-codebuff,hexbuff), firstpp->numKeys+1);
- } /* block full */
-
- /* write the data into pp, now we have room */
- memcpy(&(pp->buf[pp->offset]),codebuff,codelen);
- pp->offset += codelen;
- pp->size += codelen;
- firstpp->numKeys++;
- } /* not delete */
-
- /* (try to) read the next item */
- i_ptr = i_item;
- i_more = (*data->read_item)(data->clientData, &i_ptr, &i_mode);
-
- if ( (i_more) && (is->method->debug >3) )
- logf(LOG_LOG,"isamd: build_fi start: m=%d %s",
- i_mode, hexdump(i_item,i_ptr-i_item,hexbuff) );
-
-
- } /* i_more */