Beispiel #1
0
/*
 * function used to facilitate insert sorts for BTREE databases with
 * a datastructure of 2 uint32_t as keys.
 */
static int
bt_compare_fmRpt(DB *dbp, const DBT *in_a, const DBT *in_b)	/* ARGSUSED */
{
	int		st;
	uint32_t	a = 0;
	uint32_t	b = 0;
	uint32_t	c = 0;
	uint32_t	d = 0;
	fmrpt_key_t	*fm;

	if (in_a->size) {
		fm = (fmrpt_key_t *)in_a->data;
		memcpy(&a, &(fm->rptType), 4);
		memcpy(&b, &(fm->snapid), 4);
	}

	if (in_b->size) {
		fm = (fmrpt_key_t *)in_b->data;
		memcpy(&c, &(fm->rptType), 4);
		memcpy(&d, &(fm->snapid), 4);
	}

	st = compare_uint32(a, c);
	if (st == 0) {
		st = compare_uint32(b, d);
	}

	return (st);
}
Beispiel #2
0
static void
test_compare_uint32() {
  uint32_t x = 123;
  uint32_t y = 123;
  uint32_t z = 321;

  assert_true( compare_uint32( ( void * ) &x, ( void * ) &y ) );
  assert_false( compare_uint32( ( void * ) &x, ( void * ) &z ) );
}
Beispiel #3
0
static int
bt_compare_sfid(DB *dbp, const DBT *in_a, const DBT *in_b) /* ARGSUSED */
{
	uint64_t 	a = 0;
	uint64_t	b = 0;
	uint32_t	c = 0;
	uint32_t	d = 0;
	sfid_t		*af;
	sfid_t		*bf;
	int		st;

	if (in_a->size) {
		af = (sfid_t *)(in_a->data);

		memcpy(&a, &(af->fid), 8);
		memcpy(&c, &(af->snapid), 4);
	}

	if (in_b->size) {
		bf = (sfid_t *)(in_b->data);

		memcpy(&b, &(bf->fid), 8);
		memcpy(&d, &(bf->snapid), 4);
	}

	/* compare the snapshot id, oldest first */
	st = compare_uint32(c, d);

	/* if they're equal, secondary sort on file id */
	if (st == 0) {
		st = compare_uint64(a, b);
	}

	return (st);
}
Beispiel #4
0
/*
 * function used to facilitate insert sorts for BTREE databases with
 * fuid_t and sfid_t keys.  As both of these are comprised of 1 uint64_t
 * value and 1 uint32_t value, we can use the same compare function.
 */
static int
bt_compare_fuid(DB *dbp, const DBT *in_a, const DBT *in_b) /* ARGSUSED */
{
	uint64_t 	a = 0;
	uint64_t	b = 0;
	uint32_t	c = 0;
	uint32_t	d = 0;
	fuid_t		*af;
	fuid_t		*bf;
	int		st;

	/* compare the first uint64_t */
	if (in_a->size) {
		af = (fuid_t *)(in_a->data);
		memcpy(&a, &(af->fid), 8);
		memcpy(&c, &(af->mtime), 4);
	}

	if (in_b->size) {
		bf = (fuid_t *)(in_b->data);
		memcpy(&b, &(bf->fid), 8);
		memcpy(&d, &(bf->mtime), 4);
	}

	st = compare_uint64(a, b);

	/* if they're equal, subsort on second value */
	if (st == 0) {
		/* reverse sort - newer first */
		st = compare_uint32(d, c);
	}

	return (st);
}
Beispiel #5
0
/*
 * function used to facilitate insert sorts for BTREE databases with
 * uint32_t keys.
 */
static int
bt_compare_uint32(DB *dbp, const DBT *in_a, const DBT *in_b) /* ARGSUSED */
{
	uint32_t	a = 0;
	uint32_t	b = 0;

	if (in_a->size) {
		memcpy(&a, in_a->data, 4);
	}

	if (in_b->size) {
		memcpy(&b, in_b->data, 4);
	}

	return (compare_uint32(a, b));
}