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

📄 phtlocalstorecontainer.java

📁 High performance DB query
💻 JAVA
字号:
/*
 * @(#)$Id: PHTLocalStoreContainer.java,v 1.1 2005/09/06 04:16:44 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;

/**
 * Class PHTLocalStoreContainer
 * 
 */
public class PHTLocalStoreContainer {

    	protected Payload value;
    	protected int iid;
    	protected long expiration;
    	
    	/**
    	 * Constructor
    	 * Used for storing information in the PHT index
    	 * 
    	 * @param value - The value to be stored
    	 * @param iid - The iid for the value
    	 */
    	public PHTLocalStoreContainer(Payload value, int iid) {
    		this.value = value;
    		this.iid = iid;
    		this.expiration = -1;
    	}
    	
    	/** 
    	 * Method getValue
    	 * 
    	 * @return - The value stored
    	 */
    	public Payload getValue() {
    		return this.value;
    	}
    	
    	/**
    	 * Method getIID
    	 * 
    	 * @return - The iid of the value stored
    	 */
    	public int getIID() {
    		return this.iid;
    	}
    	
    	/**
    	 * Method isExpired
    	 * 
    	 * @return - Returns true if the value's lifetime has expired, false otherwise
    	 */
    	public boolean isExpired() {
    		return (getRemainingLifetime() <= 0);
    	}
    	
    	/**
    	 * Method getRemainingLifetime
    	 * 
    	 * @return - number of milliseconds until isExpired
    	 */
    	public long getRemainingLifetime() {
    		long remainingTime = expiration - System.currentTimeMillis();
    		if (remainingTime < 0) { return 0; }
    		else { return remainingTime; }
    	}
    	
    	/**
    	 * Method setLifetime
    	 * 
    	 * @param lifetime - Number of milliseconds item should remain in storage
    	 */
    	public void setLifetime(long lifetime) {
    		this.expiration = System.currentTimeMillis() + lifetime;
    	}
    	
    	/**
    	 * Method equals
    	 * Returns true if o.iid == this.iid, returns false otherwise.
    	 * The values aren't compared because, in the context of the PHT, two items
    	 * stored under the same key and iid are considered to be the same.
    	 * 
    	 * @param o
    	 * @return
    	 */
    	public boolean equals(Object o) {
    		return (o instanceof PHTLocalStoreContainer) && 
			((PHTLocalStoreContainer) o).getIID() == this.iid;
    	}
    	
    	/**
    	 * Method toString
    	 * @return
    	 */
    	public String toString() {
    		return "<PHTLocalStoreContainer: V:" + value + ", I:" + iid + ", E:" + getRemainingLifetime() + ">";
    	}
}

⌨️ 快捷键说明

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