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

com.xxdb.data.BasicChunkMeta Maven / Gradle / Ivy

There is a newer version: 3.00.2.2
Show newest version
package com.xxdb.data;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.xxdb.io.AbstractExtendedDataOutputStream;
import com.xxdb.io.ExtendedDataInput;
import com.xxdb.io.ExtendedDataOutput;

public class BasicChunkMeta extends AbstractEntity implements Entity{
	private String path;
	private BasicUuid id;
	private int version;
	private int size;
	private byte flag;
	private List sites;

	public BasicChunkMeta(ExtendedDataInput in) throws IOException{
		in.readShort(); //skip the length of the data
		path = in.readString();
		id = new BasicUuid(in);
		version = in.readInt();
		size = in.readInt();
		flag = in.readByte();
		sites = new ArrayList<>();
		int copyCount = in.readByte();
		for(int i=0; i0)
				str.append(", ");
			str.append(sites.get(i));
		}
		str.append("}, v");
		str.append(version);
		str.append(", ");
		str.append(size);
		if(isSplittable())
			str.append(", splittable]");
		else
			str.append("]");
		return str.toString();
	}

	@Override
	public void write(ExtendedDataOutput output) throws IOException {
		int length = 27 + AbstractExtendedDataOutputStream.getUTFlength(path, 0, 0) + sites.size();
		for(String site : sites)
			length += AbstractExtendedDataOutputStream.getUTFlength(site, 0, 0);
		output.writeShort(length);
		output.writeString(path);
		output.writeLong2(id.getLong2());
		output.writeInt(version);
		output.writeInt(size);
		output.writeByte(flag);
		output.writeByte(sites.size());
		for(String site : sites)
			output.writeUTF(site);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy