Resolves #17: Update explain() output with user readable keys#208
Resolves #17: Update explain() output with user readable keys#208drkannan wants to merge 4 commits intoFoundationDB:masterfrom
Conversation
|
Can one of the admins verify this patch? |
3 similar comments
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
@apkar could you please verify this patch |
|
@fdb-build test this please |
src/QLPlan.actor.h
Outdated
| std::string bound_end = end.present() ? FDB::printable(end.get()) : "+inf"; | ||
| // #17: Added decode_key_part to update explain output with user readable keys | ||
| std::string bound_begin = begin.present() ? DataValue::decode_key_part(begin.get()).toString() : "-inf"; | ||
| std::string bound_end = end.present() ? DataValue::decode_key_part(begin.get()).toString() : "+inf"; |
There was a problem hiding this comment.
Shouldn't this be end.get() ?
There was a problem hiding this comment.
Also, this logic would work if there is only one dimension in the index. As decode_key_part assumes there is only one element in the key. It checks type on the first byte only. If you have a compound index, then the key could be multi element tuple and this would fail.
For example, following explain() would fail.
db.coll.create_index([('a', 1), ('b', 1)])
db.coll.find({'a': 'A', 'b': 64}).explain()You can use decode_bytes() to create DataKey. Once you have DataKey, you can iterate over different elements in the key to print them by their type.
There was a problem hiding this comment.
Thanks @apkar . Will look into it.
|
@fdb-build test this please |
|
@fdb-build test this please |
|
@senthil-db-expert Can you give some explanation on the usage of |
|
@apkar Added explanations and test cases. |
| MIN_KEY = 0, | ||
| NULL_ELEMENT = 20, | ||
| NUMBER = 30, | ||
| SPL_CHAR = 31, // ASCII value for SPL_CHAR = 31 is '\0x1f' |
There was a problem hiding this comment.
Predicates like $gt, $gte, $lt, $lte etc.. use RANGE type predicate. To create a unended bound we create element with type code + 1, to match everything in that range or vice versa. Range can be on any type, not necessary just on numbers. For example, this code breaks on a query like
db.coll.find({'a': {'$gt': 'hello'}}).explain()
Which is a valid query. You can look at the following code to get better understanding of how ranges are created with one bound.
https://github.com/FoundationDB/fdb-document-layer/blob/master/src/ExtOperator.actor.cpp#L72
There was a problem hiding this comment.
@apkar We think RANGE would have some limitations for end key calculations. In Explain, we will not be able to give detailed output for inputs like $gt 10, $gt abc etc... because RANGE adds +1 to the typecode and returns as string. Whereas, if we add typecode + 1 for each of the enum in DVTypeCode, then we can handle end limit for any type and also the decode_bytes would work as expected. This will be similar to OBJECT-PACKED_OBJECT and ARRAY-PACKED_ARRAY. What do you think?
This PR resolves #17
Explain() output will be much more useful if the keys are user readable, instead of FDB keys. Used the existing decode_key_part function to achieve this.