11#include "abortable_stream.h"
20#include <google/protobuf/message.h>
22#include <util/stream/input.h>
23#include <util/stream/output.h>
24#include <util/generic/yexception.h>
25#include <util/generic/maybe.h>
35template<
class... TProtoRowTypes>
40 (TIsBaseOf<::google::protobuf::Message, TProtoRowTypes>::Value && ...),
41 "Template parameters can only be protobuf types");
43 TProtoOneOf() =
delete;
50template<
class... TSkiffRowTypes>
56 "Template parameters can only be SkiffRow types");
58 TSkiffRowOneOf() =
delete;
68template <
class TTuple>
69struct TProtoOneOfFromTuple;
72struct TProtoOneOfFromTuple<std::tuple<Ts...>>
78struct TProtoOneOfUnique
80 using TTuple =
typename TUniqueTypes<std::tuple<>, std::tuple<Ts...>>::TType;
81 using TType =
typename TProtoOneOfFromTuple<TTuple>::TType;
91struct INodeReaderImpl;
92struct IYaMRReaderImpl;
93struct IProtoReaderImpl;
94struct ISkiffRowReaderImpl;
95struct INodeWriterImpl;
96struct IYaMRWriterImpl;
97struct IProtoWriterImpl;
117 ,
public IOutputStream
120 virtual size_t GetBufferMemoryUsage()
const
128 ,
public IOutputStream
131 virtual TWriteFileFragmentResult GetWriteFragmentResult()
const = 0;
154 const TMaybe<ui32>& rangeIndex,
155 const TMaybe<ui64>& rowIndex,
156 const std::exception_ptr& error) = 0;
173 ,
public IOutputStream
189 virtual size_t GetBufferMemoryUsage()
const
206 virtual IOutputStream*
GetStream(
size_t tableIndex)
const = 0;
217 virtual size_t GetBufferMemoryUsage()
const
246template <
class T,
class>
307 if (reader && reader->
IsValid()) {
317 return Reader_ == it.Reader_;
336 if (!Reader_->IsValid()) {
378template <
class T,
class>
396template <
class T,
class>
410 size_t GetBufferMemoryUsage()
const;
475 const TString& cookie,
487 const TDistributedWriteFileCookie& cookie,
505 const ::google::protobuf::Descriptor& descriptor,
513 const TDistributedWriteTableCookie& cookie,
537 const TString& cookie,
549 const TString& cookie,
573 virtual ::TIntrusivePtr<INodeReaderImpl> CreateNodeReader(
576 virtual ::TIntrusivePtr<IYaMRReaderImpl> CreateYaMRReader(
579 virtual ::TIntrusivePtr<IProtoReaderImpl> CreateProtoReader(
582 const ::google::protobuf::Message* prototype) = 0;
584 virtual ::TIntrusivePtr<ISkiffRowReaderImpl> CreateSkiffRowReader(
587 const ISkiffRowSkipperPtr& skipper,
588 const NSkiff::TSkiffSchemaPtr& requestedSchema,
589 const NSkiff::TSkiffSchemaPtr& parserSchema) = 0;
591 virtual ::TIntrusivePtr<INodeReaderImpl> CreateNodeTablePartitionReader(
594 virtual ::TIntrusivePtr<IProtoReaderImpl> CreateProtoTablePartitionReader(
595 const TString& cookie,
597 const ::google::protobuf::Message* prototype) = 0;
599 virtual ::TIntrusivePtr<ISkiffRowReaderImpl> CreateSkiffRowTablePartitionReader(
600 const TString& cookie,
602 const ISkiffRowSkipperPtr& skipper,
603 const NSkiff::TSkiffSchemaPtr& requestedSchema,
604 const NSkiff::TSkiffSchemaPtr& parserSchema) = 0;
606 virtual ::TIntrusivePtr<INodeWriterImpl> CreateNodeWriter(
609 virtual ::TIntrusivePtr<IYaMRWriterImpl> CreateYaMRWriter(
612 virtual ::TIntrusivePtr<IProtoWriterImpl> CreateProtoWriter(
615 const ::google::protobuf::Message* prototype) = 0;
617 virtual ::TIntrusivePtr<ITableFragmentWriter<TNode>> CreateNodeFragmentWriter(
618 const TDistributedWriteTableCookie& cookie,
621 virtual ::TIntrusivePtr<ITableFragmentWriter<TYaMRRow>> CreateYaMRFragmentWriter(
622 const TDistributedWriteTableCookie& cookie,
625 virtual ::TIntrusivePtr<ITableFragmentWriter<Message>> CreateProtoFragmentWriter(
626 const TDistributedWriteTableCookie& cookie,
628 const ::google::protobuf::Message* prototype) = 0;
641 IInputStream* stream,
650template <
class... Ts>
652 IInputStream* stream,
664 IInputStream* stream,
671 IInputStream* stream,
const TTableReaderOptions& options);
676 IInputStream* stream,
const TTableReaderOptions& options);
682 IInputStream* stream,
684 const ::google::protobuf::Descriptor* descriptor);
689 IInputStream* stream,
691 TVector<const ::google::protobuf::Descriptor*> descriptors);
Interface representing YT file reader.
Definition io.h:112
Interface representing YT file writer.
Definition io.h:118
Interface for creating table and file readers and writer.
Definition io.h:460
virtual IFileReaderPtr CreateFileReader(const TRichYPath &path, const TFileReaderOptions &options=TFileReaderOptions())=0
Create a reader for file at path.
virtual TTableWriterPtr<::google::protobuf::Message > CreateTableWriter(const TRichYPath &path, const ::google::protobuf::Descriptor &descriptor, const TTableWriterOptions &options=TTableWriterOptions())=0
Create a writer to write protobuf messages with specified descriptor.
virtual IFileReaderPtr CreateBlobTableReader(const TYPath &path, const TKey &blobId, const TBlobTableReaderOptions &options=TBlobTableReaderOptions())=0
Create a reader for blob table at path.
virtual TRawTableWriterPtr CreateRawWriter(const TRichYPath &path, const TFormat &format, const TTableWriterOptions &options=TTableWriterOptions())=0
Create a reader to write a table using specified format.
TTableReaderPtr< T > CreateTableReader(const TRichYPath &path, const TTableReaderOptions &options=TTableReaderOptions())
Create a typed reader for table at path.
virtual TRawTableReaderPtr CreateRawReader(const TRichYPath &path, const TFormat &format, const TTableReaderOptions &options=TTableReaderOptions())=0
Create a reader to read a table using specified format.
virtual TRawTableReaderPtr CreateRawTablePartitionReader(const TString &cookie, const TFormat &format, const TTablePartitionReaderOptions &options={})=0
Create raw reader of table partition.
TTableWriterPtr< T > CreateTableWriter(const TRichYPath &path, const TTableWriterOptions &options=TTableWriterOptions())
Create a typed writer for table at path.
virtual IFileFragmentWriterPtr CreateFileFragmentWriter(const TDistributedWriteFileCookie &cookie, const TFileFragmentWriterOptions &options=TFileFragmentWriterOptions())=0
Create a fragment writer for given distributed file session cookie.
TTableReaderPtr< T > CreateTablePartitionReader(const TString &cookie, const TTablePartitionReaderOptions &options={})
Create reader of table partition.
ITableFragmentWriterPtr< T > CreateTableFragmentWriter(const TDistributedWriteTableCookie &cookie, const TTableFragmentWriterOptions &options={})
Create a fragment table writer for given distributed table session cookie.
virtual IFileWriterPtr CreateFileWriter(const TRichYPath &path, const TFileWriterOptions &options=TFileWriterOptions())=0
Create a writer for file at path.
virtual IFileReaderPtr CreateFilePartitionReader(const TString &cookie, const TFilePartitionReaderOptions &options={})=0
Create a reader of file partition.
Interface to deal with multiple raw output streams.
Definition io.h:197
virtual size_t GetStreamCount() const =0
Get amount of managed streams.
virtual void OnRowFinished(size_t tableIndex)=0
This handler must be called right after the next row has been written.
virtual void Abort()
Try to abort writing process as soon as possible (makes sense for multi-threaded writers).
Definition io.h:214
virtual IOutputStream * GetStream(size_t tableIndex) const =0
Get stream corresponding to the specified table index.
Class template for distributed table API fragment writer.
Definition io.h:423
virtual TWriteTableFragmentResult GetWriteFragmentResult() const =0
Get object with session-specific table fragment write information.
virtual void AddRow(const T &row)=0
Submit a row for writing.
virtual void Finish()=0
Completes writing and makes write fragment result available.
Class of exceptions connected to reading or writing tables or files.
Definition io.h:104
"Marker" type to use for several protobuf types in NYT::TTableReader.
Definition io.h:37
Low-level interface to read YT table with retries.
Definition io.h:140
virtual bool HasRangeIndices() const =0
May the input stream contain table ranges?
virtual void ResetRetries()=0
Resets retry attempt count to the initial value (then Retry() can be called again).
virtual bool Retry(const TMaybe< ui32 > &rangeIndex, const TMaybe< ui64 > &rowIndex, const std::exception_ptr &error)=0
Retry table read starting from the specified rangeIndex and rowIndex.
Low-level interface to write YT table.
Definition io.h:174
virtual void NotifyRowEnd()=0
Call this method after complete row representation is written to the stream.
virtual void Abort()
Try to abort writing process as soon as possible (makes sense for multi-threaded writers).
Definition io.h:186
Class to facilitate reading table rows sorted by key.
Definition io.h:381
void Next()
Move cursor to the next range.
TTableReader< T > & GetRange()
Get reader for rows with the same key.
bool IsValid() const
Check whether all rows are read.
Iterator for use in range-based-for.
Definition io.h:302
TTableReaderIterator(TTableReader< T > *reader)
Construct iterator from table reader (can be nullptr).
Definition io.h:305
bool operator==(const TTableReaderIterator &it) const
Equality operator.
Definition io.h:315
TTableReader< T > & operator*()
Dereference operator.
Definition io.h:321
TTableReaderIterator & operator++()
Preincrement operator.
Definition io.h:333
const TTableReader< T > & operator*() const
Const dereference operator.
Definition io.h:327
Class template to read typed rows from YT tables.
Definition io.h:249
bool IsRawReaderExhausted() const
Returns true if job raw input stream was closed and false otherwise.
const T & GetRow() const
Get current row.
void Abort()
Abort the reader, interrupting any in-progress or future reads.
ui32 GetTableIndex() const
Get table index of the current row.
ui32 GetRangeIndex() const
Get range index of the current row (zero if it is unknown or read request contains no ranges).
bool IsEndOfStream() const
Returns true if job consumed all the input and false otherwise.
void MoveRow(T *result)
Extract current row to result; further calls to GetRow and MoveRow will fail.
void Next()
Move the cursor to the next row.
bool IsValid() const
Check whether all the rows were read.
i64 GetTabletIndex() const
Get current tablet index (for ordered dynamic tables).
ui64 GetRowIndex() const
Get current row index (zero if it unknown).
bool IsAborted() const
Check whether the reader is aborted.
T MoveRow()
Extract current row; further calls to GetRow and MoveRow will fail.
Class template to write typed rows to YT tables.
Definition io.h:399
void AddRow(const T &row)
Submit a row for writing.
::TIntrusivePtr< IProtoReaderImpl > CreateProtoReader(IInputStream *stream, const TTableReaderOptions &options, const ::google::protobuf::Descriptor *descriptor)
Create a protobuf table reader from a stream.
Main namespace of YT client.
Definition abortable_stream.h:7
TTableReaderPtr< TNode > CreateTableReader< TNode >(IInputStream *stream, const TTableReaderOptions &options)
Create a NYT::TNode table reader from a stream.
TTableReaderPtr< typename NDetail::TProtoOneOfUnique< Ts... >::TType > CreateProtoMultiTableReader(IInputStream *stream, const TTableReaderOptions &options={})
Create a protobuf multi table reader from a stream.
TTableReaderIterator< T > end(TTableReader< T > &)
Function to facilitate range-based-for for NYT::TTableReader.
Definition io.h:359
TTableReaderPtr< TYaMRRow > CreateTableReader< TYaMRRow >(IInputStream *stream, const TTableReaderOptions &options)
Create a NYT::TYaMRRow table reader from a stream.
TTableReaderPtr< T > CreateConcreteProtobufReader(TTableReader< Message > *reader)
Convert generic protobuf table reader to a concrete one (for certain type T).
TTableReaderPtr< T > CreateTableReader(IInputStream *stream, const TTableReaderOptions &options={})
Create a protobuf table reader from a stream.
TTableReaderIterator< T > begin(TTableReader< T > &reader)
Function to facilitate range-based-for for NYT::TTableReader.
Definition io.h:350
TTableReaderPtr< Message > CreateGenericProtobufReader(TTableReader< T > *reader)
Convert a concrete (for certain type T) protobuf table reader to a generic one.
Options for NYT::IIOClient::CreateBlobTableReader.
Definition client_method_options.h:368
Options for writing file fragment in distributed session.
Definition client_method_options.h:677
Options for NYT::IClient::CreateFilePartitionReader.
Definition client_method_options.h:585
Options for reading file from YT.
Definition client_method_options.h:569
Options for writing file.
Definition client_method_options.h:647
Definition skiff_row.h:38
Path with additional attributes.
Definition common.h:1040
Options for writing table fragment in distributed session.
Definition client_method_options.h:878
Options for NYT::IClient::CreatePartitionTableReader.
Definition client_method_options.h:805
Options for NYT::IClient::CreateTableReader.
Definition client_method_options.h:781
Options for NYT::IClient::CreateTableWriter.
Definition client_method_options.h:825
Type representing YaMR table row.
Definition io.h:445
TStringBuf Value
Value column.
Definition io.h:453
TStringBuf Key
Key column.
Definition io.h:447
TStringBuf SubKey
Subkey column.
Definition io.h:450