Package org.openrefine.runners.testing
Class TestingRunner
- java.lang.Object
-
- org.openrefine.runners.testing.TestingRunner
-
-
Field Summary
-
Fields inherited from interface org.openrefine.model.Runner
COMPLETION_MARKER_FILE_NAME, GRID_ENCODING
-
-
Constructor Summary
Constructors Constructor Description TestingRunner()
TestingRunner(RunnerConfiguration configuration)
Constructor provided to match the expected signature of runners.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> ChangeData<T>
changeDataFromList(List<IndexedData<T>> changeData)
Creates aChangeData
from an in-memory list of indexed data.<T> ChangeData<T>
emptyChangeData()
Creates an empty change data object of a given type, marked as incomplete.protected static void
ensureSerializable(Object obj)
Asserts that an object is serializable using Java serialization.Grid
gridFromIterable(ColumnModel columnModel, CloseableIterable<Row> rows, Map<String,OverlayModel> overlayModels, long rowCount, long recordCount)
Creates aGrid
from an iterable collection of rows.Grid
gridFromList(ColumnModel columnModel, List<Row> rows, Map<String,OverlayModel> overlayModels)
Creates aGrid
from an in-memory list of rows, which will be numbered from 0 to length-1.<T> ChangeData<T>
loadChangeData(File path, ChangeDataSerializer<T> serializer)
Loads aChangeData
serialized at a given location.Grid
loadGrid(File path)
Loads aGrid
serialized at a given location.Grid
loadTextFile(String path, MultiFileReadingProgress progress, Charset encoding)
Loads a text file as aGrid
with a single column named "Column" and whose contents are the lines in the file, parsed as strings.Grid
loadTextFile(String path, MultiFileReadingProgress progress, Charset encoding, long limit)
Loads a text file as aGrid
with a single column named "Column" and whose contents are the lines in the file, parsed as strings.protected static <T> T
serializeAndDeserialize(T obj)
Serializes an object and then deserializes it back.boolean
supportsProgressReporting()
Indicates whether this implementation supports progress reporting.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openrefine.model.Runner
changeDataFromIterable
-
-
-
-
Constructor Detail
-
TestingRunner
public TestingRunner()
-
TestingRunner
public TestingRunner(RunnerConfiguration configuration)
Constructor provided to match the expected signature of runners.
-
-
Method Detail
-
ensureSerializable
protected static void ensureSerializable(Object obj)
Asserts that an object is serializable using Java serialization.- Parameters:
obj
-
-
serializeAndDeserialize
protected static <T> T serializeAndDeserialize(T obj)
Serializes an object and then deserializes it back. This ensures that the object is serializable and is useful to simulate distributed environments (for instance to null out all transient fields).- Type Parameters:
T
-- Parameters:
obj
-- Returns:
-
loadGrid
public Grid loadGrid(File path) throws IOException
Description copied from interface:Runner
Loads aGrid
serialized at a given location.- Specified by:
loadGrid
in interfaceRunner
- Parameters:
path
- the directory where the Grid is stored- Returns:
- the grid
- Throws:
IOException
- when loading the grid failed, or when the grid's serialization was incomplete (lacking a _SUCCESS marker)
-
loadChangeData
public <T> ChangeData<T> loadChangeData(File path, ChangeDataSerializer<T> serializer) throws IOException
Description copied from interface:Runner
Loads aChangeData
serialized at a given location.- Specified by:
loadChangeData
in interfaceRunner
- Parameters:
path
- the directory where the ChangeData is stored- Throws:
IOException
- when loading the grid failed
-
gridFromList
public Grid gridFromList(ColumnModel columnModel, List<Row> rows, Map<String,OverlayModel> overlayModels)
Description copied from interface:Runner
Creates aGrid
from an in-memory list of rows, which will be numbered from 0 to length-1.- Specified by:
gridFromList
in interfaceRunner
-
gridFromIterable
public Grid gridFromIterable(ColumnModel columnModel, CloseableIterable<Row> rows, Map<String,OverlayModel> overlayModels, long rowCount, long recordCount)
Description copied from interface:Runner
Creates aGrid
from an iterable collection of rows. By default, this just gathers the iterable in a list and delegates toRunner.gridFromList(ColumnModel, List, Map)
, but implementations may implement a different approach which delays the loading of the collection in memory.- Specified by:
gridFromIterable
in interfaceRunner
rowCount
- if the number of rows is known, supply it in this parameter as it might improve efficiency. Otherwise, set to -1.recordCount
- if the number of records is known, supply it in this parameter as it might improve efficiency. Otherwise, set to -1.
-
changeDataFromList
public <T> ChangeData<T> changeDataFromList(List<IndexedData<T>> changeData)
Description copied from interface:Runner
Creates aChangeData
from an in-memory list of indexed data. The list is required to be sorted.- Specified by:
changeDataFromList
in interfaceRunner
-
emptyChangeData
public <T> ChangeData<T> emptyChangeData()
Description copied from interface:Runner
Creates an empty change data object of a given type, marked as incomplete.- Specified by:
emptyChangeData
in interfaceRunner
-
loadTextFile
public Grid loadTextFile(String path, MultiFileReadingProgress progress, Charset encoding) throws IOException
Description copied from interface:Runner
Loads a text file as aGrid
with a single column named "Column" and whose contents are the lines in the file, parsed as strings.- Specified by:
loadTextFile
in interfaceRunner
encoding
- TODO- Throws:
IOException
-
loadTextFile
public Grid loadTextFile(String path, MultiFileReadingProgress progress, Charset encoding, long limit) throws IOException
Description copied from interface:Runner
Loads a text file as aGrid
with a single column named "Column" and whose contents are the lines in the file, parsed as strings.- Specified by:
loadTextFile
in interfaceRunner
- Parameters:
path
- the path to the text file to loadencoding
- TODOlimit
- the maximum number of lines to read- Throws:
IOException
-
supportsProgressReporting
public boolean supportsProgressReporting()
Description copied from interface:Runner
Indicates whether this implementation supports progress reporting. If not, progress objects will be left untouched when passed to methods in this interface.- Specified by:
supportsProgressReporting
in interfaceRunner
-
-