public static byte[] writeStringToBytes(String string) { UTF8StringWriter writer = new UTF8StringWriter(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); try { writer.writeUTF8(string, dos); } catch (IOException e) { throw new RuntimeException(e); } return bos.toByteArray(); }
@Override public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException { try { writer.writeUTF8(buffer, start, length, out); } catch (IOException e) { throw HyracksDataException.create(e); } } };
public void getClosedFieldName(ARecordType recordType, int fieldId, DataOutput dOut) throws IOException { dOut.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG); utf8Writer.writeUTF8(getClosedFieldName(recordType, fieldId), dOut); }
private void parseString(Object obj, StringObjectInspector foi, DataOutput dataOutput) throws IOException { utf8Writer.writeUTF8(foi.getPrimitiveJavaObject(obj), dataOutput); }
private void writeAndReadOneString(String testString) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); writer.writeUTF8(testString, dos); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray(), 0, bos.size()); assertEquals(testString, reader.readUTF(new DataInputStream(bis))); int lastOffset = bos.size(); char[] charArray = testString.toCharArray(); writer.writeUTF8(charArray, 0, charArray.length, dos); bis = new ByteArrayInputStream(bos.toByteArray(), lastOffset, bos.size()); assertEquals(testString, reader.readUTF(new DataInputStream(bis))); }
/** * @param str * The input string * @param vs * The storage buffer * @param writeTag * Specifying whether a tag for the string should also be written */ public void serializeString(String str, IMutableValueStorage vs, boolean writeTag) throws HyracksDataException { vs.reset(); try { DataOutput output = vs.getDataOutput(); if (writeTag) { output.write(ATypeTag.STRING.serialize()); } utf8Writer.writeUTF8(str, output); } catch (IOException e) { throw new HyracksDataException("Could not serialize " + LogRedactionUtil.userData(str)); } }
case STRING: out.write(BuiltinType.ASTRING.getTypeTag().serialize()); utf8Writer.writeUTF8(fieldObj.asText(), out); break; case BIGINT: } else if (fieldObj.isTextual()) { out.write(BuiltinType.ASTRING.getTypeTag().serialize()); utf8Writer.writeUTF8(fieldObj.asText(), out); } else if (fieldObj.isArray()) { if ((fieldObj).size() != 0) {
for (int i = 0; i < fieldNames.length; ++i) { serializedFieldNameOffsets[i] = baaos.size(); writer.writeUTF8(fieldNames[i], dos); length = baaos.size() - serializedFieldNameOffsets[i]; hashCodeIndexPairs[i] =
utf8Writer.writeUTF8(fname, dos); int nameEnd = bos.size(); IVisitablePointable typeNamePointable = allocator.allocateEmpty();
utf8Writer.writeUTF8(fieldNameStrs[i], typeDos); int nameEnd = typeBos.size(); IVisitablePointable typeNameReference = AFlatValuePointable.FACTORY.create(null);