<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package org.apache.kylin.storage;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

import org.apache.kylin.cube.cuboid.Cuboid;
import org.apache.kylin.metadata.model.MeasureDesc;

/**
 * @author xjiang
 */
public class StorageContext {

    public static final int HARD_THRESHOLD = 4000000;
    public static final int DEFAULT_THRESHOLD = 1000000;

    public enum OrderEnum {
        ASCENDING, DESCENDING
    }

    private String connUrl;
    private int threshold;
    private int limit;
    private int offset;
    private boolean hasSort;
    private List<MeasureDesc> sortMeasures;
    private List<OrderEnum> sortOrders;
    private boolean acceptPartialResult;

    private boolean exactAggregation;
    private boolean enableLimit;
    private boolean enableCoprocessor;

    private AtomicLong totalScanCount;
    private Cuboid cuboid;
    private boolean partialResultReturned;

    public StorageContext() {
        this.threshold = DEFAULT_THRESHOLD;
        this.limit = DEFAULT_THRESHOLD;
        this.totalScanCount = new AtomicLong();
        this.cuboid = null;
        this.hasSort = false;
        this.sortOrders = new ArrayList<OrderEnum>();
        this.sortMeasures = new ArrayList<MeasureDesc>();

        this.exactAggregation = false;
        this.enableLimit = false;
        this.enableCoprocessor = false;

        this.acceptPartialResult = false;
        this.partialResultReturned = false;
    }

    public String getConnUrl() {
        return connUrl;
    }

    public void setConnUrl(String connUrl) {
        this.connUrl = connUrl;
    }

    public int getThreshold() {
        return threshold;
    }

    public void setThreshold(int t) {
        threshold = Math.min(t, HARD_THRESHOLD);
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int l) {
        this.limit = l;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public void enableLimit() {
        this.enableLimit = true;
    }

    public boolean isLimitEnabled() {
        return this.enableLimit;
    }<commit_msg>KYLIN-1020 remove HARD_THRESHOLD from StorageContext<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package org.apache.kylin.storage;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

import org.apache.kylin.cube.cuboid.Cuboid;
import org.apache.kylin.metadata.model.MeasureDesc;

/**
 * @author xjiang
 */
public class StorageContext {

    public static final int DEFAULT_THRESHOLD = 1000000;

    public enum OrderEnum {
        ASCENDING, DESCENDING
    }

    private String connUrl;
    private int threshold;
    private int limit;
    private int offset;
    private boolean hasSort;
    private List<MeasureDesc> sortMeasures;
    private List<OrderEnum> sortOrders;
    private boolean acceptPartialResult;

    private boolean exactAggregation;
    private boolean enableLimit;
    private boolean enableCoprocessor;

    private AtomicLong totalScanCount;
    private Cuboid cuboid;
    private boolean partialResultReturned;

    public StorageContext() {
        this.threshold = DEFAULT_THRESHOLD;
        this.limit = DEFAULT_THRESHOLD;
        this.totalScanCount = new AtomicLong();
        this.cuboid = null;
        this.hasSort = false;
        this.sortOrders = new ArrayList<OrderEnum>();
        this.sortMeasures = new ArrayList<MeasureDesc>();

        this.exactAggregation = false;
        this.enableLimit = false;
        this.enableCoprocessor = false;

        this.acceptPartialResult = false;
        this.partialResultReturned = false;
    }

    public String getConnUrl() {
        return connUrl;
    }

    public void setConnUrl(String connUrl) {
        this.connUrl = connUrl;
    }

    public int getThreshold() {
        return threshold;
    }

    public void setThreshold(int t) {
        threshold = t;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int l) {
        this.limit = l;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public void enableLimit() {
        this.enableLimit = true;
    }

    public boolean isLimitEnabled() {
        return this.enableLimit;
    }
{'fraction_non_alphanumeric': 0.0735758179704368, 'fraction_numerical': 0.005480817140009965, 'mean_word_length': 2.857783472133248, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4155368', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1611, 'n_words': 543}