Пример #1
0
static as_rec *
ldt_aerospike_crec_open(const as_aerospike * as, const as_rec *rec, const char *bdig)
{
	static char * meth = "ldt_aerospike_crec_open()";
	if (!as || !rec || !bdig) {
		cf_warning(AS_LDT, "ldt_aerospike_crec_open: Invalid Parameters [as=%p, record=%p digest=%p]... Fail", meth, as, rec, bdig);
		return NULL;
	}
	cf_digest keyd;
	if (as_ldt_string_todigest(bdig, &keyd)) {
		return NULL;
	}
	ldt_record *lrecord = (ldt_record *)as_rec_source(rec);
	if (!lrecord) {
		return NULL;
	}
	if (!udf_record_ldt_enabled(lrecord->h_urec)) {
		cf_warning(AS_LDT, "Large Object Not Enabled... Fail");
		return NULL;
	}
	as_ldt_subdigest_setversion(&keyd, lrecord->version);
	ldt_slot    *lslotp = NULL;
	int rv              = crec_open(lrecord, &keyd, &lslotp);
	if (rv) {
		// This basically means the record is not found.
		// Do we need to propagate error message rv
		// back somehow
		cf_info_digest(AS_LDT, &keyd, "%s Failed to open Sub Record rv=%d %ld", bdig, rv, lrecord->version);
		return NULL;
	} else {
		as_val_reserve(lslotp->c_urec_p);
		return lslotp->c_urec_p;
	}
}
Пример #2
0
static int
ldt_aerospike_crec_update(const as_aerospike * as, const as_rec *crec)
{
	cf_detail(AS_LDT, "[ENTER] as(%p) subrec(%p)", as, crec );
	if (!as || !crec) {
		cf_warning(AS_LDT, "ldt_aerospike_crec_update: Invalid Parameters [as=%p, record=%p subrecord=%p]... Fail", as, crec);
		return 2;
	}
	if (!udf_record_ldt_enabled(crec)) {
		cf_warning(AS_LDT, "Large Object Not Enabled... Fail");
		return 3;
	}

	udf_record   * c_urecord = (udf_record *)as_rec_source(crec);
	if (!c_urecord) {
		cf_warning(AS_LDT, "ldt_aerospike_crec_update: Internal Error [Malformed Sub Record]... Fail!!");
		return -1;
	}
	ldt_record   * lrecord  = (ldt_record *)c_urecord->lrecord;
	if (!lrecord) {
		cf_warning(AS_LDT, "ldt_aerospike_crec_update: Internal Error [Invalid Head Record Reference in Sub Record]... Fail!!");
		return -1;
	}
	as_aerospike * las  = lrecord->as;
	cf_detail(AS_LDT, "Calling as_aerospike_rec_update() ldt_aerospike_crec_update");
	return as_aerospike_rec_update(las, crec);
}
Пример #3
0
/**
 * Set the Record Type bits for a record. Typically, this is how we show that
 * a record is of type LDT (which requires special handling). This function
 * allows us to either SET the record type (the "bits" parm is positive), or
 * UNSET the record type (the "bits" parm is negative).  When we want to
 * turn an "LDT Record" back into a "Normal Record", then we UNSET the LDT
 * flag (with a negative bits value).
 */
static int
udf_record_set_type(const as_rec * rec,  int8_t ldt_rectype_bit_update)
{
	if (!rec || !ldt_rectype_bit_update) {
		cf_warning(AS_UDF, "Invalid Paramters: record=%p rec_type_bits=%d", rec, ldt_rectype_bit_update);
		return 2;
	}
	int ret = udf_record_param_check(rec, UDF_BIN_NONAME, __FILE__, __LINE__);
	if (ret) {
		return ret;
	}

	if (!udf_record_ldt_enabled(rec)
			&& (as_ldt_flag_has_parent(ldt_rectype_bit_update)
				|| as_ldt_flag_has_sub(ldt_rectype_bit_update))) {
		cf_warning(AS_LDT, "Cannot Set Large Object Bits .. Not Enabled !!");
		return -2;
	}

	udf_record * urecord = (udf_record *) as_rec_source(rec);
	if (!(urecord->flag & UDF_RECORD_FLAG_ALLOW_UPDATES)) {
		return -1;
	}

	urecord->ldt_rectype_bit_update = ldt_rectype_bit_update;
	cf_detail(AS_RW, "TO URECORD FROM LUA   Digest=%"PRIx64" bits %d",
			  *(uint64_t *)&urecord->rd->keyd.digest[8], urecord->ldt_rectype_bit_update);

	urecord->flag |= UDF_RECORD_FLAG_METADATA_UPDATED;

	return 0;
}
Пример #4
0
static as_rec *
ldt_aerospike_crec_create(const as_aerospike * as, const as_rec *rec)
{
	static char * meth = "ldt_aerospike_crec_create()";
	if (!as || !rec) {
		cf_warning(AS_LDT, "%s: Invalid Parameters [as=%p, record=%p]... Fail", meth, as, rec);
		return NULL;
	}
	ldt_record *lrecord = (ldt_record *)as_rec_source(rec);
	if (!lrecord) {
		return NULL;
	}
	if (!udf_record_ldt_enabled(lrecord->h_urec)) {
		cf_warning(AS_LDT, "Large Object Not Enabled !!... Fail");
		return NULL;
	}
	cf_detail(AS_LDT, "ldt_aerospike_crec_create");
	return crec_create(lrecord);
}