package com.tencent.mm.plugin.fav.b.a;

import android.database.Cursor;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.fts.a.a.g;
import com.tencent.mm.plugin.fts.a.a.h;
import com.tencent.mm.plugin.fts.a.a.i;
import com.tencent.mm.plugin.fts.a.a.j;
import com.tencent.mm.plugin.fts.a.a.m;
import java.util.ArrayList;
import java.util.HashSet;

class b$f extends h {
    final /* synthetic */ b mgH;

    b$f(b bVar, i iVar) {
        this.mgH = bVar;
        super(iVar);
    }

    public final String getName() {
        return "SearchTopFavoriteTask";
    }

    public final int getId() {
        return 9;
    }

    public final void a(j jVar) {
        InterruptedException interruptedException;
        AppMethodBeat.i(5310);
        jVar.mDz = g.aO(this.mEl.query, true);
        a aVar = this.mgH.mgE;
        int i = this.mEl.mEt + 1;
        String bAl = jVar.mDz.bAl();
        Cursor rawQuery = aVar.mBT.rawQuery(String.format("SELECT %s.docid, type, subtype, entity_id, aux_index, timestamp FROM %s NOT INDEXED JOIN %s ON (%s.docid = %s.rowid) WHERE %s MATCH '%s' ORDER BY -timestamp, subtype limit " + (i + 1) + ";", new Object[]{aVar.bAf(), aVar.bAf(), aVar.bAg(), aVar.bAf(), aVar.bAg(), aVar.bAg(), bAl}), null);
        jVar.mEy = new ArrayList();
        HashSet hashSet = new HashSet();
        while (rawQuery.moveToNext()) {
            if (hashSet.add(String.valueOf(rawQuery.getLong(3)))) {
                jVar.mEy.add(new m().k(rawQuery));
                if (jVar.mEy.size() > this.mEl.mEt) {
                    break;
                } else if (Thread.interrupted()) {
                    rawQuery.close();
                    interruptedException = new InterruptedException();
                    AppMethodBeat.o(5310);
                    throw interruptedException;
                }
            }
        }
        rawQuery.close();
        if (Thread.interrupted()) {
            interruptedException = new InterruptedException();
            AppMethodBeat.o(5310);
            throw interruptedException;
        }
        AppMethodBeat.o(5310);
    }
}
