2019-03-07 11:32:45 +01:00
|
|
|
package org.warp.jcwdb.lists;
|
2019-02-01 00:04:51 +01:00
|
|
|
|
2019-02-05 17:56:28 +01:00
|
|
|
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
2019-03-07 11:32:45 +01:00
|
|
|
import org.warp.jcwdb.database.IDatabaseTools;
|
|
|
|
import org.warp.jcwdb.annotations.DBDataType;
|
|
|
|
import org.warp.jcwdb.annotations.DBField;
|
2019-02-01 00:04:51 +01:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2019-03-07 11:32:45 +01:00
|
|
|
public class ObjectJCWDBList<T> extends JCWDBList<T> {
|
2019-02-01 00:04:51 +01:00
|
|
|
|
2019-02-05 17:56:28 +01:00
|
|
|
@DBField(id = 0, type = DBDataType.REFERENCES_LIST)
|
|
|
|
private LongArrayList indices;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected LongArrayList getIndices() {
|
|
|
|
return indices;
|
|
|
|
}
|
|
|
|
|
2019-03-07 11:32:45 +01:00
|
|
|
public ObjectJCWDBList() {
|
2019-02-01 00:04:51 +01:00
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2019-03-07 11:32:45 +01:00
|
|
|
public ObjectJCWDBList(IDatabaseTools databaseTools) throws IOException {
|
2019-03-02 17:47:24 +01:00
|
|
|
super(databaseTools);
|
2019-02-05 17:56:28 +01:00
|
|
|
indices = new LongArrayList();
|
|
|
|
}
|
|
|
|
|
2019-02-01 00:04:51 +01:00
|
|
|
@Override
|
|
|
|
protected T loadItem(long uid) throws IOException {
|
2019-03-02 17:47:24 +01:00
|
|
|
return databaseTools.getObjectsIO().loadObject(uid);
|
2019-02-01 00:04:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void writeItemToDisk(long uid, T item) throws IOException {
|
2019-03-02 17:47:24 +01:00
|
|
|
databaseTools.getObjectsIO().setObject(uid, item);
|
2019-02-01 00:04:51 +01:00
|
|
|
}
|
|
|
|
}
|