Exemple #1
0
static int
merge_output(Bucket *r, SetIteration *i, int mapping)
{
    if (r->len >= r->size && Bucket_grow(r, -1, !mapping) < 0)
	return -1;
    COPY_KEY(r->keys[r->len], i->key);
    INCREF_KEY(r->keys[r->len]);
    if (mapping) {
	COPY_VALUE(r->values[r->len], i->value);
	INCREF_VALUE(r->values[r->len]);
    }
    r->len++;
    return 0;
}
Exemple #2
0
static int
nextBTreeItems(SetIteration *i)
{
  if (i->position >= 0)
    {
      if (i->position)
        {
          DECREF_KEY(i->key);
          DECREF_VALUE(i->value);
        }

      if (BTreeItems_seek(ITEMS(i->set), i->position) >= 0)
        {
          Bucket *currentbucket;

          currentbucket = BUCKET(ITEMS(i->set)->currentbucket);
          UNLESS(PER_USE(currentbucket))
            {
              /* Mark iteration terminated, so that finiSetIteration doesn't
               * try to redundantly decref the key and value
               */
              i->position = -1;
              return -1;
            }

          COPY_KEY(i->key, currentbucket->keys[ITEMS(i->set)->currentoffset]);
          INCREF_KEY(i->key);

          COPY_VALUE(i->value,
                     currentbucket->values[ITEMS(i->set)->currentoffset]);
          INCREF_VALUE(i->value);

          i->position ++;

          PER_UNUSE(currentbucket);
        }
      else
        {