org.gcube.data.tmf.impl
Class AbstractWriter

java.lang.Object
  extended by org.gcube.data.tmf.impl.AbstractWriter
All Implemented Interfaces:
Serializable, SourceWriter

public abstract class AbstractWriter
extends Object
implements SourceWriter

Partial implementation of SourceWriter.

Plugins that extend this class need only to implement SourceWriter.add(Tree) and SourceWriter.update(Tree), as the implementation of the stream-based methods can be derived from these methods.

Note that the derived implementations are naive and highly inefficient if the data source supports more direct implementations. In this case, plugins can override derived implementations selectively.

Author:
Fabio Simeoni
See Also:
SourceWriter, Serialized Form

Constructor Summary
AbstractWriter()
           
 
Method Summary
 org.gcube.data.streams.Stream<org.gcube.data.tml.outcomes.AddTreeOutcome> add(org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> stream)
          Default implementation of SourceWriter.add(Stream) based on repeated delegation to SourceWriter.add(Tree).
 org.gcube.data.streams.Stream<org.gcube.data.tml.outcomes.UpdateTreeFailure> update(org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> deltaStream)
          Default implementation of SourceWriter.update(Stream) based on repeated delegation to SourceWriter.update(Tree).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gcube.data.tmf.api.SourceWriter
add, update
 

Constructor Detail

AbstractWriter

public AbstractWriter()
Method Detail

add

public org.gcube.data.streams.Stream<org.gcube.data.tml.outcomes.AddTreeOutcome> add(org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> stream)
                                                                              throws org.gcube.data.tml.exceptions.UnsupportedOperationException,
                                                                                     Exception
Default implementation of SourceWriter.add(Stream) based on repeated delegation to SourceWriter.add(Tree).

It should be inherited only if the source does not support stream-based additions.

Specified by:
add in interface SourceWriter
Parameters:
stream - the stream of trees
Returns:
a stream of outcomes, one per tree in the input stream and in the same relative order.
Throws:
org.gcube.data.tml.exceptions.UnsupportedOperationException - if the data source does not support this operation
org.gcube.data.tml.exceptions.UnsupportedRequestException - if the data source does not support this request
Exception - if the operation fails as a whole for an unexpected error
See Also:
SourceWriter.add(Stream)

update

public org.gcube.data.streams.Stream<org.gcube.data.tml.outcomes.UpdateTreeFailure> update(org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> deltaStream)
                                                                                    throws org.gcube.data.tml.exceptions.UnsupportedOperationException,
                                                                                           Exception
Default implementation of SourceWriter.update(Stream) based on repeated delegation to SourceWriter.update(Tree).

It should be inherited only if the source does not support stream-based updates.

Specified by:
update in interface SourceWriter
Parameters:
deltaStream - the delta trees
Returns:
the failures that may occur in the process
Throws:
org.gcube.data.tml.exceptions.UnsupportedOperationException - if the data source does not support this operation
org.gcube.data.tml.exceptions.UnsupportedRequestException - if the data source does not support this request
Exception - if the operation fails as a whole for an expected error
See Also:
SourceWriter.update(Stream)


Copyright © 2012. All Rights Reserved.