[sqlite] Question: User defined function and auxiliary data for multiple instances on one query
Dear, I'm trying to make a mystrstr function to use it as a sub-function of like. mystrstr function is designed to use boyer-moore algorithm to improve string search performance. (Only for simple substing search, but not a complex search pattern) But, the problem is occurred when this mystrstr function is called two more times on one query. In boyer-moore algorithm, search pattern string should be preprocessed before it is used. I used sqlite3_set_auxdata() and sqlite3_get_auxdata() function to save preprocessed search pattern to call preprocessing process only once. It works very well if I use only one mystrstr function on one query. example) select * from mytable where mystrstr(col1, 'test1') and mystrstr(col2, 'test2'); In this case, mystrstr function is called twice and there are two different search patterns. I can use two aux data slots and can find preprocessed patterns by string compare with original pattern string for each call of mystrstr(). But, I think it is not a good idea, because of string compare can make not necessary processing cost. Could I get some more information of currently called function? For example, If I can get PC(program count of VDBE) from context, this value can be used to distinguish current position of my function on a query. Thank you. Yongil Jang. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Question: User defined function and auxiliary data for multiple instances on one query
On 02/08/2013 12:08 PM, Yongil Jang wrote: Dear, I'm trying to make a mystrstr function to use it as a sub-function of like. mystrstr function is designed to use boyer-moore algorithm to improve string search performance. (Only for simple substing search, but not a complex search pattern) But, the problem is occurred when this mystrstr function is called two more times on one query. In boyer-moore algorithm, search pattern string should be preprocessed before it is used. I used sqlite3_set_auxdata() and sqlite3_get_auxdata() function to save preprocessed search pattern to call preprocessing process only once. It works very well if I use only one mystrstr function on one query. example) select * from mytable where mystrstr(col1, 'test1') and mystrstr(col2, 'test2'); In this case, mystrstr function is called twice and there are two different search patterns. I can use two aux data slots and can find preprocessed patterns by string compare with original pattern string for each call of mystrstr(). But, I think it is not a good idea, because of string compare can make not necessary processing cost. I don't think you should have to do anything special for this to work. SQLite will allocate separate aux-data slots to each invocation. The array of aux-data slots accessed by mystrstr(col1, 'test1') is different to the array accessed by mystrstr(col2, 'test2'). So if the implementation just stores the compiled version of the search pattern in aux-data slot 1 things should just work. Dan. Could I get some more information of currently called function? For example, If I can get PC(program count of VDBE) from context, this value can be used to distinguish current position of my function on a query. Thank you. Yongil Jang. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Question: User defined function and auxiliary data for multiple instances on one query
Thank you, Dan! It really works well as you commented! Thank you again! 2013/2/8 Dan Kennedy danielk1...@gmail.com On 02/08/2013 12:08 PM, Yongil Jang wrote: Dear, I'm trying to make a mystrstr function to use it as a sub-function of like. mystrstr function is designed to use boyer-moore algorithm to improve string search performance. (Only for simple substing search, but not a complex search pattern) But, the problem is occurred when this mystrstr function is called two more times on one query. In boyer-moore algorithm, search pattern string should be preprocessed before it is used. I used sqlite3_set_auxdata() and sqlite3_get_auxdata() function to save preprocessed search pattern to call preprocessing process only once. It works very well if I use only one mystrstr function on one query. example) select * from mytable where mystrstr(col1, 'test1') and mystrstr(col2, 'test2'); In this case, mystrstr function is called twice and there are two different search patterns. I can use two aux data slots and can find preprocessed patterns by string compare with original pattern string for each call of mystrstr(). But, I think it is not a good idea, because of string compare can make not necessary processing cost. I don't think you should have to do anything special for this to work. SQLite will allocate separate aux-data slots to each invocation. The array of aux-data slots accessed by mystrstr(col1, 'test1') is different to the array accessed by mystrstr(col2, 'test2'). So if the implementation just stores the compiled version of the search pattern in aux-data slot 1 things should just work. Dan. Could I get some more information of currently called function? For example, If I can get PC(program count of VDBE) from context, this value can be used to distinguish current position of my function on a query. Thank you. Yongil Jang. __**_ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**usershttp://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users __**_ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**usershttp://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users