示例#1
0
int
ai_findandset_imatch(as_sindex_metadata *imd, as_sindex_pmetadata *pimd, int idx)
{
	if (!Num_tbls) {
		return AS_SINDEX_ERR;
	}

	char *tname = NULL, *cname = NULL, *iname = NULL;
	int ret = AS_SINDEX_OK;

	if (!(tname = create_tname_from_imd(imd))) {
		return AS_SINDEX_ERR_NO_MEMORY;
	}

	ret = AS_SINDEX_ERR;

	AI_GRLOCK();

	int tmatch = find_table(tname);
	if (tmatch == -1) {
		goto END;
	}
	if (imd->iname) {
		if (!(iname = get_iname_from_imd(imd))) {
			ret = AS_SINDEX_ERR_NO_MEMORY;
			goto END;
		}
		char idx_str[NAME_STR_LEN];
		snprintf(idx_str, sizeof(idx_str), "%d", idx);
		char *piname = str_concat(iname, '.', idx_str);
		pimd->imatch = match_partial_index_name(piname);
		cf_free(piname);
	} else {
		if (!(cname = create_cname_from_imd(imd))) {
			ret = AS_SINDEX_ERR_NO_MEMORY;
			goto END;
		}
		icol_t *ic = find_column(tmatch, cname);
		if (!ic) {
			goto END;
		}
		pimd->imatch = find_partial_index(tmatch, ic);
	}
	if (pimd->imatch == -1) {
		SITRACE(imd->si, META, debug, "Index%s: %s not found", imd->iname ? "" : "column-name", imd->iname ? iname : cname);
		goto END;
	}

	ret = AS_SINDEX_OK;

END:

	AI_UNLOCK();

	cf_free(tname);
	cf_free(iname);
	cf_free(cname);

	return ret;
}
示例#2
0
void
ai_set_simatch_by_name(char *ns, char *iname, int *imatch, int *simatch)
{
	char *ai_iname = get_iname(ns, iname);

	*simatch = -1;

	AI_GRLOCK();

	int im = match_index_name(ai_iname);
	if (im != -1) {
		*simatch = Index[im].simatch;
	}

	AI_UNLOCK();

	*imatch = im;
}
示例#3
0
int
ai_btree_dump(char *ns_name, char *setname, char *filename)
{
	char *tname;

	if (!(tname = create_tname(ns_name, setname))) {
		return -1;
	}

	AI_GRLOCK();

	int retval = dump_btree(tname, (filename ? filename : DEFAULT_BTREE_DUMP_FILENAME));

	AI_UNLOCK();

	cf_free(tname);

	return retval;
}
示例#4
0
int
ai_findandset_imatch(as_sindex_metadata *imd, as_sindex_pmetadata *pimd, int idx)
{
	if (!Num_tbls) {
		return AS_SINDEX_ERR;
	}

	char *tname = NULL;
	char *cname = NULL;
	char *iname = NULL;

	if (!(tname = create_tname_from_imd(imd))) {
		return AS_SINDEX_ERR_NO_MEMORY;
	}

	int ret = AS_SINDEX_ERR;

	AI_GRLOCK();

	int tmatch = find_table(tname);
	if (tmatch == -1) {
		goto END;
	}
	if (imd->iname) {
		// This is always true
		if (!(iname = get_iname_from_imd(imd))) {
			ret = AS_SINDEX_ERR_NO_MEMORY;
			goto END;
		}
		
		char piname[INDD_HASH_KEY_SIZE];
		snprintf(piname, sizeof(piname), "%s.%d", iname, idx);	
		pimd->imatch = match_partial_index_name(piname);
	} else {
		// CAUTION : This will not work. Since ci->list is only populated for 0th pimd
		if (!(cname = create_cname_from_imd(imd))) {
			ret = AS_SINDEX_ERR_NO_MEMORY;
			goto END;
		}
		icol_t *ic = find_column(tmatch, cname);
		if (!ic) {
			goto END;
		}
		pimd->imatch = find_partial_index(tmatch, ic);
		cf_free(ic);
	}
	if (pimd->imatch == -1) {
		cf_debug(AS_SINDEX, "Index %s not found for %dth pimd", imd->iname, idx);
		goto END;
	}

	ret = AS_SINDEX_OK;

END:

	AI_UNLOCK();

	if (tname) {
		cf_free(tname);
	}
	if (iname) { 
		cf_free(iname);
	}
	if (cname) {
		cf_free(cname);
	}
	return ret;
}