Skip to content

Commit f43dcf3

Browse files
fdmetameta-codesync[bot]
authored andcommitted
Remove unused functions in GenericPieces
Summary: Remove these functions as they are not called outside tests. It'll make the migration to MultiRangeCachePieces cleaner. Differential Revision: D90874867 fbshipit-source-id: c25d33ba912cac8272dc9cea9346a1207c00aae7
1 parent 1acf143 commit f43dcf3

2 files changed

Lines changed: 0 additions & 56 deletions

File tree

cachelib/common/piecewise/GenericPieces.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -99,39 +99,7 @@ class GenericPieces : public GenericPiecesBase {
9999
1;
100100
}
101101

102-
uint64_t getRequestedSizeOfAPiece(uint64_t pieceIndex) const {
103-
if (startPieceIndex_ == endPieceIndex_) {
104-
XDCHECK_EQ(pieceIndex, startPieceIndex_);
105-
return requestedEndByte_ - requestedStartByte_ + 1;
106-
}
107-
108-
if (pieceIndex == startPieceIndex_) {
109-
// For the first piece, trim bytes before requestedStartByte_
110-
return pieceSize_ - requestedStartByte_ % pieceSize_;
111-
} else if (pieceIndex == endPieceIndex_) {
112-
// For the last piece, trim bytes after requestedEndByte_
113-
return requestedEndByte_ % pieceSize_ + 1;
114-
} else {
115-
return pieceSize_;
116-
}
117-
}
118-
119-
uint64_t getBytesToTrimAtStart() const {
120-
return requestedStartByte_ - startPieceIndex_ * pieceSize_;
121-
}
122-
123-
uint64_t getBytesToTrimAtEnd() const {
124-
return getLastByteOffsetOfLastPiece() - requestedEndByte_;
125-
}
126-
127-
uint64_t getRequestedSize() const {
128-
return (requestedEndByte_ - requestedStartByte_ + 1);
129-
}
130-
131102
uint64_t getStartPieceIndex() const { return startPieceIndex_; }
132-
[[nodiscard]] uint64_t getStartPieceOffset() const {
133-
return startPieceIndex_ * pieceSize_;
134-
}
135103
uint64_t getEndPieceIndex() const { return endPieceIndex_; }
136104
uint64_t getRequestedStartByte() const { return requestedStartByte_; }
137105
uint64_t getRequestedEndByte() const { return requestedEndByte_; }

cachelib/common/piecewise/GenericPiecesTest.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,8 @@ TEST(GenericPiecesTests, Normal) {
3333
EXPECT_EQ(0, cp.getCurFetchingPieceIndex());
3434
EXPECT_EQ(999, cp.getLastByteOffsetOfLastPiece());
3535
EXPECT_EQ(256, cp.getSizeOfAPiece(0));
36-
EXPECT_EQ(256, cp.getRequestedSizeOfAPiece(0));
3736
EXPECT_EQ(232, cp.getSizeOfAPiece(3));
38-
EXPECT_EQ(232, cp.getRequestedSizeOfAPiece(3));
3937
EXPECT_EQ(1000, cp.getTotalSize());
40-
EXPECT_EQ(0, cp.getBytesToTrimAtStart());
41-
EXPECT_EQ(0, cp.getBytesToTrimAtEnd());
42-
EXPECT_EQ(1000, cp.getRequestedSize());
4338
EXPECT_EQ(1000, cp.getRemainingBytes());
4439
cp.updateFetchIndex();
4540
EXPECT_EQ(744, cp.getRemainingBytes());
@@ -56,14 +51,9 @@ TEST(GenericPiecesTests, Normal) {
5651
EXPECT_EQ(1, cp.getCurFetchingPieceIndex());
5752
EXPECT_EQ(767, cp.getLastByteOffsetOfLastPiece());
5853
EXPECT_EQ(256, cp.getSizeOfAPiece(1));
59-
EXPECT_EQ(252, cp.getRequestedSizeOfAPiece(1));
6054
EXPECT_EQ(256, cp.getSizeOfAPiece(2));
61-
EXPECT_EQ(248, cp.getRequestedSizeOfAPiece(2));
6255
EXPECT_EQ(512, cp.getTotalSize());
63-
EXPECT_EQ(500, cp.getRequestedSize());
6456
EXPECT_EQ(512, cp.getRemainingBytes());
65-
EXPECT_EQ(4, cp.getBytesToTrimAtStart());
66-
EXPECT_EQ(8, cp.getBytesToTrimAtEnd());
6757
cp.updateFetchIndex();
6858
EXPECT_EQ(256, cp.getRemainingBytes());
6959

@@ -78,12 +68,8 @@ TEST(GenericPiecesTests, Normal) {
7868
EXPECT_EQ(3, cp.getCurFetchingPieceIndex());
7969
EXPECT_EQ(999, cp.getLastByteOffsetOfLastPiece());
8070
EXPECT_EQ(232, cp.getSizeOfAPiece(3));
81-
EXPECT_EQ(196, cp.getRequestedSizeOfAPiece(3));
8271
EXPECT_EQ(232, cp.getTotalSize());
83-
EXPECT_EQ(196, cp.getRequestedSize());
8472
EXPECT_EQ(232, cp.getRemainingBytes());
85-
EXPECT_EQ(32, cp.getBytesToTrimAtStart());
86-
EXPECT_EQ(4, cp.getBytesToTrimAtEnd());
8773
cp.updateFetchIndex();
8874
EXPECT_EQ(0, cp.getRemainingBytes());
8975

@@ -98,14 +84,9 @@ TEST(GenericPiecesTests, Normal) {
9884
EXPECT_EQ(1, cp.getCurFetchingPieceIndex());
9985
EXPECT_EQ(999, cp.getLastByteOffsetOfLastPiece());
10086
EXPECT_EQ(256, cp.getSizeOfAPiece(1));
101-
EXPECT_EQ(112, cp.getRequestedSizeOfAPiece(1));
10287
EXPECT_EQ(232, cp.getSizeOfAPiece(3));
103-
EXPECT_EQ(232, cp.getRequestedSizeOfAPiece(3));
10488
EXPECT_EQ(744, cp.getTotalSize());
105-
EXPECT_EQ(600, cp.getRequestedSize());
10689
EXPECT_EQ(744, cp.getRemainingBytes());
107-
EXPECT_EQ(144, cp.getBytesToTrimAtStart());
108-
EXPECT_EQ(0, cp.getBytesToTrimAtEnd());
10990
cp.updateFetchIndex();
11091
EXPECT_EQ(488, cp.getRemainingBytes());
11192

@@ -120,14 +101,9 @@ TEST(GenericPiecesTests, Normal) {
120101
EXPECT_EQ(1, cp.getCurFetchingPieceIndex());
121102
EXPECT_EQ(999, cp.getLastByteOffsetOfLastPiece());
122103
EXPECT_EQ(256, cp.getSizeOfAPiece(1));
123-
EXPECT_EQ(112, cp.getRequestedSizeOfAPiece(1));
124104
EXPECT_EQ(232, cp.getSizeOfAPiece(3));
125-
EXPECT_EQ(232, cp.getRequestedSizeOfAPiece(3));
126105
EXPECT_EQ(744, cp.getTotalSize());
127-
EXPECT_EQ(600, cp.getRequestedSize());
128106
EXPECT_EQ(744, cp.getRemainingBytes());
129-
EXPECT_EQ(144, cp.getBytesToTrimAtStart());
130-
EXPECT_EQ(0, cp.getBytesToTrimAtEnd());
131107
cp.updateFetchIndex();
132108
EXPECT_EQ(488, cp.getRemainingBytes());
133109
}

0 commit comments

Comments
 (0)