Remove grpc

This commit is contained in:
Andrea Cavalli 2021-01-30 22:29:33 +01:00
parent f0f34d89a9
commit 12aa63d615
5 changed files with 10 additions and 603 deletions

83
pom.xml
View File

@ -12,17 +12,8 @@
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<grpc.version>1.29.0</grpc.version><!-- CURRENT_GRPC_VERSION -->
<protobuf.version>3.11.4</protobuf.version>
<protoc.version>3.11.4</protoc.version>
<netty.tcnative.version>2.0.30.Final</netty.tcnative.version>
</properties>
<repositories>
<repository>
<id>protoarch</id>
<name>protoarch</name>
<url>http://home.apache.org/~aajisaka/repository</url>
</repository>
<repository>
<id>mchv-release</id>
<name>MCHV Release Apache Maven Packages</name>
@ -70,65 +61,11 @@
<artifactId>snakeyaml</artifactId>
<version>1.24</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-alts</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
<version>${grpc.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>${netty.tcnative.version}</version>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>${protobuf.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
@ -228,26 +165,6 @@
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
<protoSourceRoot>${basedir}/src/main/proto</protoSourceRoot>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>

View File

@ -1,36 +1,5 @@
package it.cavallium.dbengine.database;
import org.jetbrains.annotations.Nullable;
public enum LLDictionaryResultType {
VOID, VALUE_CHANGED, PREVIOUS_VALUE;
public static LLDictionaryResultType valueOf(@Nullable it.cavallium.dbengine.proto.LLDictionaryResultType resultType) {
if (resultType == null || resultType == it.cavallium.dbengine.proto.LLDictionaryResultType.UNRECOGNIZED) {
return VOID;
}
switch (resultType) {
case PREVIOUS_VALUE:
return PREVIOUS_VALUE;
case VALUE_CHANGED:
return VALUE_CHANGED;
case VOID:
return VOID;
}
return VOID;
}
public it.cavallium.dbengine.proto.LLDictionaryResultType toProto() {
switch (this) {
case VALUE_CHANGED:
return it.cavallium.dbengine.proto.LLDictionaryResultType.VALUE_CHANGED;
case PREVIOUS_VALUE:
return it.cavallium.dbengine.proto.LLDictionaryResultType.PREVIOUS_VALUE;
case VOID:
return it.cavallium.dbengine.proto.LLDictionaryResultType.VOID;
}
return it.cavallium.dbengine.proto.LLDictionaryResultType.UNRECOGNIZED;
}
}

View File

@ -2,15 +2,10 @@ package it.cavallium.dbengine.database;
import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import com.google.protobuf.ByteString;
import it.cavallium.dbengine.lucene.RandomSortField;
import it.cavallium.dbengine.proto.LLKeyScore;
import it.cavallium.dbengine.proto.LLType;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FloatPoint;
@ -56,10 +51,14 @@ public class LLUtils {
public static ScoreMode toScoreMode(LLScoreMode scoreMode) {
switch (scoreMode) {
case COMPLETE: return ScoreMode.COMPLETE;
case TOP_SCORES: return ScoreMode.TOP_SCORES;
case COMPLETE_NO_SCORES: return ScoreMode.COMPLETE_NO_SCORES;
default: throw new IllegalStateException("Unexpected value: " + scoreMode);
case COMPLETE:
return ScoreMode.COMPLETE;
case TOP_SCORES:
return ScoreMode.TOP_SCORES;
case COMPLETE_NO_SCORES:
return ScoreMode.COMPLETE_NO_SCORES;
default:
throw new IllegalStateException("Unexpected value: " + scoreMode);
}
}
@ -113,100 +112,7 @@ public class LLUtils {
throw new UnsupportedOperationException("Unsupported field type");
}
public static Iterable<? extends it.cavallium.dbengine.proto.LLItem> toGrpc(LLItem[] items) {
var list = new ArrayList<it.cavallium.dbengine.proto.LLItem>(items.length);
for (LLItem item : items) {
list.add(LLUtils.toGrpc(item));
}
return list;
}
public static it.cavallium.dbengine.proto.LLItem toGrpc(LLItem item) {
var builder = it.cavallium.dbengine.proto.LLItem.newBuilder()
.setType(LLType.valueOf(item.getType().toString()))
.setName(item.getName())
.setData1(ByteString.copyFrom(item.getData()));
if (item.getData2() != null) {
builder.setData2(ByteString.copyFrom(item.getData2()));
}
return builder.build();
}
public static it.cavallium.dbengine.proto.LLDocument toGrpc(LLDocument doc) {
var builder = it.cavallium.dbengine.proto.LLDocument.newBuilder()
.addAllItems(toGrpc(doc.getItems()));
return builder.build();
}
public static Iterable<it.cavallium.dbengine.proto.LLDocument> toGrpc(
Iterable<LLDocument> document) {
LinkedList<it.cavallium.dbengine.proto.LLDocument> docs = new LinkedList<>();
document.forEach((doc) -> docs.add(toGrpc(doc)));
return docs;
}
public static Iterable<it.cavallium.dbengine.proto.LLTerm> toGrpcKey(Iterable<LLTerm> term) {
LinkedList<it.cavallium.dbengine.proto.LLTerm> terms = new LinkedList<>();
term.forEach((t) -> terms.add(toGrpc(t)));
return terms;
}
public static it.cavallium.dbengine.proto.LLTerm toGrpc(LLTerm term) {
return it.cavallium.dbengine.proto.LLTerm.newBuilder()
.setKey(term.getKey())
.setValue(term.getValue())
.build();
}
public static it.cavallium.dbengine.proto.LLSort toGrpc(LLSort sort) {
return it.cavallium.dbengine.proto.LLSort.newBuilder()
.setFieldName(sort.getFieldName())
.setType(it.cavallium.dbengine.proto.LLSortType.valueOf(sort.getType().toString()))
.setReverse(sort.isReverse())
.build();
}
public static it.cavallium.dbengine.database.LLKeyScore toKeyScore(LLKeyScore hit) {
return new it.cavallium.dbengine.database.LLKeyScore(hit.getKey(), hit.getScore());
}
public static LLDocument toLocal(List<it.cavallium.dbengine.proto.LLItem> documentItemsList) {
return new LLDocument(documentItemsList.stream().map(LLUtils::toLocal).toArray(LLItem[]::new));
}
public static LLDocument toLocal(it.cavallium.dbengine.proto.LLDocument document) {
return toLocal(document.getItemsList());
}
public static List<LLDocument> toLocalDocuments(
List<it.cavallium.dbengine.proto.LLDocument> documentItemsList) {
return documentItemsList.stream().map(LLUtils::toLocal).collect(Collectors.toList());
}
public static List<LLTerm> toLocalTerms(List<it.cavallium.dbengine.proto.LLTerm> termItemsList) {
return termItemsList.stream().map(LLUtils::toLocal).collect(Collectors.toList());
}
@SuppressWarnings("ConstantConditions")
private static LLItem toLocal(it.cavallium.dbengine.proto.LLItem item) {
var data2 = item.getData2() != null ? item.getData2().toByteArray() : null;
return new LLItem(it.cavallium.dbengine.database.LLType.valueOf(item.getType().toString()),
item.getName(), item.getData1().toByteArray(), data2);
}
public static LLTerm toLocal(it.cavallium.dbengine.proto.LLTerm key) {
return new LLTerm(key.getKey(), key.getValue());
}
public static LLSort toLocal(it.cavallium.dbengine.proto.LLSort sort) {
return new LLSort(sort.getFieldName(), LLSortType.valueOf(sort.getType().toString()),
sort.getReverse());
}
public static LLKeyScore toGrpc(it.cavallium.dbengine.database.LLKeyScore hit) {
return LLKeyScore.newBuilder()
.setKey(hit.getKey())
.setScore(hit.getScore())
.build();
}
}

View File

@ -78,12 +78,14 @@ public class CappedWriteBatch implements WriteBatchInterface, AutoCloseable {
flushIfNeeded(false);
}
@Deprecated
@Override
public void remove(byte[] key) throws RocksDBException {
writeBatch.remove(key);
flushIfNeeded(false);
}
@Deprecated
@Override
public void remove(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException {
writeBatch.remove(columnFamilyHandle, key);

View File

@ -1,387 +0,0 @@
syntax = "proto3";
option java_multiple_files = true;
option java_package = "it.cavallium.dbengine.proto";
option java_outer_classname = "CavalliumDBEngineProto";
option objc_class_prefix = "CDBE";
package cavallium.dbengine;
service CavalliumDBEngineService {
rpc ResetConnection (ResetConnectionRequest) returns (Empty) {}
rpc Ping (Empty) returns (Empty) {}
rpc DatabaseOpen (DatabaseOpenRequest) returns (HandleResult) {}
rpc DatabaseClose (DatabaseCloseRequest) returns (Empty) {}
rpc DatabaseSnapshotTake (DatabaseSnapshotTakeRequest) returns (DatabaseSnapshotTakeResult) {}
rpc DatabaseSnapshotRelease (DatabaseSnapshotReleaseRequest) returns (Empty) {}
rpc SingletonOpen (SingletonOpenRequest) returns (HandleResult) {}
rpc DictionaryOpen (DictionaryOpenRequest) returns (HandleResult) {}
rpc DictionaryMethodGet (DictionaryMethodGetRequest) returns (DictionaryMethodGetResponse) {}
rpc DictionaryMethodContains (DictionaryMethodContainsRequest) returns (DictionaryMethodContainsResponse) {}
rpc DictionaryMethodPut (DictionaryMethodPutRequest) returns (DictionaryMethodStandardResult) {}
rpc DictionaryMethodPutMulti (DictionaryMethodPutMultiRequest) returns (DictionaryMethodMultiStandardResult) {}
rpc DictionaryMethodRemove (DictionaryMethodRemoveRequest) returns (DictionaryMethodStandardResult) {}
rpc DictionaryMethodClear (DictionaryMethodClearRequest) returns (Empty) {}
rpc DictionaryMethodFastSize (DictionaryMethodSizeRequest) returns (DictionaryMethodSizeResponse) {}
rpc DictionaryMethodExactSize (DictionaryMethodSizeRequest) returns (DictionaryMethodSizeResponse) {}
rpc DictionaryMethodIsEmpty (DictionaryMethodIsEmptyRequest) returns (DictionaryMethodIsEmptyResponse) {}
rpc DictionaryMethodRemoveOne (DictionaryMethodRemoveOneRequest) returns (DictionaryMethodStandardEntityResponse) {}
rpc DictionaryMethodForEach (DictionaryMethodForEachRequest) returns (stream DictionaryMethodStandardEntityResponse) {}
rpc DictionaryMethodReplaceAll (DictionaryMethodReplaceAllRequest) returns (stream DictionaryMethodReplaceAllResponse) {}
rpc SingletonMethodGet (SingletonMethodGetRequest) returns (SingletonMethodGetResponse) {}
rpc SingletonMethodSet (SingletonMethodSetRequest) returns (Empty) {}
rpc LuceneIndexOpen (LuceneIndexOpenRequest) returns (HandleResult) {}
rpc LuceneIndexClose (LuceneIndexCloseRequest) returns (Empty) {}
rpc LuceneIndexSnapshotTake (LuceneIndexSnapshotTakeRequest) returns (LuceneIndexSnapshotTakeResult) {}
rpc LuceneIndexSnapshotRelease (LuceneIndexSnapshotReleaseRequest) returns (Empty) {}
rpc LuceneIndexMethodAddDocument (LuceneIndexMethodAddDocumentRequest) returns (Empty) {}
rpc LuceneIndexMethodAddDocumentMulti (LuceneIndexMethodAddDocumentMultiRequest) returns (Empty) {}
rpc LuceneIndexMethodDeleteDocument (LuceneIndexMethodDeleteDocumentRequest) returns (Empty) {}
rpc LuceneIndexMethodUpdateDocument (LuceneIndexMethodUpdateDocumentRequest) returns (Empty) {}
rpc LuceneIndexMethodUpdateDocumentMulti (LuceneIndexMethodUpdateDocumentMultiRequest) returns (Empty) {}
rpc LuceneIndexMethodDeleteAll (LuceneIndexMethodDeleteAllRequest) returns (Empty) {}
rpc LuceneIndexMethodSearch (LuceneIndexMethodSearchRequest) returns (LuceneIndexMethodSearchMultiResponse) {}
rpc LuceneIndexMethodMoreLikeThis (LuceneIndexMethodMoreLikeThisRequest) returns (LuceneIndexMethodSearchMultiResponse) {}
rpc LuceneIndexMethodSearchStream (LuceneIndexMethodSearchStreamRequest) returns (stream LuceneIndexMethodSearchStreamItem) {}
rpc LuceneIndexMethodCount (LuceneIndexMethodCountRequest) returns (LuceneIndexMethodCountResponse) {}
}
enum LLDictionaryResultType {
VOID = 0;
VALUE_CHANGED = 1;
PREVIOUS_VALUE = 2;
}
message Empty {
}
message HandleResult {
int32 handle = 1;
}
message ResetConnectionRequest {
}
message DatabaseOpenRequest {
bytes name = 1;
repeated bytes columnName = 2;
bool lowMemory = 3;
}
message DatabaseCloseRequest {
int32 databaseHandle = 1;
}
message SingletonOpenRequest {
int32 databaseHandle = 1;
bytes singletonListColumnName = 2;
bytes name = 3;
bytes defaultValue = 4;
}
message DictionaryOpenRequest {
int32 databaseHandle = 1;
bytes columnName = 2;
}
message DatabaseSnapshotTakeRequest {
int32 databaseHandle = 1;
}
message DatabaseSnapshotReleaseRequest {
int32 databaseHandle = 1;
int64 sequenceNumber = 2;
}
message DatabaseSnapshotTakeResult {
int64 sequenceNumber = 1;
}
message DictionaryMethodGetRequest {
int32 dictionaryHandle = 1;
int64 sequenceNumber = 3;
bytes key = 2;
}
message DictionaryMethodGetResponse {
bytes value = 1;
}
message DictionaryMethodContainsRequest {
int32 dictionaryHandle = 1;
int64 sequenceNumber = 3;
bytes key = 2;
}
message DictionaryMethodContainsResponse {
bool value = 1;
}
message DictionaryMethodPutRequest {
int32 dictionaryHandle = 1;
bytes key = 2;
bytes value = 3;
LLDictionaryResultType resultType = 4;
}
message DictionaryMethodPutMultiRequest {
int32 dictionaryHandle = 1;
repeated bytes key = 2;
repeated bytes value = 3;
LLDictionaryResultType resultType = 4;
}
message DictionaryMethodRemoveRequest {
int32 dictionaryHandle = 1;
bytes key = 2;
LLDictionaryResultType resultType = 3;
}
message DictionaryMethodClearRequest {
int32 dictionaryHandle = 1;
}
message DictionaryMethodSizeRequest {
int32 dictionaryHandle = 1;
int64 sequenceNumber = 2;
}
message DictionaryMethodIsEmptyRequest {
int32 dictionaryHandle = 1;
int64 sequenceNumber = 2;
}
message DictionaryMethodRemoveOneRequest {
int32 dictionaryHandle = 1;
}
message DictionaryMethodSizeResponse {
int64 size = 1;
}
message DictionaryMethodIsEmptyResponse {
bool empty = 1;
}
message DictionaryMethodStandardResult {
bytes value = 1;
}
message DictionaryMethodMultiStandardResult {
repeated bytes value = 1;
}
message DictionaryMethodForEachRequest {
int32 dictionaryHandle = 1;
int64 sequenceNumber = 2;
}
message DictionaryMethodStandardEntityResponse {
bytes key = 1;
bytes value = 2;
}
message DictionaryMethodForEachSnapshotRequest {
int32 dictionaryHandle = 1;
}
message DictionaryMethodForEachSnapshotResponse {
bytes key = 1;
bytes value = 2;
}
message DictionaryMethodReplaceAllRequest {
int32 dictionaryHandle = 1;
bool replaceKeys = 2;
}
message DictionaryMethodReplaceAllResponse {
bytes key = 1;
bytes value = 2;
}
message SingletonMethodGetRequest {
int32 singletonHandle = 1;
int64 sequenceNumber = 2;
}
message SingletonMethodGetResponse {
bytes value = 1;
}
message SingletonMethodSetRequest {
int32 singletonHandle = 1;
bytes value = 3;
}
message LuceneIndexOpenRequest {
string name = 1;
int32 textFieldsAnalyzer = 3;
int32 commitDebounceTime = 2;
int32 queryRefreshDebounceTime = 4;
bool lowMemory = 5;
int32 instancesCount = 6;
}
message LuceneIndexCloseRequest {
int32 handle = 1;
}
message LuceneIndexSnapshotTakeRequest {
int32 handle = 1;
}
message LuceneIndexSnapshotReleaseRequest {
int32 handle = 1;
int64 sequenceNumber = 2;
}
message LuceneIndexSnapshotTakeResult {
int64 sequenceNumber = 1;
}
message LuceneIndexMethodAddDocumentRequest {
int32 handle = 1;
LLTerm key = 3;
repeated LLItem documentItems = 2;
}
message LuceneIndexMethodAddDocumentMultiRequest {
int32 handle = 1;
repeated LLTerm key = 3;
repeated LLDocument documents = 2;
}
message LuceneIndexMethodDeleteDocumentRequest {
int32 handle = 1;
LLTerm key = 2;
}
message LuceneIndexMethodUpdateDocumentRequest {
int32 handle = 1;
LLTerm key = 2;
repeated LLItem documentItems = 3;
}
message LuceneIndexMethodUpdateDocumentMultiRequest {
int32 handle = 1;
repeated LLTerm key = 2;
repeated LLDocument documents = 3;
}
message LuceneIndexMethodDeleteAllRequest {
int32 handle = 1;
}
message LuceneIndexMethodSearchRequest {
int32 handle = 1;
int64 sequenceNumber = 6;
string query = 2;
int32 limit = 3;
LLSort sort = 4;
string keyFieldName = 5;
}
message LuceneIndexMethodMoreLikeThisRequest {
int32 handle = 1;
int64 sequenceNumber = 5;
repeated MltField mltFields = 2;
int32 limit = 3;
string keyFieldName = 4;
}
message MltField {
string key = 1;
repeated string values = 2;
}
message LuceneIndexMethodSearchMultiResponse {
repeated LuceneIndexMethodSearchResponse response = 1;
}
message LuceneIndexMethodSearchResponse {
int64 totalHitsCount = 1;
repeated LLKeyScore hits = 2;
}
message LuceneIndexMethodSearchStreamRequest {
int32 handle = 1;
int64 sequenceNumber = 6;
int32 shardIndex = 7;
string query = 2;
int32 limit = 3;
LLSort sort = 4;
string keyFieldName = 5;
}
message LuceneIndexMethodSearchStreamItem {
bool isKey = 1;
// If isKey == true:
string key = 2;
int32 shardIndex = 3;
// If isKey == false:
int64 approximatedTotalCount = 4;
}
message LLKeyScore {
string key = 1;
float score = 2;
}
message LuceneIndexMethodCountRequest {
int32 handle = 1;
int64 sequenceNumber = 3;
string query = 2;
}
message LuceneIndexMethodCountResponse {
int64 count = 1;
}
message LLSort {
string fieldName = 1;
LLSortType type = 2;
bool reverse = 3;
}
enum LLSortType {
LONG = 0;
RANDOM = 1;
}
message LLItem {
LLType type = 1;
string name = 2;
bytes data1 = 3;
bytes data2 = 4;
}
message LLDocument {
repeated LLItem items = 1;
}
message LLTerm {
string key = 1;
string value = 2;
}
enum LLType {
StringField = 0;
StringFieldStored = 1;
IntPoint = 2;
LongPoint = 3;
SortedNumericDocValuesField = 4;
TextField = 5;
TextFieldStored = 6;
}