int tc_verify_cmp(struct tc_spaces *s, uint64_t lsn, struct tnt_iter_storage *is, struct tnt_stream_snapshot *ss) { struct tc_space *space = tc_space_match(s, ss->log.current.row_snap.space); if (space == NULL) return -1; int rc = 0; struct tc_key *k = tc_generate_key(space, &is->t); if (k == NULL) { printf("failed to create key\n"); rc = -1; goto done; } /* 1. check in hash, if found then skip */ const struct tc_key *node = k; mh_int_t pos = mh_pk_get(space->hash_log, &node, space, space); const struct tc_key *v = NULL; if (pos != mh_end(space->hash_log)) v = *mh_pk_node(space->hash_log, pos); if (v) { rc = 0; goto done; } /* 2. if key was not found in xlog hash, then try snapshot hash */ node = k; pos = mh_pk_get(space->hash_snap, &node, space, space); v = NULL; if (pos != mh_end(space->hash_snap)) v = *mh_pk_node(space->hash_snap, pos); if (v) { /* generate and compare checksum */ uint32_t crc = crc32c(0, (unsigned char*)is->t.data, is->t.size); if (crc != v->crc) { printf("(snapshot %"PRIu64") checksum missmatch\n", lsn); rc = -1; } } else { /* not found */ printf("(snapshot %"PRIu64") key missed\n", lsn); rc = -1; } done: free(k); return rc; }
static int memtx_bitset_index_register_tuple(struct memtx_bitset_index *index, struct tuple *tuple) { uint32_t id; struct tuple **place; if (index->spare_id != SPARE_ID_END) { id = index->spare_id; void *mem = matras_get(index->id_to_tuple, id); index->spare_id = *(uint32_t *)mem; place = (struct tuple **)mem; } else { place = (struct tuple **)matras_alloc(index->id_to_tuple, &id); } *place = tuple; struct bitset_hash_entry entry; entry.id = id; entry.tuple = tuple; uint32_t pos = mh_bitset_index_put(index->tuple_to_id, &entry, 0, 0); if (pos == mh_end(index->tuple_to_id)) { *(uint32_t *)tuple = index->spare_id; index->spare_id = id; diag_set(OutOfMemory, (ssize_t) pos, "hash", "key"); return -1; } return 0; }