func.c
/* We use own implementation of string match instead of PostgreSQL textlike and texticlike functions
 * because:
 * - them are 1/3 faster: 150 vs 240 msec for performing 10 million case sensitive matches.
 * - testiclike is no reetntrant: it used palloc. And in PostgreSQL it is more than 3 times slower than
 *   case sensitive matches, while in our implementation the diffirence is much smaller - 40%
 * - character elements of timeseries are expected to be ASCII.
 */
We use own implementation of string match instead of PostgreSQL textlike and texticlike functions
because:
- them are 1/3 faster: 150 vs 240 msec for performing 10 million case sensitive matches.
- testiclike is no reetntrant: it used palloc. And in PostgreSQL it is more than 3 times slower than
case sensitive matches, while in our implementation the diffirence is much smaller - 40%
- character elements of timeseries are expected to be ASCII.
We use own implementation of string match instead of PostgreSQL textlike and texticlike functions because : - them are 1 / 3 faster : 150 vs 240 msec for performing 10 million case sensitive matches . - testiclike is no reetntrant : it used palloc . And in PostgreSQL it is more than 3 times slower than case sensitive matches while in our implementation the diffirence is much smaller - 40% - character elements of timeseries are expected to be ASCII .
static inline bool imcs_match_string(char const* str, size_t str_len, char const* pattern)
{
    char const* wildcard = NULL;
    char const* strpos = NULL;
    char const* end  = str + str_len;
    bool value;
    while (true) {
        if (*pattern == MATCH_ANY_SUBSTRING) {
            wildcard = ++pattern;
            strpos = str;
        } else if (str == end || *str == '\0') {
            value = (*pattern == '\0');
            break;
        } else if (*pattern == ESCAPE_CHAR && pattern[1] == *str) {
            str += 1;
            pattern += 2;
        } else if (*pattern != ESCAPE_CHAR
                   && (*str == *pattern || *pattern == MATCH_ANY_ONE_CHAR))
        {
            str += 1;
            pattern += 1;
        } else if (wildcard) {
            str = ++strpos;
            pattern = wildcard;
        } else {
            value = false;
            break;
        }
    }
    return value;
}
static inline bool imcs_match_string ( char const * str , size_t str_len , char const * pattern ) { char const * wildcard = NULL ; char const * strpos = NULL ; char const * end = str + str_len ; bool value ; while ( true ) { if ( * pattern == MATCH_ANY_SUBSTRING ) { wildcard = ++ pattern ; strpos = str ; } else if ( str == end || * str == ' \0 ' ) { value = ( * pattern == ' \0 ' ) ; break ; } else if ( * pattern == ESCAPE_CHAR && pattern [ 1 ] == * str ) { str += 1 ; pattern += 2 ; } else if ( * pattern != ESCAPE_CHAR && ( * str == * pattern || * pattern == MATCH_ANY_ONE_CHAR ) ) { str += 1 ; pattern += 1 ; } else if ( wildcard ) { str = ++ strpos ; pattern = wildcard ; } else { value = false ; break ; } } return value ; }
We use own implementation of string match instead of PostgreSQL textlike and texticlike functions
 because:
 - them are 1/3 faster: 150 vs 240 msec for performing 10 million case sensitive matches.
We use own implementation of string match instead of PostgreSQL textlike and texticlike functions because : - them are 1 / 3 faster : 150 vs 240 msec for performing 10 million case sensitive matches .