net.java.sen.compiler
Class VirtualTupleList

java.lang.Object
  extended by net.java.sen.compiler.VirtualTupleList

public class VirtualTupleList
extends Object

A file-mapped list of StringCTokenTuples. Slightly slower than a simple in-memory sort, but capable of storing and sorting very long lists without using large quantities of heap memory.
The index of entry positions in the list's file is stored in memory, leading to a usage of one Integer's worth of memory for each entry.

Usage:

- Call add(java.lang.String, net.java.sen.dictionary.CToken) one or more times

- Call sort() once. Once the list has been sorted, it is no longer valid to add new entries

- Call get(int) to retrieve entries from the sorted list


Constructor Summary
VirtualTupleList()
           
 
Method Summary
 void add(String string, CToken ctoken)
          Adds a StringCTokenTuple to the list.
 StringCTokenTuple get(int index)
          Retrieves an entry from the list.
 int size()
          Returns the number of entries in the list
 void sort()
          Sorts the list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualTupleList

public VirtualTupleList()
                 throws IOException
Throws:
IOException
Method Detail

add

public void add(String string,
                CToken ctoken)
         throws IOException
Adds a StringCTokenTuple to the list. Passed in as the Tuple's constituent parts to avoid creating an object that we immediately serialise and throw away

Parameters:
string - The string
ctoken - The CToken
Throws:
IOException

get

public StringCTokenTuple get(int index)
Retrieves an entry from the list. Only valid after the list has been sorted

Parameters:
index - The index of the entry to retrieve
Returns:
The list entry

sort

public void sort()
          throws IOException
Sorts the list

Throws:
IOException

size

public int size()
Returns the number of entries in the list

Returns:
The number of entries in the list


Copyright © 2012. All Rights Reserved.