java.io.Closeable
, java.lang.AutoCloseable
public class WorkbenchVirtualizer
extends java.lang.Object
implements java.io.Closeable
An instance of this class acts as a thin layer between the workbench and a set of disk queues, possibly one for
each visit state, stored in a Database
. Each queue is associated with a scheme+authority (the key).
Values are given by an increasing timestamp (written as a vByte-encoded integer) followed by a path+query.
Path+queries are enqueued using the enqueueURL(VisitState, ByteArrayList)
method. They can be dequeued in batches
(the method uses cursors). When a queue is no longer needed, it can be removed.
Constructor | Description |
---|---|
WorkbenchVirtualizer(Frontier frontier) |
Creates the virtualizer.
|
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
|
void |
collectIf(double threshold,
double targetRatio) |
Performs a garbage collection if the space used is below a given threshold, reaching a given target ratio.
|
long |
count(VisitState visitState) |
Returns the number of path+queries associated with the given visit state.
|
int |
dequeuePathQueries(VisitState visitState,
int maxUrls) |
Dequeues at most the given number of path+queries into the given visit state.
|
void |
enqueueURL(VisitState visitState,
ByteArrayList url) |
Enqueues the given URL as a path+query associated to the scheme+authority of the given visit state.
|
int |
onDisk() |
Returns the number of visit states on disk.
|
void |
readMetadata() |
|
void |
remove(VisitState visitState) |
Removes all path+queries associated with the given visit state.
|
java.lang.String |
toString() |
public WorkbenchVirtualizer(Frontier frontier)
frontier
- the frontier instantiating this virtualizer.public int dequeuePathQueries(VisitState visitState, int maxUrls) throws java.io.IOException
Note that the path+queries are directly enqueued into the visit state using
VisitState.enqueuePathQuery(byte[])
.
visitState
- the visitState in which path+queries will be moved.maxUrls
- the maximum number of path+queries to move.java.io.IOException
public long count(VisitState visitState)
visitState
- the visitState whose path+queries are to be counted.public int onDisk()
public void remove(VisitState visitState) throws java.io.IOException
visitState
- the visitState whose path+queries are to be removed.java.io.IOException
public void enqueueURL(VisitState visitState, ByteArrayList url) throws java.io.IOException
visitState
- the visitState to which the URL must be added.url
- a BUbiNG URL
.java.io.IOException
public void collectIf(double threshold, double targetRatio) throws java.io.IOException
threshold
- if ByteArrayDiskQueues.ratio()
is below this value, a garbage collection will be performed.targetRatio
- passed to ByteArrayDiskQueues.count(Object)
.java.io.IOException
public void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public void readMetadata() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException