|
|
@ -12,6 +12,8 @@ namespace HNSWDemo.Tests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private const int count = 20000;
|
|
|
|
private const int count = 20000;
|
|
|
|
private const int dimensionality = 128;
|
|
|
|
private const int dimensionality = 128;
|
|
|
|
|
|
|
|
private const string _graphFileCachee = @"lal_test_graph.bin";
|
|
|
|
|
|
|
|
private const string _mapFileCachee = @"lal_test_map.bin";
|
|
|
|
|
|
|
|
|
|
|
|
public void Run()
|
|
|
|
public void Run()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -27,9 +29,19 @@ namespace HNSWDemo.Tests
|
|
|
|
samples[c].Add(p);
|
|
|
|
samples[c].Add(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SplittedLALGraph worlds;
|
|
|
|
|
|
|
|
HNSWMappers<long> mappers;
|
|
|
|
|
|
|
|
|
|
|
|
var worlds = new SplittedLALGraph();
|
|
|
|
if (File.Exists(_graphFileCachee) && File.Exists(_mapFileCachee))
|
|
|
|
var mappers = new HNSWMappers<long>(l => (int)Math.Abs(l.GetHashCode() % moda));
|
|
|
|
{
|
|
|
|
|
|
|
|
worlds = new SplittedLALGraph(_graphFileCachee);
|
|
|
|
|
|
|
|
mappers = new HNSWMappers<long>(_mapFileCachee, l => (int)Math.Abs(l.GetHashCode() % moda));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
worlds = new SplittedLALGraph();
|
|
|
|
|
|
|
|
mappers = new HNSWMappers<long>(l => (int)Math.Abs(l.GetHashCode() % moda));
|
|
|
|
|
|
|
|
|
|
|
|
var worlds_dict = new Dictionary<int, SmallWorld<float[]>>();
|
|
|
|
var worlds_dict = new Dictionary<int, SmallWorld<float[]>>();
|
|
|
|
var maps_dict = new Dictionary<int, HNSWMap<long>>();
|
|
|
|
var maps_dict = new Dictionary<int, HNSWMap<long>>();
|
|
|
@ -75,12 +87,15 @@ namespace HNSWDemo.Tests
|
|
|
|
mappers.Append(m, c);
|
|
|
|
mappers.Append(m, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
worlds.Save(_graphFileCachee);
|
|
|
|
|
|
|
|
mappers.Save(_mapFileCachee);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var entries = new long[10];
|
|
|
|
var entries = new long[10];
|
|
|
|
for (int i = 0; i < entries.Length; i++)
|
|
|
|
for (int i = 0; i < entries.Length; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
entries[i] = persons[DefaultRandomGenerator.Instance.Next(0, persons.Count - 1)].Item2.Number;
|
|
|
|
entries[i] = persons[DefaultRandomGenerator.Instance.Next(0, persons.Count - 1)].Item2.Number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var contexts = mappers.CreateContext(null, entries);
|
|
|
|
var contexts = mappers.CreateContext(null, entries);
|
|
|
|
var result = worlds.KNearest(5000, contexts);
|
|
|
|
var result = worlds.KNearest(5000, contexts);
|
|
|
|
|
|
|
|
|
|
|
|