public List<LoadJob> getLoadJobsByDb(long dbId, String labelValue, boolean accurateMatch) {
        List<LoadJob> loadJobList = Lists.newArrayList();
        readLock();
        try {
            if (dbId != -1 && !dbIdToLabelToLoadJobs.containsKey(dbId)) {
                return loadJobList;
            }

            for (Map<String, List<LoadJob>> dbJobs : dbIdToLabelToLoadJobs.values()) {
                Map<String, List<LoadJob>> labelToLoadJobs = dbId == -1 ? dbJobs : dbIdToLabelToLoadJobs.get(dbId);

                if (Strings.isNullOrEmpty(labelValue)) {
                    loadJobList.addAll(labelToLoadJobs.values()
                            .stream().flatMap(Collection::stream).collect(Collectors.toList()));
                } else {
                    // check label value
                    if (accurateMatch) {
                        if (!labelToLoadJobs.containsKey(labelValue)) {
                            return loadJobList;
                        }
                        loadJobList.addAll(labelToLoadJobs.get(labelValue));
                    } else {
                        // non-accurate match
                        for (Map.Entry<String, List<LoadJob>> entry : labelToLoadJobs.entrySet()) {
                            if (entry.getKey().contains(labelValue)) {
                                loadJobList.addAll(entry.getValue());
                            }
                        }
                    }
                }
                if (dbId != -1) {
                    break;
                }
            }
            return loadJobList;
        } finally {
            readUnlock();
        }
    }
@Test
    public void testGetLoadJobsByDb(@Mocked GlobalStateMgr globalStateMgr) throws MetaNotFoundException {
        LoadMgr loadMgr = new LoadMgr(new LoadJobScheduler());
        LoadJob job1 = new InsertLoadJob("job1", 1L, 1L, System.currentTimeMillis(), "", "", null);
        Deencapsulation.invoke(loadMgr, "addLoadJob", job1);
        Assert.assertTrue(loadMgr.getLoadJobsByDb(2L, "job1", true).isEmpty());
        Assert.assertEquals(1, loadMgr.getLoadJobsByDb(1L, "job1", true).size());
    }