public static QueryQueueOptions createFromEnv() {
        if (!Config.enable_query_queue_v2) {
            return new QueryQueueOptions(false, V2.DEFAULT);
        }

        V2 v2 = new V2(Config.query_queue_v2_concurrency_level,
                BackendResourceStat.getInstance().getNumBes(),
                BackendResourceStat.getInstance().getAvgNumHardwareCoresOfBe(),
                BackendResourceStat.getInstance().getAvgMemLimitBytes(),
                Config.query_queue_v2_num_rows_per_slot,
                Config.query_queue_v2_cpu_costs_per_slot);
        return new QueryQueueOptions(true, v2);
    }
@Test
    public void testCreateFromEnv() {
        {
            Config.enable_query_queue_v2 = false;
            QueryQueueOptions opts = QueryQueueOptions.createFromEnv();

            assertThat(opts.isEnableQueryQueueV2()).isFalse();
        }

        {
            final int numCores = 16;
            final long memLimitBytes = 64L * 1024 * 1024 * 1024;
            final int numBEs = 2;
            final int concurrencyLevel = Config.query_queue_v2_concurrency_level;

            BackendResourceStat.getInstance().setNumHardwareCoresOfBe(1, numCores);
            BackendResourceStat.getInstance().setMemLimitBytesOfBe(1, memLimitBytes);
            BackendResourceStat.getInstance().setNumHardwareCoresOfBe(2, numCores);
            BackendResourceStat.getInstance().setMemLimitBytesOfBe(2, memLimitBytes);
            Config.enable_query_queue_v2 = true;
            QueryQueueOptions opts = QueryQueueOptions.createFromEnv();

            assertThat(opts.isEnableQueryQueueV2()).isTrue();
            assertThat(opts.v2().getNumWorkers()).isEqualTo(numBEs);
            assertThat(opts.v2().getNumRowsPerSlot()).isEqualTo(Config.query_queue_v2_num_rows_per_slot);
            assertThat(opts.v2().getTotalSlots()).isEqualTo(concurrencyLevel * numBEs * numCores);
            assertThat(opts.v2().getMemBytesPerSlot()).isEqualTo(memLimitBytes / concurrencyLevel / numCores);
            assertThat(opts.v2().getTotalSmallSlots()).isEqualTo(numCores);
        }
    }