Skip to content

Commit

Permalink
Addressing comments
Browse files Browse the repository at this point in the history
Signed-off-by: Vacha Shah <[email protected]>
  • Loading branch information
VachaShah committed Mar 27, 2024
1 parent e25d656 commit 449a4ff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ private void process(ExecutableElement executable, ReferenceType ref) {
return;
}

// Skip protobuf generated classes used in public apis
if (ref.toString().contains("Proto")) {
return;
}

if (ref instanceof DeclaredType) {
final DeclaredType declaredType = (DeclaredType) ref;

Expand Down Expand Up @@ -243,7 +238,15 @@ private boolean inspectable(ExecutableElement executable) {
*/
private boolean inspectable(Element element) {
final PackageElement pckg = processingEnv.getElementUtils().getPackageOf(element);
return pckg.getQualifiedName().toString().startsWith(OPENSEARCH_PACKAGE);
return pckg.getQualifiedName().toString().startsWith(OPENSEARCH_PACKAGE)
&& !element.getEnclosingElement()
.getAnnotationMirrors()
.stream()
.anyMatch(
m -> m.getAnnotationType()
.toString() /* ClassSymbol.toString() returns class name */
.equalsIgnoreCase("javax.annotation.Generated")
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,17 @@ public class FeatureFlags {

public static final Setting<Boolean> PLUGGABLE_CACHE_SETTING = Setting.boolSetting(PLUGGABLE_CACHE, false, Property.NodeScope);

public static final Setting<Boolean> PROTOBUF_SETTING = Setting.boolSetting(PROTOBUF, false, Property.NodeScope, Property.Dynamic);

private static final List<Setting<Boolean>> ALL_FEATURE_FLAG_SETTINGS = List.of(
REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING,
EXTENSIONS_SETTING,
IDENTITY_SETTING,
TELEMETRY_SETTING,
DATETIME_FORMATTER_CACHING_SETTING,
WRITEABLE_REMOTE_INDEX_SETTING,
PLUGGABLE_CACHE_SETTING
PLUGGABLE_CACHE_SETTING,
PROTOBUF_SETTING
);
/**
* Should store the settings from opensearch.yml.
Expand Down Expand Up @@ -166,5 +169,4 @@ public static boolean isEnabled(Setting<Boolean> featureFlag) {
}
}

public static final Setting<Boolean> PROTOBUF_SETTING = Setting.boolSetting(PROTOBUF, false, Property.NodeScope, Property.Dynamic);
}
11 changes: 0 additions & 11 deletions server/src/main/java/org/opensearch/search/SearchHit.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.document.DocumentField;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.common.xcontent.XContentHelper;
import org.opensearch.core.ParseField;
import org.opensearch.core.common.ParsingException;
Expand Down Expand Up @@ -68,8 +67,6 @@
import org.opensearch.rest.action.search.RestSearchAction;
import org.opensearch.search.fetch.subphase.highlight.HighlightField;
import org.opensearch.search.lookup.SourceLookup;
import org.opensearch.search.serializer.SearchHitProtobufSerializer;
import org.opensearch.server.proto.FetchSearchResultProto;
import org.opensearch.transport.RemoteClusterAware;

import java.io.IOException;
Expand Down Expand Up @@ -142,8 +139,6 @@ public final class SearchHit implements Writeable, ToXContentObject, Iterable<Do

private Map<String, SearchHits> innerHits;

private FetchSearchResultProto.SearchHit searchHitProto;

// used only in tests
public SearchHit(int docId) {
this(docId, null, null, null);
Expand All @@ -169,9 +164,6 @@ public SearchHit(
this.nestedIdentity = nestedIdentity;
this.documentFields = documentFields == null ? emptyMap() : documentFields;
this.metaFields = metaFields == null ? emptyMap() : metaFields;
if (FeatureFlags.isEnabled(FeatureFlags.PROTOBUF)) {
this.searchHitProto = SearchHitProtobufSerializer.convertHitToProto(this);
}
}

public SearchHit(StreamInput in) throws IOException {
Expand Down Expand Up @@ -456,9 +448,6 @@ public void setDocumentField(String fieldName, DocumentField field) {
if (fieldName == null || field == null) return;
if (documentFields.isEmpty()) this.documentFields = new HashMap<>();
this.documentFields.put(fieldName, field);
if (FeatureFlags.isEnabled(FeatureFlags.PROTOBUF)) {
this.searchHitProto = SearchHitProtobufSerializer.convertHitToProto(this);
}
}

public DocumentField removeDocumentField(String fieldName) {
Expand Down
7 changes: 0 additions & 7 deletions server/src/main/java/org/opensearch/search/SearchHits.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@
import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.lucene.Lucene;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.xcontent.ToXContentFragment;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.rest.action.search.RestSearchAction;
import org.opensearch.search.serializer.SearchHitsProtobufSerializer;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -84,8 +82,6 @@ public static SearchHits empty(boolean withTotalHits) {
@Nullable
private final Object[] collapseValues;

private org.opensearch.server.proto.FetchSearchResultProto.SearchHits searchHitsProto;

public SearchHits(SearchHit[] hits, @Nullable TotalHits totalHits, float maxScore) {
this(hits, totalHits, maxScore, null, null, null);
}
Expand All @@ -104,9 +100,6 @@ public SearchHits(
this.sortFields = sortFields;
this.collapseField = collapseField;
this.collapseValues = collapseValues;
if (FeatureFlags.isEnabled(FeatureFlags.PROTOBUF_SETTING)) {
this.searchHitsProto = SearchHitsProtobufSerializer.convertHitsToProto(this);
}
}

public SearchHits(StreamInput in) throws IOException {
Expand Down

0 comments on commit 449a4ff

Please sign in to comment.