Esempio n. 1
0
static int check_bin2(as_record * rec, scan_check * check)
{
	as_val * bin = (as_val *) as_record_get(rec, "bin2");
	if ( !bin ) {
		error("Expected a value in bin('%s'), but got null", "bin2");
		return !(check->failed = true);
	}
	
	as_string * string = as_string_fromval(bin);
	if ( !string ) {
		error("Expected a string in bin('%s'), but got type %d", "bin2", as_val_type(bin));
		return !(check->failed = true);
	}
	
	char * str = as_string_get(string);
	if ( !str ) {
		error("Expected a string value but it is NULL");
		return !(check->failed = true);
	}

	// Check the string bin
	char expected[SET_STRSZ];
	int64_t bin1 = as_record_get_int64(rec, "bin1", INT64_MIN);
	sprintf(expected, "str-%s-%" PRId64, rec->key.set[0] == '\0' ? "noset" : rec->key.set, bin1);

	if (strcmp(expected, str) != 0) {
		error("Expected '%s' in bin('%s'), but got '%s'", expected, "bin2", str);
		return !(check->failed = true);
	}

	return !(check->failed = false);
}
bool batch_get_1_callback(const as_batch_read * results, uint32_t n, void * udata)
{
    batch_read_data * data = (batch_read_data *) udata;

    data->total = n;

    for (uint32_t i = 0; i < n; i++) {

        if (results[i].result == AEROSPIKE_OK) {
            data->found++;

            int64_t key = as_integer_getorelse((as_integer *) results[i].key->valuep, -1);
            int64_t val = as_record_get_int64(&results[i].record, "val", -1);
            if ( key != val ) {
                warn("key(%d) != val(%d)",key,val);
                data->errors++;
                data->last_error = -2;
            }
        }
        else if (results[i].result != AEROSPIKE_ERR_RECORD_NOT_FOUND) {
            data->errors++;
            data->last_error = results[i].result;
            warn("batch callback thread(%d) error(%d)", data->thread_id, data->last_error);
        }
    }

    info("total: %d, found: %d, errors: %d", data->total, data->found, data->errors);

    return true;
}
static void
as_get_callback1(as_error* err, as_record* rec, void* udata, as_event_loop* event_loop)
{
	assert_success_async(&monitor, err, udata);
	
    assert_int_eq_async(&monitor, as_record_numbins(rec), 1);
    assert_int_eq_async(&monitor, as_record_get_int64(rec, "a", 0), 123);
	as_monitor_notify(&monitor);
}
Esempio n. 4
0
void SourceRecord::record(const as_record & record)
{
	time_ = as_record_get_int64(&record, "latest_time", -1);
	advId_ = as_record_get_str(&record, "adv_id");
	sid_ = as_record_get_str(&record, "sid");
	adxId_ = as_record_get_str(&record, "adx_id");
	mtUid_ = as_record_get_str(&record, "mt_uid");
	pid_ = as_record_get_str(&record, "pid");
	requestId_ = as_record_get_str(&record, "request_id");
	createId_ = as_record_get_str(&record, "create_id");
	geoId_ = as_record_get_str(&record, "geo_id");
	refererUrl_ = as_record_get_str(&record, "referer_url");
	bidPrice_ = as_record_get_str(&record, "bid_price");
}
Esempio n. 5
0
static bool batch_sequence_callback(as_key* key, as_record* record, void* udata)
{
	batch_read_data* data = (batch_read_data*)udata;

	data->total++;
	data->found++;

	int64_t k = as_integer_getorelse((as_integer *)key->valuep, -1);
	int64_t v = as_record_get_int64(record, "val", -1);
	if (k != v) {
		warn("key(%d) != val(%d)", k, v);
		data->errors++;
		data->last_error = -2;
	}
	return true;
}
Esempio n. 6
0
static bool check_bin3(as_record * rec, scan_check * check)
{
	as_val * bin = (as_val *) as_record_get(rec, "bin3");
	if ( !bin ) {
		error("Expected a value in bin('%s'), but got null", "bin3");
		return !(check->failed = true);
	}

	as_map * map = as_map_fromval(bin);
	if ( !map ) {
		error("Expected a map in bin('%s'), but got type %d", "bin3", as_val_type(bin));
		return !(check->failed = true);
	}

	int sz = as_map_size(map);
	if ( sz != 3 ) {
		error("Expected map size of %d, but got %d", 3, sz);
		return !(check->failed = true);
	} 

	int64_t bin1 = as_record_get_int64(rec, "bin1", INT64_MIN);
	int64_t ival = 0;

	ival = as_stringmap_get_int64(map, "x");
	if ( ival != bin1 ) {
		error("Expected map value '%s'=%ld, but got %ld", "x", bin1, ival);
		return !(check->failed = true);
	}
	
	ival = as_stringmap_get_int64(map, "y");
	if ( ival != bin1+1 ) {
		error("Expected map value '%s'=%ld, but got %ld", "y", bin1+1, ival);
		return !(check->failed = true);
	}

	ival = as_stringmap_get_int64(map, "z");
	if ( ival != bin1+2 ) {
		error("Expected map value '%s'=%ld, but got %ld", "z", bin1+2, ival);
		return !(check->failed = true);
	}

	return !(check->failed = false);
}
Esempio n. 7
0
bool asc_size(aerospike *p_as, char *ns, char *file, uint32_t *size)
{
    as_status status;
    as_error err;

    // Prepare the key
    as_key key;
    as_key_init_str(&key, ns, SET, file);

    // Read metadata
    as_record *rec = NULL;
    status = aerospike_key_get(p_as, &err, NULL, &key, &rec);
    if (status != AEROSPIKE_OK) {
        ERROR("aerospike_key_get() returned %d - %s", err.code, err.message);
        return false;
    }
    *size = as_record_get_int64(rec, "size", 0);
    as_record_destroy(rec);

    return true;
}