Skip to content

Commit bd9de7e

Browse files
committed
Enables Komet gRPC plugin
1 parent a2a0e3e commit bd9de7e

15 files changed

Lines changed: 216 additions & 25 deletions

File tree

common/pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
<!-- </properties>-->
1414
<dependencies>
1515
<dependency>
16-
<groupId>com.github.RoaringBitmap.RoaringBitmap</groupId>
17-
<artifactId>roaringbitmap</artifactId>
16+
<groupId>org.roaringbitmap</groupId>
17+
<artifactId>RoaringBitmap</artifactId>
18+
<version>1.6.9</version>
19+
</dependency>
20+
<dependency>
21+
<groupId>org.roaringbitmap</groupId>
22+
<artifactId>bsi</artifactId>
23+
<version>1.6.9</version>
1824
</dependency>
1925
<dependency>
2026
<groupId>dev.ikm.jpms</groupId>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright © 2015 Integrated Knowledge Management (support@ikm.dev)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package dev.ikm.tinkar.common.service;
17+
18+
/**
19+
* Marker for a {@link PrimitiveDataService} that has no local author/STAMP store to select a
20+
* user from — e.g. a read-only remote-backed provider.
21+
*
22+
* <p>UI layers check {@code PrimitiveData.get() instanceof NoLocalUserStore} to decide whether
23+
* to skip author login/selection after a data source finishes loading, instead of hardcoding a
24+
* check against a specific provider implementation.
25+
*/
26+
public interface NoLocalUserStore {
27+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* Copyright © 2015 Integrated Knowledge Management (support@ikm.dev)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package dev.ikm.tinkar.common.service;
17+
18+
import java.util.List;
19+
import java.util.UUID;
20+
21+
/**
22+
* Search contract for backends that can return rich, grouped/semantic results and
23+
* hydrate a full concept graph on demand, in addition to the flat {@link SearchService}
24+
* contract.
25+
*
26+
* <p>Discovered like any other lifecycle-managed service:
27+
* <pre>{@code
28+
* Optional<RemoteConceptSearchService> remote = ServiceLifecycleManager.get()
29+
* .getRunningService(RemoteConceptSearchService.class);
30+
* if (remote.isPresent()) {
31+
* // use remote.get().searchGrouped(...) / .searchFlat(...)
32+
* } else {
33+
* // fall back to local search
34+
* }
35+
* }</pre>
36+
* Presence of the service in the returned {@code Optional} is itself the activity signal —
37+
* there is no separate {@code isActive()} check.
38+
*/
39+
public interface RemoteConceptSearchService {
40+
41+
/**
42+
* Sort options mirroring common UI sort controls.
43+
*/
44+
enum SortOption {
45+
TOP_COMPONENT,
46+
TOP_COMPONENT_ALPHA,
47+
SEMANTIC,
48+
SEMANTIC_ALPHA
49+
}
50+
51+
/**
52+
* A single semantic match within a {@link GroupedResult}.
53+
*
54+
* @param highlightedText matched text with {@code <B>…</B>} markup
55+
* @param plainText plain text without HTML markup
56+
* @param score relevance score
57+
*/
58+
record MatchingSemantic(String highlightedText, String plainText, float score) {}
59+
60+
/**
61+
* A top-level (grouped) search result — one per matching concept.
62+
*
63+
* @param publicId stable UUIDs identifying the concept
64+
* @param fullyQualifiedName FQN of the concept
65+
* @param active whether the concept is currently active
66+
* @param topScore highest relevance score among child semantics
67+
* @param matchingSemantics child semantic matches
68+
*/
69+
record GroupedResult(
70+
List<String> publicId,
71+
String fullyQualifiedName,
72+
boolean active,
73+
float topScore,
74+
List<MatchingSemantic> matchingSemantics) {}
75+
76+
/**
77+
* A flat semantic search result (SEMANTIC sort modes) — one per matched semantic.
78+
*
79+
* @param publicId stable UUIDs identifying the concept
80+
* @param fullyQualifiedName FQN of the concept
81+
* @param highlightedText matched text with {@code <B>…</B>} markup
82+
* @param active whether the concept is currently active
83+
* @param score relevance score
84+
*/
85+
record SemanticResult(
86+
List<String> publicId,
87+
String fullyQualifiedName,
88+
String highlightedText,
89+
boolean active,
90+
float score) {}
91+
92+
/**
93+
* Performs a search returning grouped results (TOP_COMPONENT modes).
94+
*/
95+
List<GroupedResult> searchGrouped(String query, int maxResults, SortOption sortOption);
96+
97+
/**
98+
* Performs a search returning flat semantic results (SEMANTIC modes).
99+
*/
100+
List<SemanticResult> searchFlat(String query, int maxResults, SortOption sortOption);
101+
102+
/**
103+
* Fetches the full entity graph for a concept from the remote backend and loads it
104+
* into the local entity store, so subsequent local lookups (name, parents, axioms)
105+
* resolve without another round trip.
106+
*
107+
* @param publicIds the concept's public UUIDs (from a search result)
108+
* @return the local NID assigned to the concept after loading
109+
*/
110+
int loadConceptWithSemantics(List<UUID> publicIds);
111+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dev.ikm.tinkar.provider.spinedarray.SpinedArrayProvider$OpenController
2+
dev.ikm.tinkar.provider.spinedarray.SpinedArrayProvider$NewController
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dev.ikm.tinkar.provider.spinedarray.SpinedArrayProvider$OpenController
2+
dev.ikm.tinkar.provider.spinedarray.SpinedArrayProvider$NewController

provider/entity-provider/src/main/java/dev/ikm/tinkar/provider/entity/EntityProvider.java

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,40 @@ public String textFast(int nid) {
125125
}
126126
anyString = (String) version.fieldValues().get(indexForText);
127127
} else {
128-
Entity<?> entity = patternHandle.expectEntity();
129-
anyString = " <" + entity.nid() + ">" + entity.asUuidList().toString();
130-
// Added in case entity.toString() itself throws an exception, at least get a UUID for the problem.
131-
AlertStreams.getRoot().dispatch(AlertObject.makeError(new IllegalStateException("Expecting a pattern entity. Found entity with id: " + anyString)));
132-
AlertStreams.getRoot().dispatch(AlertObject.makeError(new IllegalStateException("Expecting a pattern entity. Found: " + entity)));
128+
// Pattern entity is not a PatternEntity. If it is absent (e.g. in gRPC/ephemeral-store mode
129+
// before all entities are loaded) skip silently. Otherwise report the type mismatch.
130+
if (patternHandle.isAbsent()) {
131+
LOG.warn("Pattern entity absent for NID {} while resolving text for NID {} — skipping (gRPC mode)",
132+
descriptionSemantic.patternNid(), nid);
133+
} else {
134+
Entity<?> entity = patternHandle.expectEntity();
135+
anyString = " <" + entity.nid() + ">" + entity.asUuidList().toString();
136+
// Added in case entity.toString() itself throws an exception, at least get a UUID for the problem.
137+
AlertStreams.getRoot().dispatch(AlertObject.makeError(new IllegalStateException("Expecting a pattern entity. Found entity with id: " + anyString)));
138+
AlertStreams.getRoot().dispatch(AlertObject.makeError(new IllegalStateException("Expecting a pattern entity. Found: " + entity)));
139+
}
133140
}
134141
} else {
135-
Entity<?> entity = descriptionSemanticHandle.expectEntity();
136-
anyString = " <" + entity.nid() + "> " + entity.asUuidList().toString();
137-
LOG.error("ERROR getting string for nid: " + anyString);
138-
LOG.error("ERROR Nid - 2: <" + (nid - 2) + "> " + getChronology(nid - 2));
139-
LOG.error("ERROR Nid - 1: <" + (nid - 1) + "> " + getChronology(nid - 1));
140-
LOG.error("ERROR Nid: <" + nid + "> " + getChronology(nid - 1));
141-
LOG.error("ERROR Nid + 1: <" + (nid + 1) + "> " + getChronology(nid + 1));
142-
LOG.error("ERROR Nid + 2: <" + (nid + 2) + "> " + getChronology(nid + 2));
143-
144-
// Added in case entity.toString() itself throws an exception, at least get a UUID for the problem.
145-
AlertStreams.getRoot().dispatch(AlertObject.makeError(new IllegalStateException("Expecting a description semantic entity from list: " +
146-
Arrays.toString(semanticNids) + "\n Found entity with id: " + anyString)));
147-
AlertStreams.getRoot().dispatch(AlertObject.makeError(new IllegalStateException("Expecting a description semantic. Found: " + entity)));
142+
// Description semantic handle is not a SemanticEntity. If absent (gRPC/ephemeral-store mode
143+
// before all entities are loaded) skip silently. Otherwise report the type mismatch.
144+
if (descriptionSemanticHandle.isAbsent()) {
145+
LOG.warn("Description semantic entity absent for NID {} while resolving text for NID {} — skipping (gRPC mode)",
146+
semanticNid, nid);
147+
} else {
148+
Entity<?> entity = descriptionSemanticHandle.expectEntity();
149+
anyString = " <" + entity.nid() + "> " + entity.asUuidList().toString();
150+
LOG.error("ERROR getting string for nid: " + anyString);
151+
LOG.error("ERROR Nid - 2: <" + (nid - 2) + "> " + getChronology(nid - 2));
152+
LOG.error("ERROR Nid - 1: <" + (nid - 1) + "> " + getChronology(nid - 1));
153+
LOG.error("ERROR Nid: <" + nid + "> " + getChronology(nid - 1));
154+
LOG.error("ERROR Nid + 1: <" + (nid + 1) + "> " + getChronology(nid + 1));
155+
LOG.error("ERROR Nid + 2: <" + (nid + 2) + "> " + getChronology(nid + 2));
156+
157+
// Added in case entity.toString() itself throws an exception, at least get a UUID for the problem.
158+
AlertStreams.getRoot().dispatch(AlertObject.makeError(new IllegalStateException("Expecting a description semantic entity from list: " +
159+
Arrays.toString(semanticNids) + "\n Found entity with id: " + anyString)));
160+
AlertStreams.getRoot().dispatch(AlertObject.makeError(new IllegalStateException("Expecting a description semantic. Found: " + entity)));
161+
}
148162
}
149163
}
150164
if (fqnString != null) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dev.ikm.tinkar.provider.entity.EntityProvider$CacheProvider
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dev.ikm.tinkar.provider.entity.EntityProvider$Controller
2+
dev.ikm.tinkar.provider.entity.StampProvider$Controller
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dev.ikm.tinkar.coordinate.stamp.calculator.PathProvider
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dev.ikm.tinkar.provider.entity.StampProvider

0 commit comments

Comments
 (0)