-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #371 from gregfriedland/greg/bit_jaccard_pr
bit_jaccard space
- Loading branch information
Showing
15 changed files
with
463 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ similarity_search/test/Makefile | |
*.so | ||
*.pyc | ||
*.egg-info/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
similarity_search/include/factory/space/space_bit_jaccard.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Non-metric Space Library | ||
* | ||
* Main developers: Bilegsaikhan Naidan, Leonid Boytsov, Yury Malkov, Ben Frederickson, David Novak | ||
* | ||
* For the complete list of contributors and further details see: | ||
* https://github.com/searchivarius/NonMetricSpaceLib | ||
* | ||
* Copyright (c) 2013-2018 | ||
* | ||
* This code is released under the | ||
* Apache License Version 2.0 http://www.apache.org/licenses/. | ||
* | ||
*/ | ||
#ifndef FACTORY_SPACE_BIT_JACCARD_H | ||
#define FACTORY_SPACE_BIT_JACCARD_H | ||
|
||
#include <space/space_bit_jaccard.h> | ||
|
||
namespace similarity { | ||
|
||
/* | ||
* Creating functions. | ||
*/ | ||
|
||
template <typename dist_t, typename dist_uint_t> | ||
inline Space<dist_t>* CreateBitJaccard(const AnyParams& /* ignoring params */) { | ||
return new SpaceBitJaccard<dist_t,dist_uint_t>(); | ||
} | ||
|
||
/* | ||
* End of creating functions. | ||
*/ | ||
} | ||
|
||
#endif | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Non-metric Space Library | ||
* | ||
* Main developers: Bilegsaikhan Naidan, Leonid Boytsov, Yury Malkov, Ben Frederickson, David Novak | ||
* | ||
* For the complete list of contributors and further details see: | ||
* https://github.com/searchivarius/NonMetricSpaceLib | ||
* | ||
* Copyright (c) 2013-2018 | ||
* | ||
* This code is released under the | ||
* Apache License Version 2.0 http://www.apache.org/licenses/. | ||
* | ||
*/ | ||
#ifndef _SPACE_BIT_JACCARD_H_ | ||
#define _SPACE_BIT_JACCARD_H_ | ||
|
||
#include <string> | ||
#include <map> | ||
#include <stdexcept> | ||
|
||
#include <string.h> | ||
#include "global.h" | ||
#include "object.h" | ||
#include "utils.h" | ||
#include "space.h" | ||
#include "distcomp.h" | ||
#include "space_bit_vector.h" | ||
|
||
#define SPACE_BIT_JACCARD "bit_jaccard" | ||
|
||
namespace similarity { | ||
|
||
template <typename dist_t, typename dist_uint_t> | ||
class SpaceBitJaccard : public SpaceBitVector<dist_t,dist_uint_t> { | ||
public: | ||
explicit SpaceBitJaccard() {} | ||
virtual ~SpaceBitJaccard() {} | ||
|
||
virtual std::string StrDesc() const { return "Jaccard (bit-storage) space"; } | ||
|
||
protected: | ||
virtual dist_t HiddenDistance(const Object* obj1, const Object* obj2) const { | ||
CHECK(obj1->datalength() > 0); | ||
CHECK(obj1->datalength() == obj2->datalength()); | ||
const dist_uint_t* x = reinterpret_cast<const dist_uint_t*>(obj1->data()); | ||
const dist_uint_t* y = reinterpret_cast<const dist_uint_t*>(obj2->data()); | ||
const size_t length = obj1->datalength() / sizeof(dist_uint_t) | ||
- 1; // the last integer is an original number of elements | ||
|
||
return BitJaccard<dist_t,dist_uint_t>(x, y, length); | ||
} | ||
|
||
DISABLE_COPY_AND_ASSIGN(SpaceBitJaccard); | ||
}; | ||
|
||
} // namespace similarity | ||
|
||
#endif |
Oops, something went wrong.