ehcache

net.sf.ehcache.store.disk.ods
Class FileAllocationTree

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<T>
          extended by net.sf.ehcache.store.disk.ods.AATreeSet<Region>
              extended by net.sf.ehcache.store.disk.ods.FileAllocationTree
All Implemented Interfaces:
Iterable<Region>, Collection<Region>, Set<Region>, SortedSet<Region>

public final class FileAllocationTree
extends AATreeSet<Region>

File allocation tree allows C-like alloc/free operations on a random access file.

Author:
Chris Dennis

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.ehcache.store.disk.ods.AATreeSet
AATreeSet.AbstractTreeNode<E>, AATreeSet.Node<E>
 
Constructor Summary
FileAllocationTree(long maxSize, RandomAccessFile file)
          Create a file allocation tree for the given file, capping it's size at maxSize.
 
Method Summary
 Region alloc(long size)
          Allocate a new region of the given size.
 void clear()
          Mark this whole file as free
 Region find(long size)
          Find a region of the the given size.
 Region find(Object o)
          Find the node within this tree equal to the probe node.
 void free(Region r)
          Mark this region as free.
 long getFileSize()
          Return the current occupied size of this file.
 void mark(Region r)
          Mark this region as used
 Region removeAndReturn(Object o)
          Remove the node matching this object and return it.
 
Methods inherited from class net.sf.ehcache.store.disk.ods.AATreeSet
add, comparator, first, getRoot, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, contains, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

FileAllocationTree

public FileAllocationTree(long maxSize,
                          RandomAccessFile file)
Create a file allocation tree for the given file, capping it's size at maxSize.

Method Detail

alloc

public Region alloc(long size)
Allocate a new region of the given size.


mark

public void mark(Region r)
Mark this region as used


free

public void free(Region r)
Mark this region as free.


clear

public void clear()
Mark this whole file as free

Specified by:
clear in interface Collection<Region>
Specified by:
clear in interface Set<Region>
Overrides:
clear in class AATreeSet<Region>

getFileSize

public long getFileSize()
Return the current occupied size of this file.


removeAndReturn

public Region removeAndReturn(Object o)
Description copied from class: AATreeSet
Remove the node matching this object and return it.

Overrides:
removeAndReturn in class AATreeSet<Region>

find

public Region find(Object o)
Description copied from class: AATreeSet
Find the node within this tree equal to the probe node.

Overrides:
find in class AATreeSet<Region>

find

public Region find(long size)
Find a region of the the given size.


ehcache

Copyright 2001-2015, Terracotta, Inc.