本文整理汇总了Java中org.apache.drill.exec.expr.holders.VarCharHolder类的典型用法代码示例。如果您正苦于以下问题:Java VarCharHolder类的具体用法?Java VarCharHolder怎么用?Java VarCharHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VarCharHolder类属于org.apache.drill.exec.expr.holders包,在下文中一共展示了VarCharHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
public void setup() {
classifier = new WekaUpdatableClassifierHolder();
function = new StringHolder();
arffHeader = new StringHolder();
firstRun = new BitHolder();
instancesHolder = new ObjectHolder();
instancesHolder.obj = null;
// instancesList = new LinkedListHolder<weka.core.Instances>();
// instancesList.list = new java.util.LinkedList<weka.core.Instances>();
// instancesList.algorithm=null;
// instancesList.options = null;
classifier.classifier=null;
function.value=null;
arffHeader.value=null;
firstRun.value=0;
currVal = new VarCharHolder();
updatable = new IntHolder();
updatable.value=-1;
aggregatable = new IntHolder();
aggregatable.value=-1;
}
示例2: writeString
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
private void writeString(String readString, final MapOrListWriterImpl writer, String fieldName, boolean isList) {
int length;
byte[] strBytes;
try {
strBytes = readString.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new DrillRuntimeException("Unable to read string value for field: " + fieldName, e);
}
length = strBytes.length;
ensure(length);
workBuf.setBytes(0, strBytes);
final VarCharHolder vh = new VarCharHolder();
vh.buffer = workBuf;
vh.start = 0;
vh.end = length;
if (isList == false) {
writer.varChar(fieldName).write(vh);
} else {
writer.list.varChar().write(vh);
}
}
示例3: getVarCharHolder
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
public static VarCharHolder getVarCharHolder(DrillBuf buf, String s){
VarCharHolder vch = new VarCharHolder();
byte[] b = s.getBytes(Charsets.UTF_8);
vch.start = 0;
vch.end = b.length;
vch.buffer = buf.reallocIfNeeded(b.length);
vch.buffer.setBytes(0, b);
return vch;
}
示例4: prepareVarCharHolder
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
public void prepareVarCharHolder(String value, VarCharHolder h) throws IOException {
byte[] b = value.getBytes(Charsets.UTF_8);
ensure(b.length);
workBuf.setBytes(0, b);
h.start = 0;
h.end = b.length;
h.buffer = workBuf;
}
示例5: testVectors
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
/**
* Convenience method that allows running tests on various {@link ValueVector vector} instances.
*
* @param test test function to execute
*/
private void testVectors(VectorVerifier test) throws Exception {
final MaterializedField[] fields = {
MaterializedField.create(EMPTY_SCHEMA_PATH, UInt4Holder.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, BitHolder.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, VarCharHolder.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, NullableVarCharHolder.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedListVector.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, MapVector.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedMapVector.TYPE)
};
final ValueVector[] vectors = {
new UInt4Vector(fields[0], allocator),
new BitVector(fields[1], allocator),
new VarCharVector(fields[2], allocator),
new NullableVarCharVector(fields[3], allocator),
new RepeatedListVector(fields[4], allocator, null),
new MapVector(fields[5], allocator, null),
new RepeatedMapVector(fields[6], allocator, null)
};
try {
for (final ValueVector vector : vectors) {
test.verify(vector);
}
} finally {
AutoCloseables.close(vectors);
}
}
示例6: setup
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
public void setup() {
currVal = new VarCharHolder();
matcher = java.util.regex.Pattern.compile(
org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(targetValue.start, targetValue.end, targetValue.buffer)).matcher("");
charSequenceWrapper = new org.apache.drill.exec.expr.fn.impl.CharSequenceWrapper();
matcher.reset(charSequenceWrapper);
}
示例7: testVectors
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
/**
* Convenience method that allows running tests on various {@link ValueVector vector} instances.
*
* @param test test function to execute
*/
@SuppressWarnings("resource")
private void testVectors(VectorVerifier test) throws Exception {
final MaterializedField[] fields = {
MaterializedField.create(EMPTY_SCHEMA_PATH, UInt4Holder.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, BitHolder.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, VarCharHolder.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, NullableVarCharHolder.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedListVector.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, MapVector.TYPE),
MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedMapVector.TYPE)
};
final ValueVector[] vectors = {
new UInt4Vector(fields[0], allocator),
new BitVector(fields[1], allocator),
new VarCharVector(fields[2], allocator),
new NullableVarCharVector(fields[3], allocator),
new RepeatedListVector(fields[4], allocator, null),
new MapVector(fields[5], allocator, null),
new RepeatedMapVector(fields[6], allocator, null)
};
try {
for (final ValueVector vector : vectors) {
test.verify(vector);
}
} finally {
AutoCloseables.close(vectors);
}
}
示例8: testCastVarChar
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
@Test
//cast to varchar(length)
public void testCastVarChar(@Injectable final DrillbitContext bitContext,
@Injectable UserClientConnection connection) throws Throwable {
mockDrillbitContext(bitContext);
final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(CONFIG);
final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/functions/cast/testCastVarChar.json"), Charsets.UTF_8));
final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(CONFIG);
final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
while(exec.next()) {
final VarCharVector c0 = exec.getValueVectorById(new SchemaPath("int_lit_cast", ExpressionPosition.UNKNOWN), VarCharVector.class);
final VarCharVector.Accessor a0 = c0.getAccessor();
int count = 0;
for(int i = 0; i < c0.getAccessor().getValueCount(); i++) {
final VarCharHolder holder0 = new VarCharHolder();
a0.get(i, holder0);
assertEquals("123", StringFunctionHelpers.toStringFromUTF8(holder0.start, holder0.end, holder0.buffer));
++count;
}
assertEquals(5, count);
}
exec.close();
context.close();
if(context.getFailureCause() != null) {
throw context.getFailureCause();
}
assertTrue(!context.isFailed());
}
示例9: mappify
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
public static DrillBuf mappify(FieldReader reader, BaseWriter.ComplexWriter writer, DrillBuf buffer) {
// Currently we expect single map as input
if (DataMode.REPEATED == reader.getType().getMode() || !(reader.getType().getMinorType() == TypeProtos.MinorType.MAP)) {
throw new DrillRuntimeException("kvgen function only supports Simple maps as input");
}
BaseWriter.ListWriter listWriter = writer.rootAsList();
listWriter.start();
BaseWriter.MapWriter mapWriter = listWriter.map();
// Iterate over the fields in the map
Iterator<String> fieldIterator = reader.iterator();
while (fieldIterator.hasNext()) {
String str = fieldIterator.next();
FieldReader fieldReader = reader.reader(str);
// Skip the field if its null
if (fieldReader.isSet() == false) {
mapWriter.end();
continue;
}
// writing a new field, start a new map
mapWriter.start();
// write "key":"columnname" into the map
VarCharHolder vh = new VarCharHolder();
byte[] b = str.getBytes(Charsets.UTF_8);
buffer = buffer.reallocIfNeeded(b.length);
buffer.setBytes(0, b);
vh.start = 0;
vh.end = b.length;
vh.buffer = buffer;
mapWriter.varChar(fieldKey).write(vh);
// Write the value to the map
MapUtility.writeToMapFromReader(fieldReader, mapWriter);
mapWriter.end();
}
listWriter.end();
return buffer;
}
示例10: setup
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
public void setup() {
currVal = new VarCharHolder();
matcher = java.util.regex.Pattern.compile(
org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(targetValue.start, targetValue.end, targetValue.buffer)).matcher("");
}
示例11: testAfter
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
@Test
public void testAfter() {
final VarCharHolder left = hello;
final VarCharHolder right = goodbye;
assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == 1);
}
示例12: testBefore
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
@Test
public void testBefore() {
final VarCharHolder left = goodbye;
final VarCharHolder right = hello;
assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == -1);
}
示例13: testEqualCompare
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
@Test
public void testEqualCompare() {
final VarCharHolder left = hello;
final VarCharHolder right = hello;
assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == 0);
}
示例14: testEqual
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
@Test
public void testEqual() {
final VarCharHolder left = hello;
final VarCharHolder right = hello;
assertTrue(ByteFunctionHelpers.equal(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == 1);
}
示例15: testNotEqual
import org.apache.drill.exec.expr.holders.VarCharHolder; //导入依赖的package包/类
@Test
public void testNotEqual() {
final VarCharHolder left = hello;
final VarCharHolder right = goodbye;
assertTrue(ByteFunctionHelpers.equal(left.buffer, left.start, left.end, right.buffer, right.start, right.end) == 0);
}