current HBase Plugin just fix the send rate and sample rate
current HBase Plugin just fix the send rate and sample rate , i'll fulfill this later
This commit is contained in:
parent
1f708ad1a5
commit
b65a47523b
|
@ -107,7 +107,19 @@ public abstract class RecordGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
public static class SinGenerator extends RecordGenerator {
|
||||
public static abstract class TrigonometricGenerator extends RecordGenerator {
|
||||
protected static Double Trigonometric_Cycle = 2 * Math.PI;
|
||||
protected static int OneDay_SplitBy_TenMinute = 144;
|
||||
protected static Double Accumulate_Once = Trigonometric_Cycle
|
||||
/ OneDay_SplitBy_TenMinute;
|
||||
|
||||
private TrigonometricGenerator(String dataType, String minValue,
|
||||
String maxValue) {
|
||||
super(dataType, minValue, maxValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SinGenerator extends TrigonometricGenerator {
|
||||
private Double currentAngle = 0D;
|
||||
|
||||
private SinGenerator(String dataType, String minValue, String maxValue) {
|
||||
|
@ -116,10 +128,10 @@ public abstract class RecordGenerator {
|
|||
|
||||
@Override
|
||||
public String getValue() {
|
||||
Double value = (this.maxValue - this.minValue)
|
||||
Double value = (this.maxValue - this.minValue) / 2
|
||||
* Math.sin(this.currentAngle)
|
||||
+ (this.maxValue + this.minValue) / 2;
|
||||
this.currentAngle += Math.PI / 144;
|
||||
this.currentAngle += Accumulate_Once;
|
||||
return convertAsDataType(String.valueOf(value));
|
||||
}
|
||||
|
||||
|
@ -129,7 +141,7 @@ public abstract class RecordGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
public static class CosGenerator extends RecordGenerator {
|
||||
public static class CosGenerator extends TrigonometricGenerator {
|
||||
private Double currentAngle = 0D;
|
||||
|
||||
private CosGenerator(String dataType, String minValue, String maxValue) {
|
||||
|
@ -138,10 +150,10 @@ public abstract class RecordGenerator {
|
|||
|
||||
@Override
|
||||
public String getValue() {
|
||||
Double value = (this.maxValue - this.minValue)
|
||||
Double value = (this.maxValue - this.minValue) / 2
|
||||
* Math.cos(this.currentAngle)
|
||||
+ (this.maxValue + this.minValue) / 2;
|
||||
this.currentAngle += Math.PI / 144;
|
||||
this.currentAngle += Accumulate_Once;
|
||||
return convertAsDataType(String.valueOf(value));
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class Test_RecordGenerator {
|
|||
|
||||
@Test
|
||||
public void test_buildGeneratorWithRandomWithIllegalDataType() {
|
||||
String input = "dataType=String|generator=Random|min=50|max=10|;";
|
||||
String input = "dataType=String|generator=Random|min=10|max=50|;";
|
||||
Row inputRow = Table.buildTable(input, HBasePlugin.LABEL_LIST)
|
||||
.getRow(0);
|
||||
try {
|
||||
|
@ -53,4 +53,35 @@ public class Test_RecordGenerator {
|
|||
assertTrue(e instanceof Bench4QRunTimeException);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getValueOfSin() {
|
||||
String input = "dataType=double|generator=Sin|min=10|max=50|;";
|
||||
Row inputRow = Table.buildTable(input, HBasePlugin.LABEL_LIST)
|
||||
.getRow(0);
|
||||
RecordGenerator recordGenerator = RecordGenerator
|
||||
.buildGeneratorWithRow(inputRow);
|
||||
for (int i = 0; i < 144; i++) {
|
||||
Double resultValue = recordGenerator.getDouble();
|
||||
System.out.println(resultValue);
|
||||
assertTrue(resultValue >= 10);
|
||||
assertTrue(resultValue <= 50);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getCosValue() {
|
||||
String input = "dataType=double|generator=Cos|min=10|max=50|;";
|
||||
Row inputRow = Table.buildTable(input, HBasePlugin.LABEL_LIST)
|
||||
.getRow(0);
|
||||
RecordGenerator recordGenerator = RecordGenerator
|
||||
.buildGeneratorWithRow(inputRow);
|
||||
for (int i = 0; i < 144; i++) {
|
||||
Double resultValue = recordGenerator.getDouble();
|
||||
System.out.println(resultValue);
|
||||
assertTrue(resultValue >= 10);
|
||||
assertTrue(resultValue <= 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue