Skip to content

Question: problem reading and writing to index. #640

Description

@rzorzorzo

hello,

i am trying to read and write the index and the vectors from/to file.
here my code:

`
public static void write() throws Exception {
OnHeapGraphIndex index = (OnHeapGraphIndex) builder.getGraph();
var featureId = FeatureId.INLINE_VECTORS;
var inlineVectors = new InlineVectors(dimension);

	IntFunction<Feature.State> vectorSupplier = ordinal -> {
		VectorFloat<?> vector = vectorValues.getVector(ordinal);
		return new InlineVectors.State(vector);
	};

	try (var writer = new OnDiskGraphIndexWriter.Builder(index, indexPath).with(inlineVectors) 
			.build()) {
		Map<FeatureId, IntFunction<Feature.State>> suppliers = Map.of(featureId, vectorSupplier);
		writer.write(suppliers);
	}
}

public static void readIndex() throws Exception {
	if (!indexPath.toFile().exists())
		return;
	try (ReaderSupplier readerSupplier = ReaderSupplierFactory.open(indexPath)) {
		OnDiskGraphIndex oldIndex = OnDiskGraphIndex.load(readerSupplier);
		Map<FeatureId, ? extends Feature> features = oldIndex.getFeatures();
		InlineVectors ivFeature  = (InlineVectors) oldIndex.getFeatures().get(FeatureId.INLINE_VECTORS);
		//?? 
		builder = new GraphIndexBuilder(scoreProvider, dimension, 16, 100, 1.2f, 1.2f, true);
	}
}

`
Question: how to reconstruct MapRandomAccessVectorValues from InlineVectors ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions