|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--edu.iu.iv.common.persistence.ivc.DelimitedSparseDoubleMatrixModelPersister
This persister can persist to and restore from a delimited file using a sparse matrix format.
The extension for such files is ".smf". The format for such a file is as follows:
The first line should start with the delimiter, then the number of rows and columns. This
delimiter is used as the delimiter throughout the file.
The second line stores the row labels preceded by the string "RowLabels" (case-insensitive)
and the delimiter
The labels must be separated by the delimiter again.
The third line stores the column labels preceded by the string "columnlabels" (case-insensitive)
and the delimiter. The labels must be separated by the delimiter again.
The fourth line has the string "Data" (case-insensitive) followed by a delimiter and
a number that specifies the index offset. For example, if the line looks like this:
data,1
then a 1-based indexing is used. If it looks like this:
data,0
then 0-based indexing is used, etc. If nothing is specified, then the matrix
is assumed to have 0-based indexing.
Finally the data of the matrix is stored in file.
The data is stored in coordinate-wise format with the first column containing the row indices
the second column containing the column indices and the third column containing the values.
Note that the first two columns must be integers else the persister will fail!
An example of a complete file:
,5,5 rowlabels,doc1,doc2,doc3,doc4,doc5 columnlabels,term1,term2,term3,term4,term5 data,1 1,1,12.0 1,2,15 1,5,0 2,3,-11.0 2,1,94.5343 Note: The elements don't need to be ordered.The labels are optional and you may provide only some of the labels if you wish. For example, the following line:
| Constructor Summary | |
DelimitedSparseDoubleMatrixModelPersister()
|
|
| Method Summary | |
boolean |
canPersist(java.lang.Object model)
Determines if this persister can persist the given data model. |
boolean |
canRestore(ResourceDescriptor resource)
|
PropertyMap |
getPropertyMap()
Gets a property map describing this persister and file format (if applicable). |
void |
persist(java.lang.Object model,
ResourceDescriptor resource)
Persists a data model to a resource such as a file or database. |
java.lang.Object |
restore(ResourceDescriptor resource)
Restores a model from the specified resource. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DelimitedSparseDoubleMatrixModelPersister()
| Method Detail |
public PropertyMap getPropertyMap()
Persister
getPropertyMap in interface PersisterPersister.getPropertyMap()
public void persist(java.lang.Object model,
ResourceDescriptor resource)
throws java.io.IOException,
PersistenceException
Persister
persist in interface Persistermodel - The model to be persisted.resource - The resource to persist the model to.
java.io.IOException
PersistenceExceptionPersister.persist(java.lang.Object, edu.iu.iv.core.persistence.ResourceDescriptor)
public java.lang.Object restore(ResourceDescriptor resource)
throws java.io.IOException,
PersistenceException
Persister
restore in interface Persisterjava.io.IOException
PersistenceExceptionPersister.restore(edu.iu.iv.core.persistence.ResourceDescriptor)public boolean canPersist(java.lang.Object model)
Persister
canPersist in interface Persistermodel - The model for which persistence is desired.
Persister.canPersist(java.lang.Object)public boolean canRestore(ResourceDescriptor resource)
canRestore in interface Persisterresource - The resource from which restoration is desired.
An example of a resource is a file on disk.
Persister.canRestore(ResourceDescriptor)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||