mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 21:47:37 +03:00
2010-07-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --min-split-size=SIZE option. aria2 does not split less than 2*SIZE byte range. For example, let's consider downloading 20MiB file. If SIZE is 10M, aria2 can split file into 2 range [0-10MiB) and [10MiB-20MiB) and download it using 2 sources(if --split >= 2, of course). If SIZE is 15M, since 2*15M > 20MiB, aria2 does not split file and download it using 1 source. * src/BitfieldMan.cc * src/BitfieldMan.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/OptionHandlerFactory.cc * src/RequestGroup.cc * src/prefs.cc * src/prefs.h * src/usage_text.h * test/BitfieldManTest.cc * test/SegmentManTest.cc
This commit is contained in:
parent
55748de726
commit
1ddaaf7614
12 changed files with 172 additions and 50 deletions
|
@ -24,6 +24,7 @@ class BitfieldManTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testAddNotFilter_overflow);
|
||||
CPPUNIT_TEST(testGetSparceMissingUnusedIndex);
|
||||
CPPUNIT_TEST(testGetSparceMissingUnusedIndex_setBit);
|
||||
CPPUNIT_TEST(testGetSparceMissingUnusedIndex_withMinSplitSize);
|
||||
CPPUNIT_TEST(testIsBitSetOffsetRange);
|
||||
CPPUNIT_TEST(testGetMissingUnusedLength);
|
||||
CPPUNIT_TEST(testSetBitRange);
|
||||
|
@ -53,6 +54,7 @@ public:
|
|||
void testAddNotFilter_overflow();
|
||||
void testGetSparceMissingUnusedIndex();
|
||||
void testGetSparceMissingUnusedIndex_setBit();
|
||||
void testGetSparceMissingUnusedIndex_withMinSplitSize();
|
||||
void testIsBitSetOffsetRange();
|
||||
void testGetMissingUnusedLength();
|
||||
void testSetBitRange();
|
||||
|
@ -280,48 +282,49 @@ void BitfieldManTest::testGetSparceMissingUnusedIndex() {
|
|||
const size_t length = 2;
|
||||
unsigned char ignoreBitfield[length];
|
||||
memset(ignoreBitfield, 0, sizeof(ignoreBitfield));
|
||||
size_t minSplitSize = 1024*1024;
|
||||
size_t index;
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, index);
|
||||
bitfield.setUseBit(0);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)5, index);
|
||||
bitfield.setUseBit(5);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, index);
|
||||
bitfield.setUseBit(3);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)8, index);
|
||||
bitfield.setUseBit(8);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, index);
|
||||
bitfield.setUseBit(2);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)7, index);
|
||||
bitfield.setUseBit(7);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, index);
|
||||
bitfield.setUseBit(1);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)4, index);
|
||||
bitfield.setUseBit(4);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)7, index);
|
||||
bitfield.setUseBit(7);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)6, index);
|
||||
bitfield.setUseBit(6);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)9, index);
|
||||
bitfield.setUseBit(9);
|
||||
CPPUNIT_ASSERT(!bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(!bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
}
|
||||
|
||||
|
@ -330,48 +333,82 @@ void BitfieldManTest::testGetSparceMissingUnusedIndex_setBit() {
|
|||
const size_t length = 2;
|
||||
unsigned char ignoreBitfield[length];
|
||||
memset(ignoreBitfield, 0, sizeof(ignoreBitfield));
|
||||
size_t minSplitSize = 1024*1024;
|
||||
size_t index;
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, index);
|
||||
bitfield.setBit(0);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, index);
|
||||
bitfield.setBit(1);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, index);
|
||||
bitfield.setBit(2);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, index);
|
||||
bitfield.setBit(3);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)4, index);
|
||||
bitfield.setBit(4);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)5, index);
|
||||
bitfield.setBit(5);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)6, index);
|
||||
bitfield.setBit(6);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)7, index);
|
||||
bitfield.setBit(7);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)8, index);
|
||||
bitfield.setBit(8);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)9, index);
|
||||
bitfield.setBit(9);
|
||||
CPPUNIT_ASSERT(!bitfield.getSparseMissingUnusedIndex(index,
|
||||
CPPUNIT_ASSERT(!bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
}
|
||||
|
||||
void BitfieldManTest::testGetSparceMissingUnusedIndex_withMinSplitSize()
|
||||
{
|
||||
BitfieldMan bitfield(1024*1024, 10*1024*1024);
|
||||
const size_t length = 2;
|
||||
unsigned char ignoreBitfield[length];
|
||||
memset(ignoreBitfield, 0, sizeof(ignoreBitfield));
|
||||
size_t minSplitSize = 2*1024*1024;
|
||||
size_t index;
|
||||
bitfield.setUseBit(1);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)6, index);
|
||||
bitfield.setBit(6);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)7, index);
|
||||
bitfield.setUseBit(7);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)4, index);
|
||||
bitfield.setBit(4);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, index);
|
||||
bitfield.setBit(0);
|
||||
CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)5, index);
|
||||
bitfield.setBit(5);
|
||||
CPPUNIT_ASSERT(!bitfield.getSparseMissingUnusedIndex(index, minSplitSize,
|
||||
ignoreBitfield, length));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue