![JAR search and dependency download from the Maven repository](/logo.png)
io.fluo.stress.trie.NumberLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluo-stress Show documentation
Show all versions of fluo-stress Show documentation
This module contains Fluo stress tests. Stress tests are different than integration tests in
that they are designed to run on a cluster while integration tests only run on MiniFluo in a
local environment. This module produces the jar needed to run a stress test on a cluster.
Currently, this module only has one stress test (the Trie test) but other tests could be added
to this module in the future.
The newest version!
/*
* Copyright 2014 Fluo authors (see AUTHORS)
*
* Licensed 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 io.fluo.stress.trie;
import static com.google.common.base.Preconditions.checkArgument;
import io.fluo.api.client.Loader;
import io.fluo.api.client.TransactionBase;
import io.fluo.api.types.TypedTransactionBase;
/** Executes load transactions of numbers into trie at leaf node level
*/
public class NumberLoader implements Loader {
private final Number number;
private final int level;
private final int nodeSize;
public NumberLoader(Integer num, int nodeSize) {
checkArgument(num >= 0, "Only positive numbers accepted");
checkArgument((nodeSize <= 32) && ((32 % nodeSize) == 0), "nodeSize must be divisor of 32");
this.number = num;
this.nodeSize = nodeSize;
this.level = 32 / nodeSize;
}
public NumberLoader(Long num, int nodeSize) {
checkArgument(num >= 0, "Only positive numbers accepted");
checkArgument((nodeSize <= 64) && ((64 % nodeSize) == 0), "nodeSize must be divisor of 64");
this.number = num;
this.nodeSize = nodeSize;
this.level = 64 / nodeSize;
}
@Override
public void load(TransactionBase tx) throws Exception {
TypedTransactionBase ttx = Constants.TYPEL.wrap(tx);
String rowId = new Node(number, level, nodeSize).getRowId();
Integer seen = ttx.get().row(rowId).col(Constants.COUNT_SEEN_COL).toInteger(0);
if (seen == 0) {
Integer wait = ttx.get().row(rowId).col(Constants.COUNT_WAIT_COL).toInteger(0);
if (wait == 0) {
ttx.mutate().row(rowId).col(Constants.COUNT_WAIT_COL).set(1);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy