📄 phtprinttreemessage.java
字号:
/*
* @(#)$Id: PHTPrintTreeMessage.java,v 1.1 2005/09/06 04:17:45 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 java.math.BigInteger;
import java.net.InetSocketAddress;
import pier.messages.IndexMessage;
import services.network.Payload;
import util.BitID;
import util.network.serialization.GenericByteBuffer;
import util.network.serialization.SerializationManager;
import util.network.serialization.SerializeString;
/**
* Class PHTPrintTreeMessage
*
*/
public class PHTPrintTreeMessage extends IndexMessage {
public static long serialVersionUID =
SerializationManager.getSerialUID("pier.indexes.prefixhashtree.PHTPrintTreeMessage");
protected int bitsSoFar;
protected byte[] keySoFar;
/**
* Constructor
* @param inputBuffer
*/
public PHTPrintTreeMessage(GenericByteBuffer inputBuffer) {
super(inputBuffer);
this.bitsSoFar = inputBuffer.getInt();
this.keySoFar = new byte[bitsSoFar+1];
for (int i = 0; i <= bitsSoFar; i++) {
keySoFar[i] = (byte) inputBuffer.getShort();
}
}
/**
* Method serialize
*
* @param outputBuffer
* @return
*/
public long serialize(GenericByteBuffer outputBuffer) {
super.serialize(outputBuffer);
outputBuffer.putInt(bitsSoFar);
for (int i = 0; i <= bitsSoFar; i++) {
outputBuffer.putShort(keySoFar[i]);
}
return serialVersionUID;
}
/**
* Constructor QueryForwardRequest
*/
public PHTPrintTreeMessage() { }
/**
* Method init
*
* @param indexName
* @param indexType
* @param lifetime
* @param source
* @param messageID
*/
private void init(String indexName, String indexType, long lifetime,
InetSocketAddress source, long messageID, int bitsSoFar, byte[] keySoFar) {
super.init(indexName, indexType, lifetime, source, messageID, new BitID());
this.bitsSoFar = bitsSoFar;
this.keySoFar = keySoFar;
}
/**
* Method getBitsSoFar
* @return
*/
public int getBitsSoFar() {
return this.bitsSoFar;
}
/**
* Method getKeySoFar
* @return
*/
public byte[] getKeySoFar() {
return this.keySoFar;
}
/**
* Method toString
* @return
*/
public String toString() {
return "<PHTPrintTreeMessage: N:" + indexName + ", T:" + indexType + ", S:"
+ source + ", M:" + messageID + ", L:" + lifetime + ", B:" + bitsSoFar +
", K:" + KeyConverter.printBitID(new BitID(new BigInteger(keySoFar))) + ">";
}
/**
* Method allocate
*
* @param indexName
* @param indexType
* @param lifetime
* @param source
* @param messageID
* @return
*/
public static PHTPrintTreeMessage allocate(String indexName, String indexType,
long lifetime, InetSocketAddress source, long messageID, int bitsSoFar,
byte[] keySoFar) {
PHTPrintTreeMessage message = new PHTPrintTreeMessage();
message.init(indexName, indexType, lifetime, source, messageID, bitsSoFar, keySoFar);
return message;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -