aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/apps
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-11-22 11:14:42 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2016-11-22 20:37:26 +0000
commita6acf5fede56f4d2535b3c30bcc5824bf805c143 (patch)
tree741ded2e08f2b1e8b47e7f3fd8708aa335396882 /searchlib/src/apps
parentb6f6af8b316da8f588c5e81c6d912ace086ba0b8 (diff)
Split up to avoid internal compiler error on gcc 6.2i with -Os
Diffstat (limited to 'searchlib/src/apps')
-rw-r--r--searchlib/src/apps/docstore/create-idx-from-dat.cpp63
1 files changed, 36 insertions, 27 deletions
diff --git a/searchlib/src/apps/docstore/create-idx-from-dat.cpp b/searchlib/src/apps/docstore/create-idx-from-dat.cpp
index 66661b6468d..8b02a9bad30 100644
--- a/searchlib/src/apps/docstore/create-idx-from-dat.cpp
+++ b/searchlib/src/apps/docstore/create-idx-from-dat.cpp
@@ -15,8 +15,6 @@ class CreateIdxFileFromDatApp : public FastOS_Application
int Main(void);
};
-
-
void
CreateIdxFileFromDatApp::usage(void)
{
@@ -24,6 +22,7 @@ CreateIdxFileFromDatApp::usage(void)
fflush(stdout);
}
+namespace {
bool tryDecode(size_t chunks, size_t offset, const char * p, size_t sz, size_t nextSync)
{
bool success(false);
@@ -51,6 +50,37 @@ bool validHead(const char * n, size_t offset) {
return (n[0] == 0) && (validUncompressed(n, offset));
}
+size_t
+generate(size_t serialNum, size_t chunks, FastOS_FileInterface & idxFile, size_t sz, const char * current, const char * start, const char * nextStart) __attribute__((noinline));
+size_t
+generate(size_t serialNum, size_t chunks, FastOS_FileInterface & idxFile, size_t sz, const char * current, const char * start, const char * nextStart)
+{
+ vespalib::nbostream os;
+ for (size_t lengthError(0); int64_t(sz+lengthError) <= nextStart-start; lengthError++) {
+ try {
+ Chunk chunk(chunks, current, sz + lengthError, false);
+ fprintf(stdout, "id=%d lastSerial=%ld count=%ld\n", chunk.getId(), chunk.getLastSerial(), chunk.count());
+ const Chunk::LidList & lidlist = chunk.getLids();
+ if (chunk.getLastSerial() < serialNum) {
+ fprintf(stdout, "Serial num grows down prev=%ld, current=%ld\n", serialNum, chunk.getLastSerial());
+ }
+ serialNum = std::max(serialNum, chunk.getLastSerial());
+ ChunkMeta cmeta(current-start, sz + lengthError, serialNum, chunk.count());
+ cmeta.serialize(os);
+ for (auto it(lidlist.begin()); it != lidlist.end(); it++) {
+ LidMeta lm(it->getLid(), it->netSize());
+ lm.serialize(os);
+ }
+ break;
+ } catch (const vespalib::Exception & e) {
+ fprintf(stdout, "Failed with lengthError %ld due to '%s'\n", lengthError, e.what());
+ }
+ }
+ idxFile.Write2(os.c_str(), os.size());
+ return serialNum;
+}
+
+}
int CreateIdxFileFromDatApp::createIdxFile(const vespalib::string & datFileName, const vespalib::string & idxFileName)
{
MMapRandRead datFile(datFileName, 0, 0);
@@ -94,35 +124,14 @@ int CreateIdxFileFromDatApp::createIdxFile(const vespalib::string & datFileName,
}
uint64_t sz = tail - current;
fprintf(stdout, "Most likely found chunk at offset %ld with length %ld\n", current - start, sz);
- vespalib::nbostream os;
- for (size_t lengthError(0); int64_t(sz+lengthError) <= nextStart-start; lengthError++) {
- try {
- Chunk chunk(chunks, current, sz + lengthError, false);
- fprintf(stdout, "id=%d lastSerial=%ld count=%ld\n", chunk.getId(), chunk.getLastSerial(), chunk.count());
- const Chunk::LidList & lidlist = chunk.getLids();
- if (chunk.getLastSerial() < serialNum) {
- fprintf(stdout, "Serial num grows down prev=%ld, current=%ld\n", serialNum, chunk.getLastSerial());
- }
- serialNum = std::max(serialNum, chunk.getLastSerial());
- ChunkMeta cmeta(current-start, sz + lengthError, serialNum, chunk.count());
- cmeta.serialize(os);
- for (auto it(lidlist.begin()); it != lidlist.end(); it++) {
- LidMeta lm(it->getLid(), it->netSize());
- lm.serialize(os);
- }
- break;
- } catch (const vespalib::Exception & e) {
- fprintf(stdout, "Failed with lengthError %ld due to '%s'\n", lengthError, e.what());
- }
- }
- idxFile.Write2(os.c_str(), os.size());
+ serialNum = generate(serialNum, chunks,idxFile, sz, current, start, nextStart);
chunks++;
for(current += alignment; current < tail; current += alignment);
} else {
current += alignment;
}
- //fprintf(stdout, "Next is most likely at offset %ld tail(%p)\n", current - start, tail);
-/*
+#if 0
+ fprintf(stdout, "Next is most likely at offset %ld tail(%p)\n", current - start, tail);
ChunkMeta cm;
cm.deserialize(is);
fprintf(stdout, "Chunk(%ld) : LastSerial(%ld), Entries(%d), Offset(%ld), Size(%d)\n",
@@ -132,7 +141,7 @@ int CreateIdxFileFromDatApp::createIdxFile(const vespalib::string & datFileName,
lm.deserialize(is);
fprintf(stdout, "Entry(%ld.%ld) : Lid(%d), Size(%d)\n", chunk, i, lm.getLid(), lm.size());
}
-*/
+#endif
}
fprintf(stdout, "Processed %ld chunks with total entries = %ld\n", chunks, entries);
return 0;