alessandrobenedetti commented on code in PR #3151:
URL: https://github.com/apache/solr/pull/3151#discussion_r1943553277


##########
solr/modules/llm/src/java/org/apache/solr/llm/texttovector/update/processor/TextToVectorUpdateProcessor.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.llm.texttovector.update.processor;
+
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.SolrInputField;
+import org.apache.solr.llm.texttovector.model.SolrTextToVectorModel;
+import 
org.apache.solr.llm.texttovector.store.rest.ManagedTextToVectorModelStore;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.processor.UpdateRequestProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.List;
+
+
+class TextToVectorUpdateProcessor extends UpdateRequestProcessor {
+    private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+    private final String inputField;
+    private final String outputField;
+    private final String model;
+    private SolrTextToVectorModel textToVector;
+    private ManagedTextToVectorModelStore modelStore = null;
+
+    public TextToVectorUpdateProcessor(
+            String inputField,
+            String outputField,
+            String model,
+            SolrQueryRequest req,
+            UpdateRequestProcessor next) {
+        super(next);
+        this.inputField = inputField;
+        this.outputField = outputField;
+        this.model = model;
+        this.modelStore = 
ManagedTextToVectorModelStore.getManagedModelStore(req.getCore());
+    }
+
+    /**
+     * @param cmd the update command in input containing the Document to 
process
+     * @throws IOException If there is a low-level I/O error
+     */
+    @Override
+    public void processAdd(AddUpdateCommand cmd) throws IOException {
+        this.textToVector = modelStore.getModel(model);

Review Comment:
   I was debugging the flow to have a better understanding of the lifecycle of 
an update request processor.
   
   From what I see from the test, the factory instantiates a new update request 
processor every time a new update request is received.
   I think it's ok to keep it a class member, but let me see if I can move the 
instantiation to the factory.
   Ideally I wanted that to happen when the factory is initiate but It seems 
that the update request processor factory is not compatible with resource 
loading (as far as I debugged and checked)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to