@@ -38,7 +38,7 @@ namespace stellar
38
38
class AbstractLedgerTxn ;
39
39
class Application ;
40
40
class BucketManager ;
41
- struct EvictionMetrics ;
41
+ struct EvictionStatistics ;
42
42
43
43
class Bucket : public std ::enable_shared_from_this<Bucket>,
44
44
public NonMovableOrCopyable
@@ -49,33 +49,9 @@ class Bucket : public std::enable_shared_from_this<Bucket>,
49
49
50
50
std::unique_ptr<BucketIndex const > mIndex {};
51
51
52
- // Lazily-constructed and retained for read path, one for BucketListDB reads
53
- // and one for eviction scans
54
- std::unique_ptr<XDRInputFileStream> mIndexStream ;
55
- std::unique_ptr<XDRInputFileStream> mEvictionStream ;
56
-
57
52
// Returns index, throws if index not yet initialized
58
53
BucketIndex const & getIndex () const ;
59
54
60
- // Returns (lazily-constructed) file stream for bucketDB search. Note
61
- // this might be in some random position left over from a previous read --
62
- // must be seek()'ed before use.
63
- XDRInputFileStream& getIndexStream ();
64
-
65
- // Returns (lazily-constructed) file stream for eviction scans. Unlike the
66
- // indexStream, this should retain its position in-between calls. However, a
67
- // node performing catchup or joining the network may need to begin evicting
68
- // mid-bucket, so this stream should still be seeked to the proper position
69
- // before reading.
70
- XDRInputFileStream& getEvictionStream ();
71
-
72
- // Loads the bucket entry for LedgerKey k. Starts at file offset pos and
73
- // reads until key is found or the end of the page.
74
- std::optional<BucketEntry>
75
- getEntryAtOffset (LedgerKey const & k, std::streamoff pos, size_t pageSize);
76
-
77
- std::unique_ptr<XDRInputFileStream> openStream ();
78
-
79
55
static std::string randomFileName (std::string const & tmpDir,
80
56
std::string ext);
81
57
@@ -109,18 +85,6 @@ class Bucket : public std::enable_shared_from_this<Bucket>,
109
85
// Sets index, throws if index is already set
110
86
void setIndex (std::unique_ptr<BucketIndex const >&& index);
111
87
112
- // Loads bucket entry for LedgerKey k.
113
- std::optional<BucketEntry> getBucketEntry (LedgerKey const & k);
114
-
115
- // Loads LedgerEntry's for given keys. When a key is found, the
116
- // entry is added to result and the key is removed from keys.
117
- void loadKeys (std::set<LedgerKey, LedgerEntryIdCmp>& keys,
118
- std::vector<LedgerEntry>& result);
119
-
120
- // Return all PoolIDs that contain the given asset on either side of the
121
- // pool
122
- std::vector<PoolID> const & getPoolIDsByAsset (Asset const & asset) const ;
123
-
124
88
// At version 11, we added support for INITENTRY and METAENTRY. Before this
125
89
// we were only supporting LIVEENTRY and DEADENTRY.
126
90
static constexpr ProtocolVersion
@@ -141,19 +105,6 @@ class Bucket : public std::enable_shared_from_this<Bucket>,
141
105
static std::string randomBucketName (std::string const & tmpDir);
142
106
static std::string randomBucketIndexName (std::string const & tmpDir);
143
107
144
- // Returns false if eof reached or if Bucket protocol version < 20, true
145
- // otherwise. Modifies iter as the bucket is scanned. Also modifies
146
- // bytesToScan and remainingEntriesToEvict such that after this function
147
- // returns:
148
- // bytesToScan -= amount_bytes_scanned
149
- // remainingEntriesToEvict -= entries_evicted
150
- bool scanForEviction (AbstractLedgerTxn& ltx, EvictionIterator& iter,
151
- uint32_t & bytesToScan,
152
- uint32_t & remainingEntriesToEvict, uint32_t ledgerSeq,
153
- medida::Counter& entriesEvictedCounter,
154
- medida::Counter& bytesScannedForEvictionCounter,
155
- std::optional<EvictionMetrics>& metrics);
156
-
157
108
#ifdef BUILD_TESTS
158
109
// "Applies" the bucket to the database. For each entry in the bucket,
159
110
// if the entry is init or live, creates or updates the corresponding
@@ -169,6 +120,18 @@ class Bucket : public std::enable_shared_from_this<Bucket>,
169
120
170
121
#endif // BUILD_TESTS
171
122
123
+ // Returns false if eof reached, true otherwise. Modifies iter as the bucket
124
+ // is scanned. Also modifies bytesToScan and maxEntriesToEvict such that
125
+ // after this function returns:
126
+ // bytesToScan -= amount_bytes_scanned
127
+ // maxEntriesToEvict -= entries_evicted
128
+ bool scanForEvictionLegacySQL (
129
+ AbstractLedgerTxn& ltx, EvictionIterator& iter, uint32_t & bytesToScan,
130
+ uint32_t & remainingEntriesToEvict, uint32_t ledgerSeq,
131
+ medida::Counter& entriesEvictedCounter,
132
+ medida::Counter& bytesScannedForEvictionCounter,
133
+ std::optional<EvictionStatistics>& stats) const ;
134
+
172
135
// Create a fresh bucket from given vectors of init (created) and live
173
136
// (updated) LedgerEntries, and dead LedgerEntryKeys. The bucket will
174
137
// be sorted, hashed, and adopted in the provided BucketManager.
@@ -201,5 +164,7 @@ class Bucket : public std::enable_shared_from_this<Bucket>,
201
164
static uint32_t getBucketVersion (std::shared_ptr<Bucket> const & bucket);
202
165
static uint32_t
203
166
getBucketVersion (std::shared_ptr<Bucket const > const & bucket);
167
+
168
+ friend class BucketSnapshot ;
204
169
};
205
170
}
0 commit comments