private boolean execGenWeights(VectorMap queryParam, StringBuffer respBody, DBAccess dbAccess) {
        try {
            int clntIdx = queryParam.qpIndexOfKeyNoCase("clnt");
            String clientName = (String) queryParam.getVal(clntIdx);

            int baseIdx = queryParam.qpIndexOfKeyNoCase("base");

            String base = null;
            if (baseIdx != -1) {
                base = (String) queryParam.getVal(baseIdx);
                base = base.replace("*", "%");
            }

            int corellationSize = 100000;
            int offset = 0;
            int i = 0;
            String sql = "DELETE FROM " + DBAccess.FEATURE_STATISTICS_TABLE + " WHERE " + DBAccess.FIELD_PSCLIENT + "='" + clientName + "' AND " + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_TYPE + "=" + DBAccess.STATISTICS_FREQUENCY;
            dbAccess.execute(sql);
            sql = "DELETE FROM " + DBAccess.FEATURE_STATISTICS_TABLE + " WHERE " + DBAccess.FIELD_PSCLIENT + "='" + clientName + "' AND " + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_TYPE + "=" + DBAccess.STATISTICS_FREQUENCY_NORMALIZED;
            dbAccess.execute(sql);
            sql = "DELETE FROM " + DBAccess.UFTRASSOCIATIONS_TABLE + " WHERE " + DBAccess.FIELD_PSCLIENT + "='" + clientName + "' AND " + DBAccess.UFTRASSOCIATIONS_TABLE_FIELD_TYPE + "=" + DBAccess.RELATION_PHYSICAL_NORMALIZED;
            dbAccess.execute(sql);

            if (base == null) {
                sql = "SELECT ftr, " + DBAccess.STATISTICS_FREQUENCY + ", sum( f ),'" + clientName + "' FROM ( "
                        + "(SELECT ftr_src ftr, count(*) f FROM "
                        + "user_feature_associations WHERE FK_psclient = '" + clientName + "' GROUP BY ftr "
                        + ") UNION ( "
                        + "SELECT ftr_dst ftr, count(*) f FROM "
                        + "user_feature_associations WHERE FK_psclient = '" + clientName + "' GROUP BY ftr"
                        + ") "
                        + ") AS un_ftr GROUP BY ftr";
            } else {
                sql = "SELECT ftr, " + DBAccess.STATISTICS_FREQUENCY + ", sum( f ),'" + clientName + "' FROM ( "
                        + "(SELECT ftr_src ftr, count(*) f FROM "
                        + "user_feature_associations WHERE FK_psclient = '" + clientName + "' AND ftr_dst LIKE '" + base + "' GROUP BY ftr "
                        + ") UNION ( "
                        + "SELECT ftr_dst ftr, count(*) f FROM "
                        + "user_feature_associations WHERE FK_psclient = '" + clientName + "' AND ftr_src LIKE '" + base + "' GROUP BY ftr"
                        + ") "
                        + ") AS un_ftr GROUP BY ftr";
                //System.out.println( sql );
            }
            sql = "INSERT INTO " + DBAccess.FEATURE_STATISTICS_TABLE + "(" + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_FEATURE + "," + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_TYPE + "," + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_VALUE + "," + DBAccess.FIELD_PSCLIENT + ") "
                    + sql;
            //System.out.println("executing " + sql);
            dbAccess.executeUpdate(sql);
            //System.out.println("executed " + sql);

            if (base == null) {
                sql = "SELECT count(*) FROM " + DBAccess.FEATURE_TABLE + " WHERE " + DBAccess.FIELD_PSCLIENT + "='" + clientName + "'";
            } else {
                sql = "SELECT count(*) FROM " + DBAccess.FEATURE_TABLE + " WHERE " + DBAccess.FIELD_PSCLIENT + "='" + clientName + "' AND " + DBAccess.FEATURE_TABLE_FIELD_FEATURE + " LIKE '" + base + "'";
            }
            ResultSet tmpRs = dbAccess.executeQuery(sql).getRs();
            tmpRs.next();
            int totalFrequesny = tmpRs.getInt(1);
            sql = "INSERT INTO " + DBAccess.FEATURE_STATISTICS_TABLE + "(" + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_FEATURE + "," + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_TYPE + "," + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_VALUE + "," + DBAccess.FIELD_PSCLIENT + ") "
                    + " SELECT " + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_FEATURE + "," + DBAccess.STATISTICS_FREQUENCY_NORMALIZED + "," + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_VALUE + "/" + totalFrequesny + "," + DBAccess.FIELD_PSCLIENT + " FROM " + DBAccess.FEATURE_STATISTICS_TABLE + " WHERE " + DBAccess.FIELD_PSCLIENT + "='" + clientName + "' AND " + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_TYPE + "=" + DBAccess.STATISTICS_FREQUENCY;
            //System.out.println("executing " + sql);
            dbAccess.executeUpdate(sql);
            //System.out.println("executed " + sql);

            HashMap<String, Float> featureFrequencies = new HashMap<String, Float>(1000);
            sql = "SELECT " + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_FEATURE + "," + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_VALUE + " FROM " + DBAccess.FEATURE_STATISTICS_TABLE + " WHERE " + DBAccess.FEATURE_STATISTICS_TABLE_FIELD_TYPE + "=" + DBAccess.STATISTICS_FREQUENCY + " AND " + DBAccess.FIELD_PSCLIENT + "='" + clientName + "'";
            ResultSet features = dbAccess.executeQuery(sql).getRs();
            while (features.next()) {
                featureFrequencies.put(features.getString(1), features.getFloat(2));
            }
            features.close();

            do {
                i = 0;
                //System.out.println("offset is " + offset);
                String subSql = "SELECT * FROM " + DBAccess.UFTRASSOCIATIONS_TABLE + " WHERE " + DBAccess.UFTRASSOCIATIONS_TABLE_FIELD_TYPE + "=" + DBAccess.RELATION_PHYSICAL + " AND " + DBAccess.FIELD_PSCLIENT + "='" + clientName + "' LIMIT " + corellationSize + " OFFSET " + offset;
                ResultSet cor = dbAccess.executeQuery(subSql).getRs();
                while (cor.next()) {
                    String ftr1 = cor.getString(DBAccess.UFTRASSOCIATIONS_TABLE_FIELD_SRC);
                    String ftr2 = cor.getString(DBAccess.UFTRASSOCIATIONS_TABLE_FIELD_DST);
                    float weight = cor.getFloat(DBAccess.UFTRASSOCIATIONS_TABLE_FIELD_WEIGHT);
                    //System.out.println( "ftr1 " + ftr1 + " ftr2 " + ftr2 );
                    Float f1 = featureFrequencies.get(ftr1);
                    Float f2 = featureFrequencies.get(ftr2);
                    if (f1 == null || f2 == null) {
                        continue;
                    }
                    float newWeight = weight * weight / (f1 * f2);
                    String sqlIns = "INSERT DELAYED INTO " + DBAccess.UFTRASSOCIATIONS_TABLE + "(" + DBAccess.UFTRASSOCIATIONS_TABLE_FIELD_SRC + "," + DBAccess.UFTRASSOCIATIONS_TABLE_FIELD_DST + "," + DBAccess.UFTRASSOCIATIONS_TABLE_FIELD_TYPE + "," + DBAccess.UFTRASSOCIATIONS_TABLE_FIELD_WEIGHT + "," + DBAccess.FIELD_PSCLIENT + ") VALUES ("
                            + "'" + ftr1 + "','" + ftr2 + "'," + DBAccess.RELATION_PHYSICAL_NORMALIZED + "," + newWeight + ",'" + clientName + "')";
                    dbAccess.executeUpdate(sqlIns);
                    i++;
                }
                cor.close();
                offset += corellationSize;
                System.out.println(offset);
            } while (i == corellationSize);

        } catch (SQLException ex) {
            WebServer.win.log.error(ex.toString());
            ex.printStackTrace();
            return false;
        }
        return true;
    }