io.pinecone.utils.SparseIndicesConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pinecone-client Show documentation
Show all versions of pinecone-client Show documentation
The Pinecone.io Java Client
package io.pinecone.utils;
import io.pinecone.exceptions.PineconeValidationException;
import java.util.ArrayList;
import java.util.List;
public class SparseIndicesConverter {
public static List convertUnsigned32IntToSigned32Int(List unsigned32IntValues) {
List int32Values = new ArrayList<>();
for (Long value : unsigned32IntValues) {
if (value < 0 || value > 0xFFFFFFFFL) {
throw new PineconeValidationException("Sparse indices are out of range for unsigned 32-bit integers.");
}
int32Values.add(value.intValue());
}
return int32Values;
}
public static List convertSigned32IntToUnsigned32Int(List signed32IntValues) {
List uint32Values = new ArrayList<>();
for (Integer value : signed32IntValues) {
if (value < 0) {
uint32Values.add((long) value + 4294967296L);
} else {
uint32Values.add((long) value);
}
}
return uint32Values;
}
}