All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliyun.drc.client.message.drcmessage.VarAreaHeader Maven / Gradle / Ivy

There is a newer version: 5.0.0.1-cloud.beta
Show newest version
package com.aliyun.drc.client.message.drcmessage;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * Header of the variable-length message storeage format
 * Version 1 storage format
 * 
 * 
 * 
 * 
 * ...
 * 
 * 
 * @author erbai.qzc
 *
 */
public class VarAreaHeader {

	private MsgHeader header;
	private long count;
	private byte[] data;

	public VarAreaHeader() {
		header = null;
		data = null;
	}

	/**
	 * Parse the VarAreaHeader from the stream.
	 * 
	 * @param is
	 * @throws IOException
	 */
	public void parseFrom(DataInputStream is) throws IOException {
		header = new MsgHeader();
		header.parseFrom(is);
		int headerLen = header.getRawData().length;
		data = new byte[headerLen + 4];
		for (int i = 0; i< headerLen; i ++) {
			data[i] = header.getRawData()[i];
		}
		count = CIOUtil.readUnsignedInt(is);
		data[headerLen] =(byte)(count & 0xff);
		data[headerLen + 1] =(byte)((count >> 8) & 0xff);
		data[headerLen + 2] =(byte)((count >> 16) & 0xff);
		data[headerLen + 3] =(byte)((count >> 24) & 0xff);
	}
	
	/**
	 * Get the message header including message type, version and size
	 * @return the message header
	 */
	public final MsgHeader getMsgHeader() {
		return header;
	}

	/**
	 * Get the count of fields
	 * 
	 * @return count
	 */
	public final long getCount() {
		return count;
	}
	
	public byte[] getRawData() {
		return data;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy