use of org.apache.phoenix.pherf.rules.RulesApplier in project phoenix by apache.
the class RuleGeneratorTest method testRuleOverrides.
@Test
public void testRuleOverrides() throws Exception {
XMLConfigParser parser = new XMLConfigParser(matcherScenario);
WriteWorkload loader = new WriteWorkload(parser);
RulesApplier rulesApplier = loader.getRulesApplier();
Scenario scenario = parser.getScenarios().get(0);
// We should be able to find the correct rule based only on Type and Name combination
// Test CHAR
Column simPhxCol = new Column();
simPhxCol.setName("OTHER_ID");
simPhxCol.setType(DataTypeMapping.CHAR);
// Get the rule we expect to match
Column rule = rulesApplier.getRule(simPhxCol);
assertEquals("Did not find the correct rule.", rule.getName(), simPhxCol.getName());
assertEquals("Did not find the matching rule type.", rule.getType(), simPhxCol.getType());
assertEquals("Rule contains incorrect length.", rule.getLength(), 8);
assertEquals("Rule contains incorrect prefix.", rule.getPrefix(), "z0Oxx00");
DataValue value = rulesApplier.getDataForRule(scenario, simPhxCol);
assertEquals("Value returned does not match rule.", value.getValue().length(), 8);
// Test VARCHAR with RANDOM and prefix
simPhxCol.setName("OLDVAL_STRING");
simPhxCol.setType(DataTypeMapping.VARCHAR);
// Get the rule we expect to match
rule = rulesApplier.getRule(simPhxCol);
assertEquals("Did not find the correct rule.", rule.getName(), simPhxCol.getName());
assertEquals("Did not find the matching rule type.", rule.getType(), simPhxCol.getType());
assertEquals("Rule contains incorrect length.", rule.getLength(), 10);
assertEquals("Rule contains incorrect prefix.", rule.getPrefix(), "MYPRFX");
value = rulesApplier.getDataForRule(scenario, simPhxCol);
assertEquals("Value returned does not match rule.", value.getValue().length(), 10);
assertTrue("Value returned start with prefix.", StringUtils.startsWith(value.getValue(), rule.getPrefix()));
}
use of org.apache.phoenix.pherf.rules.RulesApplier in project phoenix by apache.
the class DataIngestIT method testColumnRulesApplied.
@Test
public void testColumnRulesApplied() {
Scenario scenario = null;
try {
scenario = parser.getScenarioByName("testScenario");
List<Column> columnListFromPhoenix = util.getColumnsFromPhoenix(scenario.getSchemaName(), scenario.getTableNameWithoutSchemaName(), util.getConnection());
assertTrue("Could not get phoenix columns.", columnListFromPhoenix.size() > 0);
WriteWorkload loader = new WriteWorkload(util, parser, scenario, GeneratePhoenixStats.NO);
WorkloadExecutor executor = new WorkloadExecutor();
executor.add(loader);
executor.get();
executor.shutdown();
RulesApplier rulesApplier = loader.getRulesApplier();
List<Map> modelList = rulesApplier.getModelList();
assertTrue("Could not generate the modelList", modelList.size() > 0);
for (Column column : columnListFromPhoenix) {
DataValue data = rulesApplier.getDataForRule(scenario, column);
// We are generating data values
// so the value should have been specified by this point.
assertTrue("Failed to retrieve data for column type: " + column.getType(), data != null);
// so we should get the default rule.
if ((column.getType() == DataTypeMapping.VARCHAR) && (column.getName().equals("NEWVAL_STRING"))) {
assertTrue("Failed to retrieve data for column type: ", data.getDistribution() == Integer.MIN_VALUE);
}
}
// Run some queries
executor = new WorkloadExecutor();
Workload query = new QueryExecutor(parser, util, executor);
executor.add(query);
executor.get();
executor.shutdown();
PhoenixUtil.create().deleteTables("ALL");
} catch (Exception e) {
fail("We had an exception: " + e.getMessage());
}
}
Aggregations