Removed the 10000 files static commmit-time limit from tagcache.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10278 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b50e8935e1
commit
a47bd73f3e
2 changed files with 19 additions and 10 deletions
|
@ -141,7 +141,9 @@ struct tempbuf_searchidx {
|
||||||
struct tempbuf_id_list idlist;
|
struct tempbuf_id_list idlist;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LOOKUP_BUF_DEPTH (TAGFILE_MAX_ENTRIES*2 \
|
static long commit_entry_count;
|
||||||
|
|
||||||
|
#define LOOKUP_BUF_DEPTH (commit_entry_count*2 \
|
||||||
* (TAGFILE_ENTRY_AVG_LENGTH/TAGFILE_ENTRY_CHUNK_LENGTH))
|
* (TAGFILE_ENTRY_AVG_LENGTH/TAGFILE_ENTRY_CHUNK_LENGTH))
|
||||||
|
|
||||||
struct tempbuf_searchidx **lookup;
|
struct tempbuf_searchidx **lookup;
|
||||||
|
@ -1276,7 +1278,7 @@ static bool tempbuf_insert(char *str, int id, int idx_id, bool unique)
|
||||||
|
|
||||||
/* Insert it to the buffer. */
|
/* Insert it to the buffer. */
|
||||||
tempbuf_left -= len;
|
tempbuf_left -= len;
|
||||||
if (tempbuf_left - 4 < 0 || tempbufidx >= TAGFILE_MAX_ENTRIES-1)
|
if (tempbuf_left - 4 < 0 || tempbufidx >= commit_entry_count-1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (id >= 0 && id < LOOKUP_BUF_DEPTH)
|
if (id >= 0 && id < LOOKUP_BUF_DEPTH)
|
||||||
|
@ -1536,18 +1538,28 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
||||||
|
|
||||||
logf("Building index: %d", index_type);
|
logf("Building index: %d", index_type);
|
||||||
|
|
||||||
|
/* Check the number of entries we need to allocate ram for. */
|
||||||
|
commit_entry_count = h->entry_count + 1;
|
||||||
|
|
||||||
|
masterfd = open_master_fd(&tcmh, false);
|
||||||
|
if (masterfd >= 0)
|
||||||
|
{
|
||||||
|
commit_entry_count += tcmh.tch.entry_count;
|
||||||
|
close(masterfd);
|
||||||
|
}
|
||||||
|
|
||||||
tempbufidx = 0;
|
tempbufidx = 0;
|
||||||
tempbuf_pos = TAGFILE_MAX_ENTRIES * sizeof(struct tempbuf_searchidx);
|
tempbuf_pos = commit_entry_count * sizeof(struct tempbuf_searchidx);
|
||||||
tempbuf_pos += LOOKUP_BUF_DEPTH * sizeof(void **);
|
tempbuf_pos += LOOKUP_BUF_DEPTH * sizeof(void **);
|
||||||
tempbuf_left = tempbuf_size - tempbuf_pos - 8;
|
tempbuf_left = tempbuf_size - tempbuf_pos - 8;
|
||||||
if (tempbuf_left - TAGFILE_ENTRY_AVG_LENGTH * TAGFILE_MAX_ENTRIES < 0)
|
if (tempbuf_left - TAGFILE_ENTRY_AVG_LENGTH * commit_entry_count < 0)
|
||||||
{
|
{
|
||||||
logf("Buffer way too small!");
|
logf("Buffer way too small!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lookup = (struct tempbuf_searchidx **)
|
lookup = (struct tempbuf_searchidx **)
|
||||||
(tempbuf + sizeof(struct tempbuf_searchidx)*TAGFILE_MAX_ENTRIES);
|
(tempbuf + sizeof(struct tempbuf_searchidx)*commit_entry_count);
|
||||||
memset(lookup, 0, LOOKUP_BUF_DEPTH * sizeof(void **));
|
memset(lookup, 0, LOOKUP_BUF_DEPTH * sizeof(void **));
|
||||||
|
|
||||||
/* Open the index file, which contains the tag names. */
|
/* Open the index file, which contains the tag names. */
|
||||||
|
@ -1610,7 +1622,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
||||||
* table when the index gets resorted.
|
* table when the index gets resorted.
|
||||||
*/
|
*/
|
||||||
tempbuf_insert(buf, loc/TAGFILE_ENTRY_CHUNK_LENGTH
|
tempbuf_insert(buf, loc/TAGFILE_ENTRY_CHUNK_LENGTH
|
||||||
+ TAGFILE_MAX_ENTRIES, entry.idx_id,
|
+ commit_entry_count, entry.idx_id,
|
||||||
tagcache_is_unique_tag(index_type));
|
tagcache_is_unique_tag(index_type));
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
@ -1804,7 +1816,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
||||||
|
|
||||||
idxbuf[j].tag_seek[index_type] = tempbuf_find_location(
|
idxbuf[j].tag_seek[index_type] = tempbuf_find_location(
|
||||||
idxbuf[j].tag_seek[index_type]/TAGFILE_ENTRY_CHUNK_LENGTH
|
idxbuf[j].tag_seek[index_type]/TAGFILE_ENTRY_CHUNK_LENGTH
|
||||||
+ TAGFILE_MAX_ENTRIES);
|
+ commit_entry_count);
|
||||||
|
|
||||||
if (idxbuf[j].tag_seek[index_type] < 0)
|
if (idxbuf[j].tag_seek[index_type] < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,9 +41,6 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
|
||||||
/* How much to allocate extra space for ramcache. */
|
/* How much to allocate extra space for ramcache. */
|
||||||
#define TAGCACHE_RESERVE 32768
|
#define TAGCACHE_RESERVE 32768
|
||||||
|
|
||||||
/* How many entries we can create in one tag file (for sorting). */
|
|
||||||
#define TAGFILE_MAX_ENTRIES 10000
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define how long one entry must be at least (longer -> less memory at commit).
|
* Define how long one entry must be at least (longer -> less memory at commit).
|
||||||
* Must be at least 4 bytes in length for correct alignment.
|
* Must be at least 4 bytes in length for correct alignment.
|
||||||
|
|
Loading…
Reference in a new issue