⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phtmessagedata.java

📁 High performance DB query
💻 JAVA
字号:
/*
 * @(#)$Id: PHTMessageData.java,v 1.1 2005/09/06 04:17:08 burkhart Exp $
 *
 * Copyright (c) 2001-2004 Regents of the University of California.
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached BERKELEY-LICENSE
 * file. If you do not find these files, copies can be found by writing to:
 * Computer Science Division, Database Group, Universite of California,
 * 617 Soda Hall #1776, Berkeley, CA 94720-1776. Attention: Berkeley License
 *
 * Copyright (c) 2003-2004 Intel Corporation. All rights reserved.
 *
 * This file is distributed under the terms in the attached INTEL-LICENSE file.
 * If you do not find these files, copies can be found by writing to:
 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300,
 * Berkeley, CA, 94704.  Attention:  Intel License Inquiry.
 */



package pier.indexes.prefixhashtree;

import services.network.Payload;
import util.BitID;
import util.network.serialization.GenericByteBuffer;
import util.network.serialization.SerializationManager;
import util.network.serialization.SerializeBigInteger;

/**
 * Class PHTMessageData
 * 
 */
public class PHTMessageData implements Payload {

    public static long serialVersionUID =
        SerializationManager.getSerialUID("pier.indexes.prefixhashtree.PHTMessageData");
    protected BitID binaryKey;
	protected int placeInKey;
	protected int factorOfSplit;
	protected int iid;
	
	/**
	 * Constructor
	 *
	 * @param inputBuffer
	 */
	public PHTMessageData(GenericByteBuffer inputBuffer) {
		this.binaryKey = new BitID(SerializeBigInteger.deSerialize(inputBuffer)); 
		this.placeInKey = inputBuffer.getInt();
		this.factorOfSplit = inputBuffer.getInt();
		this.iid = inputBuffer.getInt();
	}
	
	/**
	 * Constructor
	 * Users should call allocate to create a new instance
	 */
	protected PHTMessageData() { }

	/**
	 * Method getBinaryKey
	 * @return
	 */
	public BitID getBinaryKey() {
		return this.binaryKey;
	}
	
	/**
	 * Method getPlaceInKey
	 * @return
	 */
	public int getPlaceInKey() {
		return this.placeInKey;
	}
	
	/**
	 * Method getFactorOfSplit
	 * @return
	 */
	public int getFactorOfSplit() {
		return this.factorOfSplit;
	}
	
	/**
	 * Method getIID
	 * @return
	 */
	public int getIID() {
		return this.iid;
	}
	
	/**
	 * Method getSize
	 * 
	 * @return
	 */
	public int getSize() {
		return binaryKey.getSize() + (3 * Payload.INT_SIZE);
	}

	/**
	 * Method serialize
	 * 
	 * @param outputBuffer
	 * @return
	 */
	public long serialize(GenericByteBuffer outputBuffer) {
        SerializeBigInteger.serialize(outputBuffer, this.binaryKey.bigIntegerValue());
	    outputBuffer.putInt(this.placeInKey);
	    outputBuffer.putInt(this.factorOfSplit);
	    outputBuffer.putInt(this.iid);
		
	    return this.serialVersionUID;
	}
	
	/**
	 * Method init
	 * Set all local variables to passed in arguments
	 * 
	 * @param placeInKey
	 * @param factorOfSplit
	 * @param iid
	 */
	protected void init(BitID binaryKey, int placeInKey, int factorOfSplit, int iid) {
		this.binaryKey = binaryKey;
		this.placeInKey = placeInKey;
		this.factorOfSplit = factorOfSplit;
		this.iid = iid;
	}

    /**
     * Method toString
     * 
     * @return
     */
    public String toString() {
        return "<PHTMessageData: B:" + KeyConverter.printBitID(this.binaryKey) + ", " + 
		"P:" + this.placeInKey + ", F:" + this.factorOfSplit + ", I:" + this.iid + ">";
    }

    /**
     * Method allocate
     * Called to create a new instance
     * 
     * @param placeInKey
     * @param factorOfSplit
     * @param iid
     * @return
     */
    public static PHTMessageData allocate(BitID binaryKey, int placeInKey, int factorOfSplit, int iid) {
        PHTMessageData data = new PHTMessageData();
        data.init(binaryKey, placeInKey, factorOfSplit, iid);
        return data;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -