`

A data matrix implementation 2

    博客分类:
  • OO*
阅读更多
We could add more functionalities, but in separate classes.

1. We may add a class for the following operations: sorting, querying, and merging.

java 代码
 
  1. import java.util.List;  
  2.   
  3. public class DataMatrixRowManipulator  
  4. {  
  5.     public DataMatrix query(String queryString, DataMatrix dataMatrix)  
  6.     {  
  7.         return null;  
  8.     }  
  9.   
  10.     public DataMatrix sortByColumn(int col)  
  11.     {  
  12.         return null;  
  13.     }  
  14.   
  15.     public DataMatrix sortByField(Field field)  
  16.     {  
  17.         return null;  
  18.     }  
  19.   
  20.     public List selectRow(DataMatrixRowKey rowKey, DataMatrix dataMatrix)  
  21.     {  
  22.         return null;  
  23.     }  
  24.   
  25.     public DataMatrix mergeOnKey(DataMatrixRowKey rowKey, DataMatrix dataMatrix, DataMatrix anotherDataMatrix)  
  26.     {  
  27.         return null;  
  28.     }  
  29. }  

Here the class DataMatrixRowKey is to guaranty the uniqueness of each row for the selection and merge purpose(This is corresponding to the composite keys).

java 代码
 
  1. import java.util.Set;  
  2. import java.util.Collection;  
  3. import java.util.HashSet;  
  4. import java.util.Iterator;  
  5.   
  6. public class DataMatrixRowKey  
  7. {  
  8.     private Set keyFieldSet;  
  9.   
  10.     public DataMatrixRowKey(Collection keyFieldSet)  
  11.     {  
  12.         this.keyFieldSet = new HashSet(keyFieldSet);  
  13.     }  
  14.   
  15.     public boolean equals(Object obj)  
  16.     {  
  17.         // equals only when all fields are the same.  
  18.         if (!(obj instanceof DataMatrixRowKey)) return false;  
  19.   
  20.         DataMatrixRowKey key = (DataMatrixRowKey)obj;  
  21.   
  22.         if (key.keyFieldSet.size() != this.keyFieldSet.size()) return false;  
  23.   
  24.         for (Iterator it=keyFieldSet.iterator(); it.hasNext(); )  
  25.         {  
  26.             if (!key.keyFieldSet.contains(it.next())) return false;  
  27.         }  
  28.   
  29.         return true;  
  30.     }  
  31.   
  32.     public int hashCode()  
  33.     {  
  34.         return keyFieldSet.hashCode();  
  35.     }  
  36. }  

And again, these operations don't use the specific knowledge of Field. The query operation could be complicated, in order to support a search language similar to SQL, we may use a language parser.

2. We could have a separate converter to convert a data matrix to XML, CSV, etc formats and vice versa.

3. Number crunching, e.g., the sum of all cells in a column, truncate float/double to int/long or to certain digits after period, or even a formula that computes from other columns. The formula parsing could get complicated when the Field class has more data fields, even with the help of ANTLR or JavaCC.

4. The hard problem is the equals() method since it has different meanings in different contexts. One way is that two data matrix are equal only when they match cell by cell, another way is by rows and ignore orders, and so on.
分享到:
评论

相关推荐

    DataMatrix 二维码生成 和解码 C#程序

    DataMatrix 二维码生成 和解码 C#程序,亲测可用。解码是Freytag DataMatrixDecoder A c# implementation to find DataMatrix 'barcodes' in bitmaps and decode them back into a string.

    zxing datamartrix生成点阵二维码

    2. **编写代码**:在需要生成DataMatrix的Java或Kotlin类中,创建一个方法来生成点阵二维码: ```java import com.google.zxing.*; import com.google.zxing.common.BitMatrix; import ...

    nrfPCA的MATLAB实现

    1)x: your data matrix samples in rows and variables in columns. 2)LV: How many variables to use from data, if not specified all variables are used. 3)method: Optional, will be selected automatically. ...

    PCA implementation

    cov_matrix = cov(data); ``` 3. **特征值分解**:协方差矩阵是一个实对称矩阵,因此可以进行特征值分解。这一步骤将帮助我们找出主成分的方向。MATLAB中的`eig`函数可以完成这个任务。 ```matlab [~, ...

    Open Data Structures (in Java) Pat Morin

    Offered as an introduction to the field of data structures and algorithms, Open Data Structures covers the implementation and analysis of data structures for sequences (lists), queues, priority queues...

    Low-Rank Modeling of Local k-Space Neighborhoods (LORAKS) for Constrained MRI

    with simulated and experimental data for a range of denoising and sparse-sampling applications. LORAKS is also compared against state-of-the-art methods like homodyne reconstruction, `1-norm ...

    i-vector的工具箱

    In the conventional GMM-UBM framework the universal background model (UBM) is a Gaussian mixture model (GMM) that is trained on a pool of data (known as the background or development data) from a ...

    数据库系统原理英文课件:ch16 Concurrency Control.ppt

    The **lock-compatibility matrix** plays a key role here, determining whether a transaction can be granted a lock based on the locks already held by other transactions on the same item. Multiple ...

    实验三:数组及其应用.doc

    2. The second program prints the elements of a 2D array in a specific order. 3. The third program finds the maximum element in a 2D array and prints its position and value. 4. The fourth program ...

    android上使用ZXing识别条形码和二维码

    2. **创建扫描界面**:ZXing提供了一个简单的Intent方式来启动扫描。你只需要创建一个按钮或者触发扫描的事件,然后启动扫描Intent: ```java IntentIntegrator integrator = new IntentIntegrator(this); ...

    遥感图像处理论文合集,包含高光谱遥感等多个方向

    “A Large-Scale Benchmark Data Set for Evaluating Pansharpening Performance Overview and implementation”两篇论文提供了评估高光谱和多光谱图像融合(即 pansharpening)性能的大规模基准数据集,这对于比较...

    Introduction to MATLAB for Engineers

    - **4.5–2 Plotting with a For Loop**: Here, plotting functions are used in conjunction with loops to visualize data dynamically. This technique is particularly useful for engineers who need to ...

    人口模型的处理,二胎影响

    the data obtained with the existing data, it is concluded that the opening of the second child has a positive effect on China’s economic development, the alleviation of aging, and the increase in the...

    svm matlab版本

    A matlab function libsvmwrite writes Matlab matrix to a file in LIBSVM format: libsvmwrite('data.txt', label_vector, instance_matrix] The instance_matrix must be a sparse matrix. (type must be ...

    矩阵类 及其基本运算

    例如,可以定义一个名为`Matrix`的类,包含私有字段`rows`、`cols`和`data`,分别表示行数、列数和二维数组数据: ```csharp public class Matrix { private int rows; private int cols; private double[,] ...

    Professional C# 3rd Edition

    Populating a DataSet Class with a Data Adapter 722 Populating a DataSet from XML 723 xx Contents Persisting DataSet Changes 723 Updating with Data Adapters 724 Writing XML Output 726 Working with ADO...

    Salesforce doc: Integration Patterns and Practices

    - **SOAP (Simple Object Access Protocol)**: A protocol for exchanging structured information in the implementation of web services. - **REST (Representational State Transfer)**: An architectural style...

    Graphics Gems (Vol.2)

    2. Recovering the Data from the Transformation Matrix 324 Ronald N. Goldman 3. Transformations as Exponentials 332 Ronald N. Goldman 4. More Matrices and Transformations: Shear and Pseudo-Perspective ...

Global site tag (gtag.js) - Google Analytics