libgrape-lite
A C++ library for parallel graph processing
Loading...
Searching...
No Matches
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.
 
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

◆ Close()

void grape::LocalIOAdaptor::Close ( )
overridevirtual

Implements grape::IOAdaptorBase.

◆ Configure()

bool grape::LocalIOAdaptor::Configure ( const std::string &  key,
const std::string &  value 
)
overridevirtual

Configure sub-class specific items. e.g., odps_access_key = abcd; oss_read_concurrency = 16; whether ReadLine for local location uses std::getline;.

Implements grape::IOAdaptorBase.

◆ IsExist()

bool grape::LocalIOAdaptor::IsExist ( )
overridevirtual

Implements grape::IOAdaptorBase.

◆ MakeDirectory()

void grape::LocalIOAdaptor::MakeDirectory ( const std::string &  path)
overridevirtual

Implements grape::IOAdaptorBase.

◆ Open() [1/2]

void grape::LocalIOAdaptor::Open ( )
overridevirtual

Implements grape::IOAdaptorBase.

◆ Open() [2/2]

void grape::LocalIOAdaptor::Open ( const char *  mode)
overridevirtual

Implements grape::IOAdaptorBase.

◆ Read()

bool grape::LocalIOAdaptor::Read ( void *  buffer,
size_t  size 
)
overridevirtual

Implements grape::IOAdaptorBase.

◆ ReadArchive()

bool grape::LocalIOAdaptor::ReadArchive ( OutArchive archive)
overridevirtual

Implements grape::IOAdaptorBase.

◆ ReadLine()

bool grape::LocalIOAdaptor::ReadLine ( std::string &  line)
overridevirtual

Implements grape::IOAdaptorBase.

◆ 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.

◆ Write()

bool grape::LocalIOAdaptor::Write ( void *  buffer,
size_t  size 
)
overridevirtual

Implements grape::IOAdaptorBase.

◆ WriteArchive()

bool grape::LocalIOAdaptor::WriteArchive ( InArchive archive)
overridevirtual

Implements grape::IOAdaptorBase.