[Prévia] [Próxima] [Prévia por assunto] [Próxima por assunto]
[Índice cronológico] [Índice de assunto]

lista de páginas vazias



Professor, estavamos com algums problemas quanto a lista de páginas vazias
da Database e o NotEnoughSpaceException. Armazenamos a lista ligada de
páginas vazias no campo "previous" da nossa primeira página (o diretório
de record sets) porém para tirar páginas desta lista não queriamos testar
sempre para ver se não estava vazia, então criamos o seguinte método na
HFPage:
 /**
     *Returns the page id stored in the "previous" field of a page.
     *Adjusts the "previous" field to the next free page in the list
     *However if that page id is equal to INVALID_PAGE we return a
     *NotEnoughSpaceException.
     *We use this method when we have a list contained in the previous field.
     *We assume this list is a list of free pages.
     *We assume the list is contained in the "previous" field of the current
     *buffer and in the "next" fields of the other pages....	
     *	
     * @param b a <code>Buffer</code> with the page
     * @return the page id of the first free page
     * @throws NotEnoughSpaceException
     */
    static long PegaVazio(Buffer b) throws NotEnoughSpaceException{
	if( b.readLong(prevPage(b)) == INVALID_PAGE )
	    throw new NotEnoughSpaceException("Acabou o espaço");
	else{
	    Page p=Page.pin(prevPage(b),true);
	    this.setPrevious(b,this.getNext(p.getBuffer()));
	    this.setNext(p.getBuffer(),INVALID_PAGE);
	    p.unpin();
	    return p.getid();
	}
	    
    }
podemos usar isto?????
vc acha que é uma boa idéia ou é melhor testar sempre individualmente???

______________________________________________
Only after the last tree has been cut down. 
Only after the last river has been poisoned.
Only after the last fish has been caught.
Only then will you find that money cannot be 
eaten.
			-Indian Prophecy
----------------------------------------------
 Alexandre Freire      <alex@linux.ime.usp.br>