@Override public void reset(IMutableValueStorage mvs) throws IOException { this.mvs = mvs; out = mvs.getDataOutput(); out.write(getValueTag()); headerOffset = mvs.getLength(); out.write(0); }
public void startAttributeChunk() { attrSlots.clear(); attrDataArea.reset(); }
public void endAttributeChunk() throws IOException { attrCount = attrSlots.getSize(); if (attrCount > 0) { out.writeInt(attrCount); int[] slotArray = attrSlots.getArray(); for (int i = 0; i < attrCount; ++i) { int slot = slotArray[i]; out.writeInt(slot); } out.write(attrDataArea.getByteArray(), attrDataArea.getStartOffset(), attrDataArea.getLength()); } }
public void finish() throws IOException { int utflen = mvs.getLength() - 2; BytePointable.setByte(mvs.getByteArray(), 0, (byte) ((utflen >>> 8) & 0xFF)); BytePointable.setByte(mvs.getByteArray(), 1, (byte) ((utflen >>> 0) & 0xFF)); }
/** * Experimental. * Check if too many serialization for the same field names can be expensive or not. * * @param fieldName * @return * @throws HyracksDataException */ public IMutableValueStorage getSerializedFieldName(String fieldName) throws IOException { IMutableValueStorage serializedFieldName = serializedFieldNames.get(fieldName); if (serializedFieldName == null) { serializedFieldName = new ArrayBackedValueStorage(); serializedFieldName.reset(); aString.setValue(fieldName); stringSerDe.serialize(aString, serializedFieldName.getDataOutput()); serializedFieldNames.put(fieldName, serializedFieldName); } return serializedFieldName; }
public void reset(IMutableValueStorage mvs) throws IOException { this.mvs = mvs; out = mvs.getDataOutput(); out.write(0); out.write(0); }
public void startNamespaceChunk() { nsChunkStart = mvs.getLength(); nsCount = 0; }
public void endNamespaceChunk() { byte[] bytes = mvs.getByteArray(); IntegerPointable.setInteger(bytes, nsChunkStart, nsCount); }
/** * @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)); } }
public void reset(IMutableValueStorage mvs) throws IOException { out = mvs.getDataOutput(); out.write(getValueTag()); }
@Override public void finish() throws IOException { byte header = 0; if (nsCount > 0) { header |= ElementNodePointable.NS_CHUNK_EXISTS_MASK; } if (attrCount > 0) { header |= ElementNodePointable.ATTRIBUTES_CHUNK_EXISTS_MASK; } if (childrenCount > 0) { header |= ElementNodePointable.CHILDREN_CHUNK_EXISTS_MASK; } BytePointable.setByte(mvs.getByteArray(), headerOffset, header); }
protected final void parseCollection(AbstractCollectionType collectionType, ADMToken endToken, DataOutput out) throws IOException { final IMutableValueStorage valueBuffer = parserContext.enterCollection(); final IAsterixListBuilder arrayBuilder = parserContext.getCollectionBuilder(collectionType); final boolean isOpen = collectionType.getItemType().getTypeTag() == ATypeTag.ANY; while (nextToken() != endToken) { valueBuffer.reset(); if (isOpen) { parseValue(BuiltinType.ANY, valueBuffer.getDataOutput()); } else { //fail fast if current value is null if (currentToken() == ADMToken.NULL) { throw new RuntimeDataException(ErrorCode.PARSER_COLLECTION_ITEM_CANNOT_BE_NULL); } parseValue(collectionType.getItemType(), valueBuffer.getDataOutput()); } arrayBuilder.addItem(valueBuffer); } parserContext.exitCollection(valueBuffer, arrayBuilder); arrayBuilder.write(out, true); }
public void startChildrenChunk() { childrenSlots.clear(); childrenDataArea.reset(); }
public void addChild(IValueReference value) throws IOException { childrenDataArea.getDataOutput().write(value.getByteArray(), value.getStartOffset(), value.getLength()); childrenSlots.append(childrenDataArea.getLength()); }
public void finish() throws IOException { DataOutput out = mvs.getDataOutput(); if (slots.getSize() != 1) { out.write(ValueTag.SEQUENCE_TAG); int size = slots.getSize(); out.writeInt(size); if (size > 0) { int[] slotArray = slots.getArray(); for (int i = 0; i < size; ++i) { out.writeInt(slotArray[i]); } out.write(dataArea.getByteArray(), dataArea.getStartOffset(), dataArea.getLength()); } } else { out.write(dataArea.getByteArray(), dataArea.getStartOffset(), dataArea.getLength()); } } }
public void endChildrenChunk() throws IOException { childrenCount = childrenSlots.getSize(); if (childrenCount > 0) { out.writeInt(childrenCount); int[] slotArray = childrenSlots.getArray(); for (int i = 0; i < childrenCount; ++i) { int slot = slotArray[i]; out.writeInt(slot); } out.write(childrenDataArea.getByteArray(), childrenDataArea.getStartOffset(), childrenDataArea.getLength()); } } }
public void endChild(AbstractNodeBuilder nb) throws IOException { nb.finish(); childrenSlots.append(childrenDataArea.getLength()); }
fieldName); valueBuffer.reset(); nextToken(); parseValue(BuiltinType.ANY, valueBuffer.getDataOutput()); objectBuilder.addField(parserContext.getSerializedFieldName(fieldName), valueBuffer); } else { parseValue(fieldType, valueBuffer.getDataOutput()); objectBuilder.addField(fieldIndex, valueBuffer);