blob: c0a141f3d4a9990c65bff3d4ee08d6ab3e0455ae [file] [log] [blame]
/*
* 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.flink.state.benchmark;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
/**
* Constants for state benchmark tests. Also generates random keys/values in advance to avoid
* possible affect of using {@link Random#nextLong()}
*/
public class StateBenchmarkConstants {
// TODO: why all of those static fields? Those should be inside a context class
public static final int mapKeyCount = 10;
public static final int listValueCount = 100;
public static final int setupKeyCount = 500_000;
public static final String rootDirName = "benchmark";
public static final String recoveryDirName = "localRecovery";
public static final String dbDirName = "dbPath";
public static final ArrayList<Long> mapKeys = new ArrayList<>(mapKeyCount);
public static final ArrayList<Double> mapValues = new ArrayList<>(mapKeyCount);
public static final ArrayList<Long> setupKeys = new ArrayList<>(setupKeyCount);
public static final int newKeyCount = 500_000;
public static final ArrayList<Long> newKeys = new ArrayList<>(newKeyCount);
public static final int randomValueCount = 1_000_000;
public static final ArrayList<Long> randomValues = new ArrayList<>(randomValueCount);
static {
for (int i = 0; i < mapKeyCount; i++) {
mapKeys.add((long) i);
}
Collections.shuffle(mapKeys);
}
static {
Random random = new Random();
for (int i = 0; i < mapKeyCount; i++) {
mapValues.add(random.nextDouble());
}
Collections.shuffle(mapValues);
}
static {
for (long i = 0; i < setupKeyCount; i++) {
setupKeys.add(i);
}
Collections.shuffle(setupKeys);
}
static {
for (long i = 0; i < newKeyCount; i++) {
newKeys.add(i + setupKeyCount);
}
Collections.shuffle(newKeys);
}
static {
for (long i = 0; i < randomValueCount; i++) {
randomValues.add(i);
}
Collections.shuffle(randomValues);
}
}