libgrape-lite
A C++ library for parallel graph processing
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
grape::LocalIOAdaptor Class Reference

A default adaptor to read/write files from local locations. More...

#include <local_io_adaptor.h>

Inheritance diagram for grape::LocalIOAdaptor:
grape::IOAdaptorBase

Public Member Functions

 LocalIOAdaptor (std::string location)
 
void Open () override
 
void Open (const char *mode) override
 
void Close () override
 
bool Configure (const std::string &key, const std::string &value) override
 Configure sub-class specific items. e.g., odps_access_key = abcd; oss_read_concurrency = 16; whether ReadLine for local location uses std::getline;.
 
bool SetPartialRead (int index, int total_parts) override
 Set each worker only scan related parts of the whole file. More...
 
bool ReadLine (std::string &line) override
 
bool ReadArchive (OutArchive &archive) override
 
bool WriteArchive (InArchive &archive) override
 
bool Read (void *buffer, size_t size) override
 
bool Write (void *buffer, size_t size) override
 
void MakeDirectory (const std::string &path) override
 
bool IsExist () override
 

Private Types

enum  FileLocation { kFileLocationBegin = 0 , kFileLocationCurrent = 1 , kFileLocationEnd = 2 }
 

Private Member Functions

int64_t tell ()
 
void seek (int64_t offset, FileLocation seek_from)
 
bool setPartialReadImpl ()
 

Private Attributes

FILE * file_
 
std::fstream fs_
 
std::string location_
 
bool using_std_getline_
 
char buff [LINE_SIZE] {}
 
bool enable_partial_read_
 
std::vector< int64_t > partial_read_offset_
 
int total_parts_
 
int index_
 

Static Private Attributes

static constexpr size_t LINE_SIZE = 65535
 

Detailed Description

A default adaptor to read/write files from local locations.

Member Function Documentation

◆ SetPartialRead()

bool grape::LocalIOAdaptor::SetPartialRead ( int  index,
int  total_parts 
)
overridevirtual

Set each worker only scan related parts of the whole file.

for local: read with offset, from a big file.

Implements grape::IOAdaptorBase.