class SubQueryResult extends DelegatedResult {

    protected ValueHashMap<Value[]> distinctRows;
    protected int rowCount = -1;

    public SubQueryResult(Query query, int maxRows) {
        result = query.query(maxRows);
    }

    public boolean containsDistinct(Value[] values) {
        if (result instanceof LocalResult)
            return ((LocalResult) result).containsDistinct(values);

        if (distinctRows == null) {
            initDistinctRows();
        }

        ValueArray array = ValueArray.get(values);
        return distinctRows.get(array) != null;
    }

    private int initDistinctRows() {<FILL_FUNCTION_BODY>}

    @Override
    public int getRowCount() {
        int rowCount = result.getRowCount();
        if (rowCount == -1) {
            initDistinctRows();
            return this.rowCount;
        }

        return rowCount;
    }
}

        if (distinctRows == null) {
            rowCount = 0;

            distinctRows = ValueHashMap.newInstance();
            int visibleColumnCount = getVisibleColumnCount();
            ArrayList<Value[]> rowList = new ArrayList<>();
            while (next()) {
                rowCount++;
                Value[] row = currentRow();
                if (row.length > visibleColumnCount) {
                    Value[] r2 = new Value[visibleColumnCount];
                    System.arraycopy(row, 0, r2, 0, visibleColumnCount);
                    row = r2;
                }
                ValueArray array = ValueArray.get(row);
                distinctRows.put(array, row);
                rowList.add(row);
            }

            result = new SubQueryRowList(rowList, result);
        }

        return rowCount;
    
<methods>public non-sealed void <init>() ,public void close() ,public com.lealone.db.value.Value[] currentRow() ,public java.lang.String getAlias(int) ,public java.lang.String getColumnName(int) ,public long getColumnPrecision(int) ,public int getColumnScale(int) ,public int getColumnType(int) ,public int getDisplaySize(int) ,public int getFetchSize() ,public int getNullable(int) ,public int getRowCount() ,public int getRowId() ,public java.lang.String getSchemaName(int) ,public java.lang.String getTableName(int) ,public int getVisibleColumnCount() ,public boolean isAutoIncrement(int) ,public boolean needToClose() ,public boolean next() ,public void reset() ,public void setFetchSize(int) <variables>protected com.lealone.db.result.Result result