//-------------------------------------------------------------------------------------- // read_likes() // // Reads trainUsers.json and generates containers train_u and likes //-------------------------------------------------------------------------------------- void read_likes(char const* file_name) { myout << endl << clock()/CLOCKS_PER_SEC << "s\t read_likes: " << file_name << flush; ifstream infile(file_name); string line; getline(infile, line, '\n'); while (!infile.eof()) { int size = line.size(); char* buf = new char[size]; line.copy(buf, size); char* sz = buf; buf[size-1]=0; bool in_test = read_json_bool(sz, "inTestSet"); int uid = read_json_str2int(sz, "uid"); train_u.push_back(uid); if (in_test) test_u.push_back(uid); int bid = read_json_str2int(sz, "blog"); while(bid) { int pid = read_json_str2int(sz, "post_id"); time_t time = read_json_time(sz, "like_dt"); likes.insert(Like(uid, bid, pid, time)); bid = read_json_str2int(sz, "blog"); } getline(infile, line, '\n'); delete[] buf; } infile.close(); }
SqlBool LikeSmartWild(const SqlVal& exp, const String& text) { const char *s = text; if(*s == 0) return SqlBool::True(); if((*s == '.' && s[1] != 0 && *++s != '.') || HasNlsLetters(WString(s))) { SqlBool e = Like(Upper(exp), Wild(ToUpper(s))); if(ToUpper((byte)*s) == 'C' && s[1] == 0) e &= NotLike(Upper(exp), "CH%"); // CH patch return e; } else return LikeUpperAscii(exp, Wild(s)); }
SqlBool LikeUpperAscii(const SqlVal& a, const SqlVal& b) { return Like(UpperAscii(a), UpperAscii(b)); }
bool StringFunctions::Like(UNUSED_ATTRIBUTE executor::ExecutorContext &ctx, const char *t, uint32_t tlen, const char *p, uint32_t plen) { PELOTON_ASSERT(t != nullptr); PELOTON_ASSERT(p != nullptr); if (plen == 1 && *p == '%') return true; while (tlen > 0 && plen > 0) { if (*p == '\\') { NextByte(p, plen); if (plen <= 0) return false; if (tolower(*p) != tolower(*t)) return false; } else if (*p == '%') { char firstpat; NextByte(p, plen); while (plen > 0) { if (*p == '%') NextByte(p, plen); else if (*p == '_') { if (tlen <= 0) return false; NextByte(t, tlen); NextByte(p, plen); } else break; } if (plen <= 0) return true; if (*p == '\\') { if (plen < 2) return false; firstpat = tolower(p[1]); } else firstpat = tolower(*p); while (tlen > 0) { if (tolower(*t) == firstpat) { int matched = Like(ctx, t, tlen, p, plen); if (matched != false) return matched; } NextByte(t, tlen); } return false; } else if (*p == '_') { NextByte(t, tlen); NextByte(p, plen); continue; } else if (tolower(*p) != tolower(*t)) { return false; } NextByte(t, tlen); NextByte(p, plen); } if (tlen > 0) return false; while (plen > 0 && *p == '%') NextByte(p, plen); if (plen <= 0) return true; return false; }