@Test
//cast to float4
public void testCastFloat4(@Injectable final DrillbitContext bitContext,
@Injectable UserServer.UserClientConnection connection) throws Throwable{
final BufferAllocator allocator = new TopLevelAllocator();
new NonStrictExpectations(){{
bitContext.getMetrics(); result = new MetricRegistry();
bitContext.getAllocator(); result = allocator;
bitContext.getConfig(); result = c;
bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c);
bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
}};
PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/functions/cast/testCastFloat4.json"), Charsets.UTF_8));
FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
while(exec.next()){
Float4Vector c0 = exec.getValueVectorById(new SchemaPath("varchar_cast2", ExpressionPosition.UNKNOWN), Float4Vector.class);
Float4Vector.Accessor a0;
a0 = c0.getAccessor();
int count = 0;
for(int i = 0; i < c0.getAccessor().getValueCount(); i++){
Float4Holder holder0 = new Float4Holder();
a0.get(i, holder0);
assertEquals(12.56, holder0.value, 0.001);
++count;
}
assertEquals(5, count);
}
exec.stop();
context.close();
allocator.close();
if(context.getFailureCause() != null){
throw context.getFailureCause();
}
assertTrue(!context.isFailed());