org.basex.data
Class MemData

java.lang.Object
  extended by org.basex.data.Data
      extended by org.basex.data.MemData

public final class MemData
extends Data

This class stores and organizes the database table and the index structures for textual content in a compressed memory structure. The table mapping is documented in Data.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 
Fields inherited from class org.basex.data.Data
atnindex, ATTR, atvindex, cache, COMM, DOC, ELEM, ftxindex, meta, nspaces, paths, PI, pins, resources, tagindex, TEXT, txtindex
 
Constructor Summary
MemData(Data data)
          Light-weight constructor, adopting data structures from the specified database.
MemData(Names tag, Names att, PathSummary ps, Namespaces ns, Prop pr, Index txt, Index atv)
          Constructor.
MemData(PathSummary ps, Namespaces ns, Prop pr)
          Constructor.
MemData(Prop pr)
          Constructor, creating a new, empty database.
 
Method Summary
 void close()
          Closes the database.
 void closeIndex(IndexType type)
          Closes the specified index.
protected  void delete(int pre, boolean text)
          Deletes the specified text entry.
 void finishUpdate()
          Finishes an update operation: removes the update file and the exclusive lock.
protected  long index(int pre, int id, byte[] txt, int kind)
          Indexes a text and returns the reference.
protected  void indexDelete(int pre, int size)
          Delete a node and its descendants from the corresponding indexes.
 void setIndex(IndexType type, Index index)
          Assigns the specified index.
 boolean startUpdate()
          Starts an update operation: writes a file to disk to indicate that an update is going on, and exclusively locks the table.
 byte[] text(int pre, boolean text)
          Returns a text (text, comment, pi) or attribute value.
 double textDbl(int pre, boolean text)
          Returns a text (text, comment, pi) or attribute value as double value.
 long textItr(int pre, boolean text)
          Returns a text (text, comment, pi) or attribute value as integer value.
 int textLen(int pre, boolean text)
          Returns the byte length of a text (text, comment, pi).
 void updateText(int pre, byte[] val, int kind)
          Updates the specified text or attribute value.
 
Methods inherited from class org.basex.data.Data
atom, attr, attSize, attValue, count, delete, dist, dist, doc, elem, id, info, inMemory, insert, insert, insertAttr, iter, kind, name, name, ns, nsFlag, nsFlag, parent, pre, pre, replace, size, size, text, toString, update, update, uri
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemData

public MemData(PathSummary ps,
               Namespaces ns,
               Prop pr)
Constructor.

Parameters:
ps - path summary
ns - namespaces
pr - database properties

MemData

public MemData(Names tag,
               Names att,
               PathSummary ps,
               Namespaces ns,
               Prop pr,
               Index txt,
               Index atv)
Constructor.

Parameters:
tag - tag index
att - attribute name index
ps - path summary
ns - namespaces
pr - database properties
txt - text index
atv - attribute value index

MemData

public MemData(Data data)
Light-weight constructor, adopting data structures from the specified database.

Parameters:
data - data reference

MemData

public MemData(Prop pr)
Constructor, creating a new, empty database.

Parameters:
pr - property reference
Method Detail

close

public void close()
Description copied from class: Data
Closes the database.

Specified by:
close in class Data

closeIndex

public void closeIndex(IndexType type)
Description copied from class: Data
Closes the specified index.

Specified by:
closeIndex in class Data
Parameters:
type - index to be closed

setIndex

public void setIndex(IndexType type,
                     Index index)
Description copied from class: Data
Assigns the specified index.

Specified by:
setIndex in class Data
Parameters:
type - index to be opened
index - index instance

startUpdate

public boolean startUpdate()
Description copied from class: Data
Starts an update operation: writes a file to disk to indicate that an update is going on, and exclusively locks the table.

Specified by:
startUpdate in class Data
Returns:
success flag

finishUpdate

public void finishUpdate()
Description copied from class: Data
Finishes an update operation: removes the update file and the exclusive lock.

Specified by:
finishUpdate in class Data

text

public byte[] text(int pre,
                   boolean text)
Description copied from class: Data
Returns a text (text, comment, pi) or attribute value.

Specified by:
text in class Data
Parameters:
pre - pre value
text - text/attribute flag
Returns:
atomized value

textItr

public long textItr(int pre,
                    boolean text)
Description copied from class: Data
Returns a text (text, comment, pi) or attribute value as integer value.

Specified by:
textItr in class Data
Parameters:
pre - pre value
text - text/attribute flag
Returns:
numeric value

textDbl

public double textDbl(int pre,
                      boolean text)
Description copied from class: Data
Returns a text (text, comment, pi) or attribute value as double value.

Specified by:
textDbl in class Data
Parameters:
pre - pre value
text - text/attribute flag
Returns:
numeric value

textLen

public int textLen(int pre,
                   boolean text)
Description copied from class: Data
Returns the byte length of a text (text, comment, pi).

Specified by:
textLen in class Data
Parameters:
pre - pre value
text - text/attribute flag
Returns:
length

delete

protected void delete(int pre,
                      boolean text)
Description copied from class: Data
Deletes the specified text entry.

Specified by:
delete in class Data
Parameters:
pre - pre value
text - text (text, comment or pi) or attribute flag

updateText

public void updateText(int pre,
                       byte[] val,
                       int kind)
Description copied from class: Data
Updates the specified text or attribute value.

Specified by:
updateText in class Data
Parameters:
pre - pre value
val - content
kind - node kind

index

protected long index(int pre,
                     int id,
                     byte[] txt,
                     int kind)
Description copied from class: Data
Indexes a text and returns the reference.

Specified by:
index in class Data
Parameters:
pre - pre value
id - id value
txt - text to be indexed
kind - node kind
Returns:
reference

indexDelete

protected void indexDelete(int pre,
                           int size)
Description copied from class: Data
Delete a node and its descendants from the corresponding indexes.

Specified by:
indexDelete in class Data
Parameters:
pre - pre value of the node to delete
size - number of descendants