Package edu.ie3.datamodel.io.sink
Class CsvFileSink
java.lang.Object
edu.ie3.datamodel.io.sink.CsvFileSink
- All Implemented Interfaces:
DataSink,InputDataSink,OutputDataSink
Sink that provides all capabilities to write
UniqueEntitys to .csv-files. Be careful
about using methods other than persistJointGrid(JointGridContainer) because all other
methods do not check for duplicate entries but only dump the data they received. In
contrast, when using persistJointGrid(JointGridContainer), all nested entities get
extracted first and then dumped individually without any duplicate lines.- Since:
- 19.03.20
-
Constructor Summary
ConstructorsConstructorDescriptionCsvFileSink(String baseFolderPath) CsvFileSink(String baseFolderPath, FileNamingStrategy fileNamingStrategy, boolean initFiles, String csvSep) Create an instance of a csv file sink that can be used to persist Unique entities.CsvFileSink(String baseFolderPath, ProcessorProvider processorProvider, FileNamingStrategy fileNamingStrategy, boolean initFiles, String csvSep) Create an instance of a csv file sink that can be used to persist Unique entities. -
Method Summary
Modifier and TypeMethodDescription<T extends UniqueEntity>
voidpersist(T entity) Should implement the entry point of a data sink to persist an entity.<T extends UniqueEntity>
voidpersistAll(Collection<T> entities) Should implement the entry point of a data sink to persist multiple entities in a collection.<C extends InputEntity>
voidpersistAllIgnoreNested(Collection<C> entities) Should implement the entry point of a data sink to persist multiple input entities in a collection.<C extends InputEntity>
voidpersistAllIncludeNested(Collection<C> entities) Should offer a clear alternative toInputDataSink.persistAllIgnoreNested(java.util.Collection<C>)if the nested entities of the input entities are supposed to be persisted as well.<C extends InputEntity>
voidpersistIgnoreNested(C entity) Should implement the entry point of a data sink to persist an input entity.<C extends InputEntity>
voidpersistIncludeNested(C entity) Should offer a clear alternative toInputDataSink.persistIgnoreNested(C)if the nested entities of an input entity are supposed to be persisted as well.voidpersistJointGrid(JointGridContainer jointGridContainer) Should implement the entry point of a data sink to persist a wholeJointGridContainer<E extends TimeSeriesEntry<V>,V extends Value>
voidpersistTimeSeries(TimeSeries<E, V> timeSeries) Should implement the handling of a whole time series.voidshutdown()Shutdown this sink and do all cleanup operations (e.g.
-
Constructor Details
-
CsvFileSink
-
CsvFileSink
public CsvFileSink(String baseFolderPath, FileNamingStrategy fileNamingStrategy, boolean initFiles, String csvSep) Create an instance of a csv file sink that can be used to persist Unique entities. This implementation processes in sequential order. To parallelize this process one might consider starting several sinks and use them for specific entities.- Parameters:
baseFolderPath- the base folder path where the files should be put intofileNamingStrategy- the data sink file naming strategy that should be usedinitFiles- true if the files should be created during initialization (might create files, that only consist of a headline, because no data will be written into them), false otherwisecsvSep- the csv file separator that should be use
-
CsvFileSink
public CsvFileSink(String baseFolderPath, ProcessorProvider processorProvider, FileNamingStrategy fileNamingStrategy, boolean initFiles, String csvSep) Create an instance of a csv file sink that can be used to persist Unique entities. This implementation processes in sequential order. To parallelize this process one might consider starting several sinks and use them for specific entities. Be careful when providing your ownProcessorProviderbecause if you're not 100% sure that it knows about all entities you're going to process exceptions might occur. Therefore it is strongly advised to either use a constructor without providing theProcessorProvideror provide a generalProcessorProviderby callingProcessorProvider()- Parameters:
baseFolderPath- the base folder path where the files should be put intoprocessorProvider- the processor provided that should be used for entity serializationfileNamingStrategy- the data sink file naming strategy that should be usedinitFiles- true if the files should be created during initialization (might create files, that only consist of a headline, because no data will be written into them), false otherwisecsvSep- the csv file separator that should be use
-
-
Method Details
-
persistAll
Description copied from interface:DataSinkShould implement the entry point of a data sink to persist multiple entities in a collection. By default this method should take care about the extraction process of nested entities (if any) of input entities and useExtractoraccordingly. For a faster method that neglects the nested objects persistence and only persists the uuid of the nested * objects (if any), instead of the object itself useInputDataSink.persistAllIgnoreNested(java.util.Collection<C>)- Specified by:
persistAllin interfaceDataSink- Type Parameters:
T- bounded to be all unique entities. Handling of specific entities is normally then executed by a specificEntityProcessor- Parameters:
entities- a collection of entities that should be persisted
-
persist
Description copied from interface:DataSinkShould implement the entry point of a data sink to persist an entity. By default this method should take care about the extraction process of nested entities (if any) of input entities and useExtractoraccordingly. For an faster method e.g. that neglects the nested objects persistence and only persists the uuid of the nested objects (if any), instead of the object itself useInputDataSink.persistIgnoreNested(C)- Specified by:
persistin interfaceDataSink- Type Parameters:
T- bounded to be all unique entities. Handling of specific entities is normally then executed by a specificEntityProcessor- Parameters:
entity- the entity that should be persisted
-
persistIgnoreNested
Description copied from interface:InputDataSinkShould implement the entry point of a data sink to persist an input entity. In contrast toDataSink.persist(C)andInputDataSink.persistIncludeNested(C), this method should not take care about the extraction process of nested entities (if any) but only persist the uuid of the nested entity. This might speed up things a little bit because of missing if-/else-clauses but can also lead to missing persisted data that should be persisted, but is not e.g. nested types that are not available anymore afterwards. It might be useful especially for all entities without nested entities. For all doubts about if the provided entity contains needed nested data or notDataSink.persist(UniqueEntity)is the recommended method to be used.- Specified by:
persistIgnoreNestedin interfaceInputDataSink- Type Parameters:
C- bounded to be all input entities. Handling of the entities is normally then executed by aInputEntityProcessor- Parameters:
entity- the entity that should be persisted
-
persistAllIgnoreNested
Description copied from interface:InputDataSinkShould implement the entry point of a data sink to persist multiple input entities in a collection. In contrast toDataSink.persistAll(Collection)andInputDataSink.persistAllIncludeNested(java.util.Collection<C>), this method should not take care about the extraction process of nested entities (if any) but only persist the uuid of the nested entity. This might speed up things a little bit because of missing if-/else-clauses but but can also lead to missing persisted data that should be persisted, but is not e.g. nested types that are not available anymore afterwards. It might be useful especially for all entities without nested entities. For all doubts about if the provided entity contains needed nested data or notDataSink.persistAll(Collection)is the recommended method to be used.- Specified by:
persistAllIgnoreNestedin interfaceInputDataSink- Type Parameters:
C- bounded to be all unique entities. Handling of the entities is normally then executed by aInputEntityProcessor- Parameters:
entities- the entities that should be persisted
-
persistIncludeNested
Description copied from interface:InputDataSinkShould offer a clear alternative toInputDataSink.persistIgnoreNested(C)if the nested entities of an input entity are supposed to be persisted as well. However this might take longer as additional entities have to be extracted and persisted.- Specified by:
persistIncludeNestedin interfaceInputDataSink- Type Parameters:
C- bounded to be all input entities. Handling of specific entities is normally then executed by a specificInputEntityProcessor- Parameters:
entity- the entity that should be persisted including its nested entities
-
persistAllIncludeNested
Description copied from interface:InputDataSinkShould offer a clear alternative toInputDataSink.persistAllIgnoreNested(java.util.Collection<C>)if the nested entities of the input entities are supposed to be persisted as well. However this might take longer as additional entities have to be extracted and persisted.- Specified by:
persistAllIncludeNestedin interfaceInputDataSink- Type Parameters:
C- bounded to be all unique entities. Handling of the entities is normally then executed by aInputEntityProcessor- Parameters:
entities- the entities that should be persisted including its nested entities
-
persistJointGrid
Description copied from interface:InputDataSinkShould implement the entry point of a data sink to persist a wholeJointGridContainer- Specified by:
persistJointGridin interfaceInputDataSink- Parameters:
jointGridContainer- theJointGridContainerthat should be persisted
-
shutdown
public void shutdown()Description copied from interface:DataSinkShutdown this sink and do all cleanup operations (e.g. closing of theDataConnector) here -
persistTimeSeries
public <E extends TimeSeriesEntry<V>,V extends Value> void persistTimeSeries(TimeSeries<E, V> timeSeries) Description copied from interface:DataSinkShould implement the handling of a whole time series. Therefore the single entries have to be extracted and persisted accordingly.- Specified by:
persistTimeSeriesin interfaceDataSink- Type Parameters:
E- Type of entry in the time seriesV- Type of actual value, that is inside the entry- Parameters:
timeSeries- Time series to persist
-