Exemple #1
0
MojErr MojDbQueryPlan::pushSearch(MojDbKeyBuilder& lowerBuilder, MojDbKeyBuilder& upperBuilder,
		const MojObject& val, MojDbTextCollator* collator)
{
	// get text
	MojString text;
	MojErr err = val.stringValue(text);
	MojErrCheck(err);
	MojDbKeyBuilder::KeySet toks;

	// tokenize
	MojRefCountedPtr<MojDbTextTokenizer> tokenizer(new MojDbTextTokenizer);
	MojAllocCheck(tokenizer.get());
	err = tokenizer->init(m_locale);
	MojErrCheck(err);
	err = tokenizer->tokenize(text, collator, toks);
	MojErrCheck(err);

	// remove prefixes
	MojDbKeyBuilder::KeySet::Iterator i;
	err = toks.begin(i);
	MojErrCheck(err);
	MojDbKeyBuilder::KeySet::ConstIterator prev = toks.end();
	while (i != toks.end()) {
		if (prev != toks.end() && prev->stringPrefixOf(*i)) {
			bool found = false;
			err = toks.del(*prev, found);
			MojErrCheck(err);
			MojAssert(found);
		}
		prev = i;
		++i;
	}

	// push toks
	err = lowerBuilder.push(toks);
	MojErrCheck(err);
	err = upperBuilder.push(toks);
	MojErrCheck(err);
	m_groupCount = (MojUInt32) toks.size();

	return MojErrNone;
}
Exemple #2
0
MojErr MojDbIndex::getKeys(const MojObject& obj, KeySet& keysOut) const
{
    LOG_TRACE("Entering function %s", __FUNCTION__);

	// build the set of unique keys from object
	MojDbKeyBuilder builder;
	MojErr err = builder.push(m_idSet);
	MojErrCheck(err);
	MojSize idx = 0;
	for (PropVec::ConstIterator i = m_props.begin();
		 i != m_props.end();
		 ++i, ++idx) {
		KeySet vals;
		err = (*i)->vals(obj, vals);
		MojErrCheck(err);
		err = builder.push(vals);
		MojErrCheck(err);
	}
	err = builder.keys(keysOut);
	MojErrCheck(err);

	return MojErrNone;
}
Exemple #3
0
MojErr MojDbQueryPlan::pushVal(MojDbKeyBuilder& builder, const MojObject& val, MojDbTextCollator* collator)
{
	MojErr err = MojErrNone;
	MojDbKey key;
	MojDbKeyBuilder::KeySet keys;
	if (val.type() == MojObject::TypeArray) {
		MojObject::ConstArrayIterator end = val.arrayEnd();
		for (MojObject::ConstArrayIterator i = val.arrayBegin(); i != end; ++i) {
			err = key.assign(*i, collator);
			MojErrCheck(err);
			err = keys.put(key);
			MojErrCheck(err);
		}
	} else {
		err = key.assign(val, collator);
		MojErrCheck(err);
		err = keys.put(key);
		MojErrCheck(err);
	}
	err = builder.push(keys);
	MojErrCheck(err);

	return MojErrNone;
}