Skip to content

Commit

Permalink
v1.7.3 fix bug in createIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
masajiro committed May 10, 2019
1 parent 8d33837 commit 9bf9f5d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.2
1.7.3
4 changes: 2 additions & 2 deletions lib/NGT/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,11 @@ namespace NGT {
};

namespace Serializer {
inline void read(istream &is, uint8_t *v, size_t s) {
static inline void read(istream &is, uint8_t *v, size_t s) {
is.read((char*)v, s);
}

inline void write(ostream &os, const uint8_t *v, size_t s) {
static inline void write(ostream &os, const uint8_t *v, size_t s) {
os.write((const char*)v, s);
}

Expand Down
10 changes: 4 additions & 6 deletions lib/NGT/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,13 @@ NeighborhoodGraph::setupSeeds(NGT::SearchContainer &sc, ObjectDistances &seeds,
#endif
#endif
neighborendptr = neighborptr;
if (edgeSize == 0) {
neighborendptr += neighbors->size();
} else {
neighborendptr += (neighbors->size() < edgeSize ? neighbors->size() : edgeSize);
}
size_t neighborSize = neighbors->size() < edgeSize ? neighbors->size() : edgeSize;
neighborendptr += neighborSize;
#ifdef NGT_GRAPH_BETTER_FIRST_RESTORE
neighborendptr -= position;
#endif
for (size_t i = 0; i < prefetchOffset; i++) {
size_t prefetchSize = prefetchOffset < neighborSize ? prefetchOffset : neighborSize;
for (size_t i = 0; i < prefetchSize; i++) {
if (!distanceChecked[(*(neighborptr + i)).id]) {
unsigned char *ptr = reinterpret_cast<unsigned char*>(objectRepository.get((*(neighborptr + i)).id));
MemoryCache::prefetch(ptr, byteSizeOfObject);
Expand Down
17 changes: 11 additions & 6 deletions lib/NGT/Index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,21 @@ CreateIndexThread::run() {
} catch(NGT::ThreadTerminationException &err) {
break;
} catch(NGT::Exception &err) {
cerr << "CreateIndex::search:popFront " << err.what() << endl;
cerr << "CreateIndex::search:Error! popFront " << err.what() << endl;
break;
}
ObjectDistances *rs = new ObjectDistances;
Object &obj = *job.object;
if (graphIndex.NeighborhoodGraph::property.graphType == NeighborhoodGraph::GraphTypeKNNG) {
graphIndex.searchForKNNGInsertion(obj, job.id, *rs); // linear search
} else {
graphIndex.searchForNNGInsertion(obj, *rs);
}
try {
if (graphIndex.NeighborhoodGraph::property.graphType == NeighborhoodGraph::GraphTypeKNNG) {
graphIndex.searchForKNNGInsertion(obj, job.id, *rs); // linear search
} else {
graphIndex.searchForNNGInsertion(obj, *rs);
}
} catch(NGT::Exception &err) {
cerr << "CreateIndex::search:Fatal error! ID=" << job.id << " " << err.what() << endl;
abort();
}
job.results = rs;
poolThread.getOutputJobQueue().pushBack(job);
}
Expand Down

0 comments on commit 9bf9f5d

Please sign in to comment.