Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
import com.google.auto.value.AutoValue;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.protobuf.Empty;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import com.google.protobuf.util.JsonFormat;
import io.grpc.Status.Code;
import java.lang.reflect.Type;
import java.util.UUID;

/** MessageAuditLogEntry records the handling of a Protobuf message by a service call. */
Expand Down Expand Up @@ -103,20 +100,17 @@ public String toJSON() {
new GsonBuilder()
.registerTypeAdapter(
Message.class,
new JsonSerializer<Message>() {
@Override
public JsonElement serialize(
Message message, Type type, JsonSerializationContext context) {
try {
String messageJSON = JsonFormat.printer().print(message);
return new JsonParser().parse(messageJSON);
} catch (InvalidProtocolBufferException e) {

throw new RuntimeException(
"Unexpected exception converting Protobuf to JSON", e);
}
}
})
(JsonSerializer<Message>)
(message, type, context) -> {
try {
String messageJSON = JsonFormat.printer().print(message);
return new JsonParser().parse(messageJSON);
} catch (InvalidProtocolBufferException e) {

throw new RuntimeException(
"Unexpected exception converting Protobuf to JSON", e);
}
})
.create();
return gson.toJson(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* GrpcMessageInterceptor assumes that all service calls are unary (ie single request/response).
*/
public class GrpcMessageInterceptor implements ServerInterceptor {
private LoggingProperties loggingProperties;
private final LoggingProperties loggingProperties;

/**
* Construct GrpcMessageIntercetor.
Expand Down Expand Up @@ -78,7 +78,7 @@ public <ReqT, RespT> Listener<ReqT> interceptCall(

// Register forwarding call to intercept outgoing response and log to audit log
call =
new SimpleForwardingServerCall<ReqT, RespT>(call) {
new SimpleForwardingServerCall<>(call) {
@Override
public void sendMessage(RespT message) {
// 2. Track the response & Log entry to audit logger
Expand All @@ -97,7 +97,7 @@ public void close(Status status, Metadata trailers) {
};

ServerCall.Listener<ReqT> listener = next.startCall(call, headers);
return new SimpleForwardingServerCallListener<ReqT>(listener) {
return new SimpleForwardingServerCallListener<>(listener) {
@Override
// Register listener to intercept incoming request messages and log to audit log
public void onMessage(ReqT message) {
Expand Down
4 changes: 1 addition & 3 deletions java/sdk/src/main/java/dev/feast/RequestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ public static List<FeatureReferenceV2> createFeatureRefs(List<String> featureRef
}

List<FeatureReferenceV2> featureRefs =
featureRefStrings.stream()
.map(refStr -> parseFeatureRef(refStr))
.collect(Collectors.toList());
featureRefStrings.stream().map(RequestUtil::parseFeatureRef).collect(Collectors.toList());

return featureRefs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.Optional;

public class LocalRegistryFile implements RegistryFile {
private RegistryProto.Registry cachedRegistry;
private final RegistryProto.Registry cachedRegistry;

public LocalRegistryFile(String path) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
package feast.serving.registry;

import feast.proto.core.*;
import feast.proto.core.FeatureServiceProto.FeatureService;
import feast.proto.core.FeatureViewProto.FeatureView;
import feast.proto.core.OnDemandFeatureViewProto.OnDemandFeatureView;
import feast.proto.serving.ServingAPIProto;
import feast.serving.exception.SpecRetrievalException;
import java.util.List;
Expand All @@ -26,24 +29,24 @@

public class Registry {
private final RegistryProto.Registry registry;
private Map<String, FeatureViewProto.FeatureViewSpec> featureViewNameToSpec;
private final Map<String, FeatureViewProto.FeatureViewSpec> featureViewNameToSpec;
private Map<String, OnDemandFeatureViewProto.OnDemandFeatureViewSpec>
onDemandFeatureViewNameToSpec;
private Map<String, FeatureServiceProto.FeatureServiceSpec> featureServiceNameToSpec;
private final Map<String, FeatureServiceProto.FeatureServiceSpec> featureServiceNameToSpec;

Registry(RegistryProto.Registry registry) {
this.registry = registry;
List<FeatureViewProto.FeatureViewSpec> featureViewSpecs =
registry.getFeatureViewsList().stream()
.map(fv -> fv.getSpec())
.map(FeatureView::getSpec)
.collect(Collectors.toList());
this.featureViewNameToSpec =
featureViewSpecs.stream()
.collect(
Collectors.toMap(FeatureViewProto.FeatureViewSpec::getName, Function.identity()));
List<OnDemandFeatureViewProto.OnDemandFeatureViewSpec> onDemandFeatureViewSpecs =
registry.getOnDemandFeatureViewsList().stream()
.map(odfv -> odfv.getSpec())
.map(OnDemandFeatureView::getSpec)
.collect(Collectors.toList());
this.onDemandFeatureViewNameToSpec =
onDemandFeatureViewSpecs.stream()
Expand All @@ -53,7 +56,7 @@ public class Registry {
Function.identity()));
this.featureServiceNameToSpec =
registry.getFeatureServicesList().stream()
.map(fs -> fs.getSpec())
.map(FeatureService::getSpec)
.collect(
Collectors.toMap(
FeatureServiceProto.FeatureServiceSpec::getName, Function.identity()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ public void processTransformFeaturesResponse(
} catch (IOException e) {
log.info(e.toString());
throw Status.INTERNAL
.withDescription(
"Unable to correctly process transform features response: " + e.toString())
.withDescription("Unable to correctly process transform features response: " + e)
.asRuntimeException();
}
}
Expand All @@ -249,11 +248,10 @@ public void processTransformFeaturesResponse(
public ValueType serializeValuesIntoArrowIPC(List<Pair<String, List<ValueProto.Value>>> values) {
// In order to be serialized correctly, the data must be packaged in a VectorSchemaRoot.
// We first construct all the columns.
Map<String, FieldVector> columnNameToColumn = new HashMap<String, FieldVector>();
BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);

List<Field> columnFields = new ArrayList<Field>();
List<FieldVector> columns = new ArrayList<FieldVector>();
List<Field> columnFields = new ArrayList<>();
List<FieldVector> columns = new ArrayList<>();

for (Pair<String, List<ValueProto.Value>> columnEntry : values) {
// The Python FTS does not expect full feature names, so we extract the feature name.
Expand Down Expand Up @@ -316,8 +314,7 @@ public ValueType serializeValuesIntoArrowIPC(List<Pair<String, List<ValueProto.V
} catch (IOException e) {
log.info(e.toString());
throw Status.INTERNAL
.withDescription(
"ArrowFileWriter could not write properly; failed with error: " + e.toString())
.withDescription("ArrowFileWriter could not write properly; failed with error: " + e)
.asRuntimeException();
}
byte[] byteData = out.toByteArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public ValueProto.Value getFeatureValue(ValueProto.ValueType.Enum valueType) {
.build();
break;
default:
throw new RuntimeException("FeatureType is not supported");
throw new RuntimeException(
String.format("FeatureType %s is not supported", valueType.name()));
}
} catch (ClassCastException e) {
// Feature type has changed
Expand Down