Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Object execute(final Object self, final Identifiable currentRecord, final

final int limit = params[2] instanceof Number n ? n.intValue() : Integer.parseInt(params[2].toString());

final List<Pair<Vertex, ? extends Number>> neighbors = vIndex.findNeighborsFromVector(key, limit, null);
final List<Pair<Vertex, ? extends Number>> neighbors = vIndex.findNeighborsFromId(key, limit, null);

final ArrayList<Object> result = new ArrayList<>(neighbors.size());
for (Pair<Vertex, ? extends Number> n : neighbors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ public TextEmbeddingsImporter setContext(final ImporterContext context) {

private List<TextFloatsEmbedding> loadFromFile() throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
final Stream<String> parser = reader.lines();
Stream<String> parser = reader.lines();

if (settings.parsingLimitEntries > 0)
parser.limit(settings.parsingLimitEntries);
parser = parser.limit(settings.parsingLimitEntries);

final AtomicInteger vectorSize = new AtomicInteger(301);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.arcadedb.integration.importer;

import com.arcadedb.database.Database;
import com.arcadedb.database.DatabaseFactory;
import com.arcadedb.graph.Vertex;
import com.arcadedb.integration.TestHelper;
import com.arcadedb.query.sql.executor.Result;
import com.arcadedb.query.sql.executor.ResultSet;
import com.arcadedb.utility.FileUtils;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;

import static org.assertj.core.api.Assertions.assertThat;

public class FastTextVectorImportTest extends com.arcadedb.TestHelper
{
@Test
public void vectorNeighborsQuery() {
database.command("sql", "import database file://src/test/resources/cc.en.300.small.vec.gz " //
+ "with distanceFunction = cosine, m = 16, ef = 128, efConstruction = 128, " //
+ "vertexType = Word, edgeType = Proximity, vectorProperty = vector, idProperty = name" //
);
assertThat(database.countType("Word", true)).isEqualTo(1000);

final ResultSet rs = database.command("SQL",
"select expand(vectorNeighbors('Word[name,vector]','with',10))");

final AtomicInteger total = new AtomicInteger();
while (rs.hasNext()) {
final Result record = rs.next();
assertThat(record).isNotNull();
Vertex vertex = (Vertex) record.getElementProperty("vertex");
Float distance = record.getProperty("distance");
total.incrementAndGet();
}

assertThat(total.get()).isEqualTo(10);
}

@Test
public void parsingLimitEntries() {
database.command("sql", "import database file://src/test/resources/cc.en.300.small.vec.gz " //
+ "with distanceFunction = cosine, m = 16, ef = 128, efConstruction = 128, " //
+ "vertexType = Word, edgeType = Proximity, vectorProperty = vector, idProperty = name, "
+ "parsingLimitEntries = 101"
);

// The header is skipped, so we expect 100 entries
assertThat(database.countType("Word", true)).isEqualTo(100);
}

@Override
protected String getDatabasePath() {
return "target/databases/test-fasttextsmall";
}
}
Binary file not shown.
Loading