sapling/eden/scm/lib/backingstore/c_api/HgNativeBackingStore.h
Zeyi (Rice) Fan 854637e854 implement batch blob import for HgNativeBackingStore
Summary:
NOTE: This stack works together, they are separated for easier reviewing. Check D21723465 if you want to read this stack in one place.

This diff encapsulates the newly added batch blob import API in backingstore crate, and expose it to EdenFS. It converts incoming complex data structures down to primitive data types that can go through FFI boundary.

Reviewed By: xavierd

Differential Revision: D21697578

fbshipit-source-id: 8f5505ef4cab342dfa710798a04df4e0e94055d9
2020-06-10 19:29:25 -07:00

55 lines
1.5 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/Range.h>
#include <memory>
#include "eden/scm/lib/backingstore/c_api/RustBackingStore.h"
namespace folly {
class IOBuf;
} // namespace folly
namespace facebook {
namespace eden {
class HgNativeBackingStore {
public:
HgNativeBackingStore(folly::StringPiece repository, bool useEdenApi);
std::unique_ptr<folly::IOBuf>
getBlob(folly::ByteRange name, folly::ByteRange node, bool local);
/**
* Imports a list of files from Rust contentstore. `names` and `nodes` are
* required to have the same length, and both are combined to constitute a
* query for one file.
*
* Whenever the requested file is read, `resolve` will be called with the
* index of the request in the passed vectors, along with an unique pointer
* pointing to the file content.
*
* If `local` is true, this method will only look requested file on disk.
*/
void getBlobBatch(
const std::vector<std::pair<folly::ByteRange, folly::ByteRange>>&
requests,
bool local,
std::function<void(size_t, std::unique_ptr<folly::IOBuf>)>&& resolve);
std::shared_ptr<RustTree> getTree(folly::ByteRange node);
void refresh();
private:
std::unique_ptr<RustBackingStore, std::function<void(RustBackingStore*)>>
store_;
};
} // namespace eden
} // namespace facebook