Package gaiasky.data
Class StreamingOctreeLoader
java.lang.Object
gaiasky.data.StreamingOctreeLoader
- All Implemented Interfaces:
ISceneGraphLoader
,IObserver
- Direct Known Subclasses:
OctreeGroupLoader
Contains the infrastructure common to all multi-file octree loaders which
streams data on-demand from disk and unloads unused data.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
The daemon loader thread. -
Field Summary
Modifier and TypeFieldDescriptionprotected StreamingOctreeLoader.OctreeLoaderThread
Daemon thread that gets the data loading requests and serves them.protected String
protected int
static StreamingOctreeLoader
protected long
Last time of a queue clear event went through.protected static int
Default load queue size in octants.protected long[]
Loaded octant ids, for logging.protected int
protected boolean
Whether loading is paused or not.protected static int
Maximum number of pages to send to load every batch.protected int
protected long
Max number of stars loaded at once.protected String
protected static long
Minimum time to pass to be able to clear the queue again.protected String
protected int
Current number of stars that are loaded.protected String
protected static int
Data will be pre-loaded at startup down to this octree depth.protected Queue<OctreeNode>
The octant loading queue.protected Queue<OctreeNode>
This queue is sorted ascending by access date, so that we know which element to release if needed (oldest). -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Tells the daemon to immediately stop the loading of octants and wait for new dataprotected void
addLoadedInfo(long id, int nobjects)
void
addToQueue(OctreeNode octant)
static void
Clears the current load queue.void
Removes all octants from the current load queue.protected void
void
Tells the loader to start loading the octants in the queue.static int
static int
void
initialize(String[] files)
void
initialize(uk.ac.starlink.util.DataSource ds)
com.badlogic.gdx.utils.Array<? extends SceneGraphNode>
loadData()
void
loadLod(Integer lod, AbstractOctreeWrapper octreeWrapper)
Loads all the levels of detail until the given one.abstract boolean
loadOctant(OctreeNode octant, AbstractOctreeWrapper octreeWrapper, boolean fullInit)
Loads the data of the given octant.void
loadOctant(OctreeNode octant, AbstractOctreeWrapper octreeWrapper, Integer level)
Loads the data of the given octant and its children down to the given level.int
loadOctants(com.badlogic.gdx.utils.Array<OctreeNode> octants, AbstractOctreeWrapper octreeWrapper, AtomicBoolean abort)
Loads the objects of the given octants.protected abstract AbstractOctreeWrapper
Loads the nodes and the octree.void
static void
queue(OctreeNode octant)
Adds the octant to the load queue.void
setDescription(String description)
void
void
static void
touch(OctreeNode octant)
Moves the octant to the end of the unload queue.void
touchOctant(OctreeNode octant)
Puts it at the end of the toUnloadQueue.void
unloadOctant(OctreeNode octant, AbstractOctreeWrapper octreeWrapper)
Unloads the given octant.
-
Field Details
-
PRELOAD_DEPTH
protected static final int PRELOAD_DEPTHData will be pre-loaded at startup down to this octree depth.- See Also:
- Constant Field Values
-
LOAD_QUEUE_MAX_SIZE
protected static final int LOAD_QUEUE_MAX_SIZEDefault load queue size in octants.- See Also:
- Constant Field Values
-
MIN_QUEUE_CLEAR_MS
protected static final long MIN_QUEUE_CLEAR_MSMinimum time to pass to be able to clear the queue again.- See Also:
- Constant Field Values
-
MAX_LOAD_CHUNK
protected static final int MAX_LOAD_CHUNKMaximum number of pages to send to load every batch.- See Also:
- Constant Field Values
-
instance
-
nLoadedStars
protected int nLoadedStarsCurrent number of stars that are loaded. -
maxLoadedStars
protected final long maxLoadedStarsMax number of stars loaded at once. -
toLoadQueue
The octant loading queue. -
loadingPaused
protected boolean loadingPausedWhether loading is paused or not. -
lastQueueClearMs
protected long lastQueueClearMsLast time of a queue clear event went through. -
name
-
description
-
params
-
toUnloadQueue
This queue is sorted ascending by access date, so that we know which element to release if needed (oldest). -
loadedIds
protected long[] loadedIdsLoaded octant ids, for logging. -
loadedObjects
protected int loadedObjects -
maxLoadedIds
protected int maxLoadedIds -
idxLoadedIds
protected int idxLoadedIds -
metadata
-
particles
-
daemon
Daemon thread that gets the data loading requests and serves them.
-
-
Constructor Details
-
StreamingOctreeLoader
public StreamingOctreeLoader()
-
-
Method Details
-
initialize
public void initialize(uk.ac.starlink.util.DataSource ds)- Specified by:
initialize
in interfaceISceneGraphLoader
-
initialize
- Specified by:
initialize
in interfaceISceneGraphLoader
- Throws:
RuntimeException
-
loadData
- Specified by:
loadData
in interfaceISceneGraphLoader
-
addLoadedInfo
protected void addLoadedInfo(long id, int nobjects) -
flushLoadedIds
protected void flushLoadedIds() -
loadOctreeData
Loads the nodes and the octree. -
queue
Adds the octant to the load queue. -
clearQueue
public static void clearQueue()Clears the current load queue. -
getLoadQueueSize
public static int getLoadQueueSize() -
getNLoadedStars
public static int getNLoadedStars() -
touch
Moves the octant to the end of the unload queue. -
emptyLoadQueue
public void emptyLoadQueue()Removes all octants from the current load queue. This happens when the camera viewport changes radically (velocity is high, direction changes a lot, etc.) so that the old octants are dropped and newly observed octants are loaded right away. -
addToQueue
-
touchOctant
Puts it at the end of the toUnloadQueue. -
flushLoadQueue
public void flushLoadQueue()Tells the loader to start loading the octants in the queue. -
abortCurrentLoading
public void abortCurrentLoading()Tells the daemon to immediately stop the loading of octants and wait for new data -
loadLod
Loads all the levels of detail until the given one.- Parameters:
lod
- The level of detail to load.octreeWrapper
- The octree wrapper.- Throws:
IOException
- When any of the level's files fails to load.
-
loadOctant
public void loadOctant(OctreeNode octant, AbstractOctreeWrapper octreeWrapper, Integer level) throws IOExceptionLoads the data of the given octant and its children down to the given level.- Parameters:
octant
- The octant to load.octreeWrapper
- The octree wrapper.level
- The depth to load.- Throws:
IOException
- When the octant's file fails to load.
-
loadOctants
public int loadOctants(com.badlogic.gdx.utils.Array<OctreeNode> octants, AbstractOctreeWrapper octreeWrapper, AtomicBoolean abort) throws IOExceptionLoads the objects of the given octants.- Parameters:
octants
- The list holding the octants to load.octreeWrapper
- The octree wrapper.abort
- State variable that will be set to true if an abort is called.- Returns:
- The actual number of loaded octants.
- Throws:
IOException
- When any of the octants' files fail to load.
-
unloadOctant
Unloads the given octant. -
loadOctant
public abstract boolean loadOctant(OctreeNode octant, AbstractOctreeWrapper octreeWrapper, boolean fullInit) throws IOExceptionLoads the data of the given octant.- Parameters:
octant
- The octant to load.octreeWrapper
- The octree wrapper.fullInit
- Whether to fully initialise the objects (on-demand load) or not (startup)- Returns:
- True if the octant was loaded, false otherwise
- Throws:
IOException
- When the octant file could not be read.
-
notify
-
setName
- Specified by:
setName
in interfaceISceneGraphLoader
-
setDescription
- Specified by:
setDescription
in interfaceISceneGraphLoader
-
setParams
- Specified by:
setParams
in interfaceISceneGraphLoader
-