dmitrievanthony commented on a change in pull request #6378: IGNITE-11647: ML 
Vectors should work with all Serializable objects besides double
URL: https://github.com/apache/ignite/pull/6378#discussion_r270479520
 
 

 ##########
 File path: 
modules/ml/src/main/java/org/apache/ignite/ml/math/primitives/vector/storage/DenseVectorStorage.java
 ##########
 @@ -56,19 +61,90 @@ public DenseVectorStorage(double[] data) {
         this.data = data;
     }
 
+    /**
+     * @param data Backing data array.
+     */
+    public DenseVectorStorage(Serializable[] data) {
+        assert data != null;
+
+        this.rawData = data;
+    }
+
     /** {@inheritDoc} */
     @Override public int size() {
-        return data == null ? 0 : data.length;
+        if (data == null && rawData == null)
+            return 0;
+        else {
+            if (data != null)
+                return data.length;
+            if (rawData != null)
+                return rawData.length;
+            else
+                throw new IllegalStateException();
+        }
+    }
+
+    /**
+     * Copies values between internal arrays If toNumericRepresentation = true 
then method tries cast all serializable
+     * objects to double, initializes double array with converted values and 
cleans raw data array. If
+     * toNumericRepresentation = false then method copies double array to raw 
data array and cleans double array.
+     *
+     * @param toNumericRepresentation To numeric representation.
+     */
+    private void swap(boolean toNumericRepresentation) {
 
 Review comment:
   Lets make two methods `toNumericArray` and `toGenericArray`. Looks like it 
will be more clear.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to