iterator
Class OBuf

java.lang.Object
  extended byiterator.OBuf
All Implemented Interfaces:
GlobalConst

public class OBuf
extends java.lang.Object
implements GlobalConst

O_buf::Put takes tuples and stores them on the buffer pages that were passed to O_buf::init. O_buf::flush inserts them enmass into a temporary HeapFile.


Field Summary
 
Fields inherited from interface global.GlobalConst
INVALID_PAGE, MAX_NAME, MAX_SPACE, MAXATTRNAME, MAXFILENAME, MAXINDEXNAME, MINIBASE_BUFFER_POOL_SIZE, MINIBASE_DB_SIZE, MINIBASE_DEFAULT_SHAREDMEM_SIZE, MINIBASE_MAX_TRANSACTIONS, MINIBASE_MAXARRSIZE, MINIBASE_PAGESIZE, NUMBUF
 
Constructor Summary
OBuf()
          fault constructor no args -- use init to initialize
 
Method Summary
 long flush()
          returns the # of tuples written.
 void init(byte[][] bufs, int n_pages, int tSize, Heapfile temp_fd, boolean buffer)
          O_buf is an output buffer.
 Tuple Put(Tuple buf)
          Writes a tuple to the output buffer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OBuf

public OBuf()
fault constructor no args -- use init to initialize

Method Detail

init

public void init(byte[][] bufs,
                 int n_pages,
                 int tSize,
                 Heapfile temp_fd,
                 boolean buffer)
O_buf is an output buffer. It takes as input:

Parameters:
bufs - temporary buffer to pages.(EACH ELEMENT IS A SINGLE BUFFER PAGE).
n_pages - the number of pages
tSize - tuple size
temp_fd - fd of a HeapFile
buffer - true => it is used as a buffer => if it is flushed, print a nasty message. it is false by default.

Put

public Tuple Put(Tuple buf)
          throws java.io.IOException,
                 java.lang.Exception
Writes a tuple to the output buffer

Parameters:
buf - the tuple written to buffer
Returns:
the position of tuple which is in buffer
Throws:
java.io.IOException - some I/O fault
java.lang.Exception - other exceptions

flush

public long flush()
           throws java.io.IOException,
                  java.lang.Exception
returns the # of tuples written.

Returns:
the numbers of tuples written
Throws:
java.io.IOException - some I/O fault
java.lang.Exception - other exceptions