/** * copy a text. * * @param other the text to initialize from */ public void set(Text other) { set(other.getBytes(), 0, other.getLength()); }
/** * Set the variable length element at the specified index to the * content in supplied Text. * * @param index position of the element to set * @param text Text object with data */ public void set(int index, Text text) { set(index, text.getBytes(), 0, text.getLength()); }
/** * Same as {@link #set(int, NullableVarCharHolder)} except that it handles the * case where index and length of new element are beyond the existing * capacity of the vector. * * @param index position of the element to set. * @param text Text object with data */ public void setSafe(int index, Text text) { setSafe(index, text.getBytes(), 0, text.getLength()); }
} else if (o instanceof Text) { try { String s = Text.decode(((Text) o).getBytes(), 0, ((Text) o).getLength()); if((s == null) || (s.length() == 0)
public static boolean castToFloat(FieldReader reader, NullableFloat8Holder out) { Object o = reader.readObject(); if (o instanceof Number) { out.value = ((Number) o).doubleValue(); return true; } else if (o instanceof Boolean) { out.value = ((Boolean) o).booleanValue() ? 1 : 0; return true; } else if (o instanceof LocalDateTime) { out.value = toMillis((LocalDateTime) o); return true; } else if (o instanceof Text) { String s; try { s = Text.decode(((Text) o).getBytes(), 0, ((Text) o).getLength()); if (!isNumeric(s)) { return false; } out.value = Double.parseDouble(s); return true; } catch (Exception e) { // TODO: is this the best way? logger.warn("Can't decode text to FLOAT", e); return false; } } else if (o instanceof byte[]) { return false; // TODO } return false; }
public static boolean castToInteger(FieldReader reader, NullableBigIntHolder out) { Object o = reader.readObject(); if (o instanceof Number) { out.value = ((Number) o).longValue(); return true; } else if (o instanceof Boolean) { out.value = ((Boolean) o).booleanValue() ? 1 : 0; return true; } else if (o instanceof LocalDateTime) { out.value = toMillis((LocalDateTime) o); return true; } else if (o instanceof Text) { try { String s = Text.decode(((Text) o).getBytes(), 0, ((Text) o).getLength()); return parseLong(s, out); } catch (CharacterCodingException e) { // TODO: is this the best way? logger.warn("Can't decode text", e); return false; } } else if (o instanceof byte[]) { return false; // TODO } return false; }
@Override public void set(ValueVector v, int index) { if(obj != null){ byte[] bytes = obj.getBytes(); ((VarCharVector) v).setSafe(index, bytes, 0, obj.getLength()); } }
Text text = from.readText(); workBuf = workBuf.reallocIfNeeded(text.getLength()); workBuf.setBytes(0, text.getBytes()); to.varChar().writeVarChar(0, text.getLength(), workBuf); break;