jigcell.compare.data
Class PackedTreeDataElement2

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by jigcell.compare.impl.Transferer
          extended by jigcell.compare.data.DataElement
              extended by jigcell.compare.data.EditableDataElement
                  extended by jigcell.compare.data.TreeDataElement
                      extended by jigcell.compare.data.PackedTreeDataElement
                          extended by jigcell.compare.data.PackedTreeDataElement2
All Implemented Interfaces:
java.awt.datatransfer.Transferable, java.io.Serializable, IDataElement, IEditableDataElement

public class PackedTreeDataElement2
extends PackedTreeDataElement

An implementation of EditableDataElement that uses an AVL tree to store values. The tree keys are primitives. Each key can hold a pack of values so this structure uses less memory than SparseTreeDataElement2 for dense collections. The size of the pack is adjustable. This structure becomes faster and smaller than PackedTreeDataElement around 25 times the pack size entries. PackedTreeDataElement2 does not protect against concurrent edits. The maximum number of values this element can contain is approximately 2^40, but is likely to fail before then.

This code is licensed under the DARPA BioCOMP Open Source License. See LICENSE for more details.

Author:
Nicholas Allen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jigcell.compare.data.EditableDataElement
EditableDataElement.EditableDataElementDelegate
 
Nested classes/interfaces inherited from interface jigcell.compare.IDataElement
IDataElement.Type
 
Field Summary
private  it.unimi.dsi.fastutil.longs.ModifiedLong2ObjectAVLTreeMap values
          Element values
 
Fields inherited from class jigcell.compare.data.PackedTreeDataElement
MESSAGE_CHUNKSIZEERROR, MESSAGE_LASTERROR, size, SIZE_DEFAULTPACK
 
Fields inherited from class jigcell.compare.data.TreeDataElement
length
 
Fields inherited from class jigcell.compare.data.EditableDataElement
DOUBLE_NaN, DOUBLE_NINFINITY, DOUBLE_PINFINITY, MESSAGE_PARSEBLOCKERROR, MESSAGE_PARSEERROR, MESSAGE_PARSEEXTRAERROR, MESSAGE_PARSELITERALERROR, PATTERN_FP, prototypeChild, TOKEN_ALL, TOKEN_BLOCKELEMENT, TOKEN_BLOCKEND, TOKEN_BLOCKSTART, TOKEN_LITERAL
 
Fields inherited from class jigcell.compare.data.DataElement
lockCount, LONGPOOL, PATTERN_FALSE, PATTERN_NAN, PATTERN_NINFINITY, PATTERN_NINFINITY2, PATTERN_NULL, PATTERN_PINFINITY, PATTERN_PINFINITY2, PATTERN_TRUE, PATTERN_VOID, SIZE_LONGPOOL
 
Fields inherited from class jigcell.compare.impl.Transferer
CSV_FOOTER, CSV_LINEPOSTPEND, CSV_LINEPREPEND, CSV_LINESEPARATOR, HTML_FOOTER, HTML_HEADPOSTPEND, HTML_HEADPREPEND, HTML_HEADSEPARATOR, HTML_LINEPOSTPEND, HTML_LINEPREPEND, HTML_LINESEPARATOR
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, MOVE, NONE
 
Constructor Summary
PackedTreeDataElement2()
          Creates a new data element backed by a tree with packed storage.
PackedTreeDataElement2(int size)
          Creates a new data element with packed storage.
 
Method Summary
protected  EditableDataElement constructNew()
          Constructs a new element of the same type as this element.
static IEditableDataElement createElement(java.io.Reader reader)
          Generates a PackedTreeDataElement2 from streaming input.
static IEditableDataElement createElementSafe(java.io.Reader reader)
          Generates a PackedTreeDataElement2 from streaming input.
protected  java.lang.Object getDirect(long pos)
          Gets the value at a position. Boolean values are represented by Boolean. Empty values are represented by null. Integral values are represented by Integer. Literal values are represented by String. Multiple values are represented by DataElement. Real values are represented by Double. The position of the object may be anything.
protected  long lastValue()
          Finds the last defined value.
protected  void putDirect(long pos, java.lang.Object value)
          Sets the value at a position. Boolean values are represented by Boolean. Empty values are represented by null. Integral values are represented by Integer. Literal values are represented by String. Multiple values are represented by DataElement. Real values are represented by Double. The position of the object may be anything.
protected  void removeDirect(long pos)
          Removes the value at a position. The position of the object may be anything.
 
Methods inherited from class jigcell.compare.data.TreeDataElement
clear, getLength, getValues, isAvailable, memoryLock, memoryUnlock, setLengthDirect, setValue, setValues, unsetValue
 
Methods inherited from class jigcell.compare.data.EditableDataElement
copyValue, createElement, createElement, createElement, createElementSafe, createElementSafe, createScalarElement, createScalarElement, createScalarElement, createScalarElement, forceSlice, forceSlice, forceSlice, forceSlice, getBooleanValue, getChecked, getIntegralValue, getListValue, getLiteralValue, getPrototypeChild, getRealValue, getType, getType, makeList, moveValue, putChecked, setPrototypeChild, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueInterpreted, setValueInterpreted, swapValues
 
Methods inherited from class jigcell.compare.data.DataElement
forceBooleanValue, forceBooleanValue, forceIntegralValue, forceIntegralValue, forceListValue, forceLiteralValue, forceLiteralValue, forceRealValue, forceRealValue, forceSlice, getBooleanValue, getIntegralValue, getLiteralValue, getLongObject, getRealValue, getSlice, getSlice, getSlice, getSlice, getSlice, getTransferData, isScalar, isSpecialNonNumeric, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString
 
Methods inherited from class jigcell.compare.impl.Transferer
addExtension, addFlavor, createCSVTable, createFormattedTable, createHTMLTable, getExceptionRecorder, getExpectedClasses, getExpectedClasses, getExpectedClasses, getFlavors, getFlavors, getPreferredExtensions, getPreferredExtensions, getTransferClass, getTransferDataFlavors, getTransferFlavor, isDataFlavorSupported, transfer
 
Methods inherited from class javax.swing.TransferHandler
canImport, createTransferable, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getSourceActions, getVisualRepresentation, importData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jigcell.compare.IDataElement
forceBooleanValue, forceBooleanValue, forceIntegralValue, forceIntegralValue, forceListValue, forceLiteralValue, forceLiteralValue, forceRealValue, forceRealValue, forceSlice, getBooleanValue, getIntegralValue, getLiteralValue, getRealValue, getSlice, getSlice, getSlice, getSlice, getSlice, isScalar, toString, toString, toString, toString, toString, toString, toString
 
Methods inherited from interface java.awt.datatransfer.Transferable
getTransferData, getTransferDataFlavors, isDataFlavorSupported
 

Field Detail

values

private it.unimi.dsi.fastutil.longs.ModifiedLong2ObjectAVLTreeMap values
Element values

Constructor Detail

PackedTreeDataElement2

public PackedTreeDataElement2()
Creates a new data element backed by a tree with packed storage.


PackedTreeDataElement2

public PackedTreeDataElement2(int size)
Creates a new data element with packed storage.

Parameters:
size - Pack size
Method Detail

createElement

public static IEditableDataElement createElement(java.io.Reader reader)
Generates a PackedTreeDataElement2 from streaming input.

Parameters:
reader - Reader

createElementSafe

public static IEditableDataElement createElementSafe(java.io.Reader reader)
Generates a PackedTreeDataElement2 from streaming input. If an element cannot be created, an empty element in returned.

Parameters:
reader - Reader

constructNew

protected EditableDataElement constructNew()
Constructs a new element of the same type as this element.

Overrides:
constructNew in class PackedTreeDataElement

getDirect

protected java.lang.Object getDirect(long pos)
Gets the value at a position. Boolean values are represented by Boolean. Empty values are represented by null. Integral values are represented by Integer. Literal values are represented by String. Multiple values are represented by DataElement. Real values are represented by Double. The position of the object may be anything.

Overrides:
getDirect in class PackedTreeDataElement
Parameters:
pos - Position

lastValue

protected long lastValue()
Finds the last defined value.

Overrides:
lastValue in class PackedTreeDataElement

putDirect

protected void putDirect(long pos,
                         java.lang.Object value)
Sets the value at a position. Boolean values are represented by Boolean. Empty values are represented by null. Integral values are represented by Integer. Literal values are represented by String. Multiple values are represented by DataElement. Real values are represented by Double. The position of the object may be anything.

Overrides:
putDirect in class PackedTreeDataElement
Parameters:
pos - Position
value - Value

removeDirect

protected void removeDirect(long pos)
Removes the value at a position. The position of the object may be anything.

Overrides:
removeDirect in class PackedTreeDataElement
Parameters:
pos - Position