2010-02-26 18:52:25 +00:00
|
|
|
/**
|
|
|
|
* \file LSMPersistentStoreImpl.h
|
|
|
|
* \brief This file is a wrapper over the LSM-Tree network protocol.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 Yahoo, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LSM_PSTORE_IMPL_H
|
|
|
|
#define LSM_PSTORE_IMPL_H
|
|
|
|
|
|
|
|
#include "PersistentStore.h"
|
2010-09-15 21:53:51 +00:00
|
|
|
#include "datatuple.h"
|
2010-02-26 18:52:25 +00:00
|
|
|
//#include "LSMCoreImpl.h"
|
|
|
|
|
|
|
|
struct logstore_handle_t;
|
|
|
|
|
2010-09-15 21:53:51 +00:00
|
|
|
class LSMIterator;
|
|
|
|
|
2010-02-26 18:52:25 +00:00
|
|
|
class LSMPersistentStoreImpl : public PersistentStore
|
|
|
|
{
|
2010-09-15 21:53:51 +00:00
|
|
|
friend class LSMIterator;
|
|
|
|
friend class LSMPersistentParent;
|
|
|
|
protected:
|
2010-09-29 17:58:34 +00:00
|
|
|
|
2010-02-26 18:52:25 +00:00
|
|
|
// LSMCoreImpl& mySQLCoreImpl_;
|
2010-09-15 21:53:51 +00:00
|
|
|
bool isOrdered_;
|
2010-02-26 18:52:25 +00:00
|
|
|
unsigned char * my_strcat(const std::string& table,
|
|
|
|
const std::string& tablet,
|
|
|
|
const std::string& key,
|
|
|
|
size_t * len);
|
2010-09-15 21:53:51 +00:00
|
|
|
void my_strtok(const unsigned char* in, size_t len, std::string& table, std::string& tablet, std::string& key);
|
2010-02-26 18:52:25 +00:00
|
|
|
unsigned char * buf_key(const TabletMetadata& m, const RecordKey& r,
|
|
|
|
size_t * len);
|
2010-09-15 21:53:51 +00:00
|
|
|
unsigned char * buf_key(const TabletMetadata& m, const std::string s,
|
|
|
|
size_t * len);
|
2010-02-26 18:52:25 +00:00
|
|
|
unsigned char * buf_val(const StorageRecord &val,
|
|
|
|
size_t * len);
|
2010-09-15 21:53:51 +00:00
|
|
|
SuCode::ResponseCode tup_buf(StorageRecord &ret, datatuple * tup);
|
|
|
|
SuCode::ResponseCode key_buf(StorageRecord &ret,
|
|
|
|
const unsigned char * buf, size_t buf_len);
|
2010-02-26 18:52:25 +00:00
|
|
|
SuCode::ResponseCode val_buf(StorageRecord &ret,
|
|
|
|
const unsigned char * buf, size_t buf_len);
|
|
|
|
public:
|
2010-09-15 21:53:51 +00:00
|
|
|
|
|
|
|
LSMPersistentStoreImpl(bool ordered);
|
2010-02-26 18:52:25 +00:00
|
|
|
virtual ~LSMPersistentStoreImpl();
|
|
|
|
|
2010-09-15 21:53:51 +00:00
|
|
|
SuCode::ResponseCode initMetadataMetadata(TabletMetadata& m);
|
|
|
|
|
2010-02-26 18:52:25 +00:00
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode init(const SectionConfig& config);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
bool isOrdered();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode addEmptyTablet(TabletMetadata& tabletMeta);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode dropTablet(TabletMetadata& tabletMeta);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode clearTabletRange(TabletMetadata& tabletMeta,
|
|
|
|
uint32_t removalLimit);
|
|
|
|
|
2010-09-15 21:53:51 +00:00
|
|
|
/**
|
|
|
|
Not part of PersistentStore api. PersistentParent needs to
|
|
|
|
provide this method as well, but it gets a string instead of a
|
|
|
|
TabletMetadata...
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode getApproximateTableSize(std::string tabletMeta,
|
|
|
|
int64_t& tableSize,
|
|
|
|
int64_t & rowCount);
|
|
|
|
|
2010-02-26 18:52:25 +00:00
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode getApproximateTableSize(TabletMetadata& tabletMeta,
|
|
|
|
int64_t& tableSize,
|
|
|
|
int64_t & rowCount);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode get(const TabletMetadata& tabletMeta,
|
|
|
|
StorageRecord& recordData);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode update(const TabletMetadata& tabletMeta,
|
|
|
|
const StorageRecord& updateData);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode insert(const TabletMetadata& tabletMeta,
|
|
|
|
const StorageRecord& insertData);
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode remove(const TabletMetadata& tabletMeta,
|
|
|
|
const RecordKey& recordKey);
|
2010-09-15 21:53:51 +00:00
|
|
|
/**
|
|
|
|
* Not part of PersistentStore API. However, PersistentParent needs to implement ping
|
|
|
|
*/
|
|
|
|
bool ping();
|
2010-02-26 18:52:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
2010-09-15 21:53:51 +00:00
|
|
|
StorageRecordIterator
|
|
|
|
scan(const TabletMetadata& tabletMeta, const ScanContinuation& continuation,
|
|
|
|
ScanSelect::Selector selector, const uint64_t expiryTime, unsigned int scanLimit, size_t byteLimit);
|
2010-02-26 18:52:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode getSnapshotExporter(const TabletMetadata& tabletMeta,
|
|
|
|
const std::string& snapshotId,
|
|
|
|
SnapshotExporterAutoPtr& exporter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode getSnapshotImporter(const TabletMetadata& tabletMeta,
|
|
|
|
const std::string& version,
|
|
|
|
const std::string& snapshotId,
|
|
|
|
SnapshotImporterAutoPtr& snapshot) ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode getIncomingCopyProgress(const TabletMetadata& metadata,
|
|
|
|
const std::string& snapshotId,
|
|
|
|
int64_t& current,
|
|
|
|
int64_t& estimated) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See PersistentStore API
|
|
|
|
*/
|
|
|
|
SuCode::ResponseCode getOutgoingCopyProgress(const TabletMetadata& metadata,
|
|
|
|
const std::string& snapshotId,
|
|
|
|
int64_t& current,
|
|
|
|
int64_t& estimated) const;
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* connect to the database. Noop if already connected.
|
|
|
|
*
|
|
|
|
* @return SuCode::SuOk if successful, error otherwise
|
|
|
|
*/
|
|
|
|
// SuCode::ResponseCode connect();
|
|
|
|
|
|
|
|
private:
|
|
|
|
LSMPersistentStoreImpl(LSMPersistentStoreImpl &);
|
|
|
|
LSMPersistentStoreImpl operator=(LSMPersistentStoreImpl &);
|
|
|
|
|
2010-09-15 21:53:51 +00:00
|
|
|
void metadata_buf(TabletMetadata &m, const unsigned char * buf, size_t len);
|
|
|
|
void buf_metadata(unsigned char ** buf, size_t *len, const TabletMetadata &m);
|
|
|
|
protected:
|
2010-02-26 18:52:25 +00:00
|
|
|
logstore_handle_t * l_;
|
2010-09-15 22:37:50 +00:00
|
|
|
logstore_handle_t * scan_l_; // XXX make sure that one scan handle per process suffices.
|
2010-02-26 18:52:25 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*LSM_PSTORE_IMPL_H*/
|