public double weight() {
        double w = 0;
        if (user != null) {
            w += 1;
        }
        if (role != null) {
            w += 1;
        }
        if (planCpuCostRange != null) {
            w += 1;
        }
        if (planMemCostRange != null) {
            w += 1;
        }
        if (queryTypes != null && !queryTypes.isEmpty()) {
            w += 1 + 0.1 / queryTypes.size();
        }
        if (sourceIp != null) {
            w += 1 + NetUtils.getCidrPrefixLength(sourceIp) / 64.0;
        }
        if (CollectionUtils.isNotEmpty(databaseIds)) {
            w += 10.0 * databaseIds.size();
        }
        return w;
    }
@Test
    public void testWeight() {
        ResourceGroupClassifier classifier = new ResourceGroupClassifier();

        for (int i = 0; i <= 32; i++) {
            classifier.setSourceIp("192.168.0.1/" + i);
            assertThat(classifier.weight()).isCloseTo(1 + i / 64., within(1e-5));
        }
    }