This is an automated email from the ASF dual-hosted git repository. leerho pushed a commit to branch LicenseSwap2 in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-vector.git
commit 1d44221adf7fbe8e4a1d117ccd46a3c2adfca4d7 Author: Lee Rhodes <[email protected]> AuthorDate: Thu Oct 17 12:44:20 2019 -0700 The big License Swap + package refactoring --- pom.xml | 6 +- .../vector/decomposition/package-info.java | 14 ---- .../yahoo/sketches/vector/matrix/MatrixType.java | 20 ------ .../yahoo/sketches/vector/matrix/package-info.java | 14 ---- .../com/yahoo/sketches/vector/package-info.java | 11 --- .../apache/datasketches}/vector/MatrixFamily.java | 20 +++++- .../vector/decomposition/FrequentDirections.java | 78 +++++++++++++--------- .../vector/decomposition/MatrixOps.java | 25 +++++-- .../vector/decomposition/MatrixOpsImplOjAlgo.java | 27 ++++++-- .../vector/decomposition/PreambleUtil.java | 26 ++++++-- .../vector/decomposition/SVDAlgo.java | 21 +++++- .../vector/decomposition/package-info.java | 27 ++++++++ .../apache/datasketches}/vector/matrix/Matrix.java | 27 ++++++-- .../datasketches}/vector/matrix/MatrixBuilder.java | 21 ++++-- .../vector/matrix/MatrixImplOjAlgo.java | 45 ++++++++----- .../vector/matrix/MatrixPreambleUtil.java | 26 ++++++-- .../datasketches/vector/matrix/MatrixType.java | 39 +++++++++++ .../datasketches/vector/matrix/package-info.java | 27 ++++++++ .../apache/datasketches/vector/package-info.java | 24 +++++++ .../sketches/vector/matrix/MatrixBuilderTest.java | 36 ---------- .../decomposition/FrequentDirectionsTest.java | 28 ++++++-- .../vector/decomposition/MatrixOpsTest.java | 27 ++++++-- .../vector/matrix/MatrixBuilderTest.java | 49 ++++++++++++++ .../vector/matrix/MatrixImplOjAlgoTest.java | 24 +++++-- .../datasketches}/vector/matrix/MatrixTest.java | 26 ++++++-- 25 files changed, 485 insertions(+), 203 deletions(-) diff --git a/pom.xml b/pom.xml index 4d552fa..59be0fd 100644 --- a/pom.xml +++ b/pom.xml @@ -153,9 +153,9 @@ </dependency> <dependency> - <groupId>com.yahoo.datasketches</groupId> - <artifactId>memory</artifactId> - <version>0.10.2</version> + <groupId>org.apache.datasketches</groupId> + <artifactId>datasketches-memory</artifactId> + <version>1.1.0-incubating</version> </dependency> <!-- Test Scope --> diff --git a/src/main/java/com/yahoo/sketches/vector/decomposition/package-info.java b/src/main/java/com/yahoo/sketches/vector/decomposition/package-info.java deleted file mode 100644 index cea4261..0000000 --- a/src/main/java/com/yahoo/sketches/vector/decomposition/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2017, Yahoo! Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root - * for terms. - */ - -/** - * <p>This package is dedicated to streaming algorithms that enable approximate matrix - * decompositions.</p> - * - * <p>These sketches are mergeable and can be serialized and deserialized to/from a compact - * form.</p> - */ -package com.yahoo.sketches.vector.decomposition; diff --git a/src/main/java/com/yahoo/sketches/vector/matrix/MatrixType.java b/src/main/java/com/yahoo/sketches/vector/matrix/MatrixType.java deleted file mode 100644 index 7ca7f2b..0000000 --- a/src/main/java/com/yahoo/sketches/vector/matrix/MatrixType.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.yahoo.sketches.vector.matrix; - -public enum MatrixType { - OJALGO(1, "ojAlgo"); - - private int id_; - private String name_; - - MatrixType(final int id, final String name) { - id_ = id; - name_ = name; - } - - public int getId() { return id_; } - - public String getName() { return name_; } - - @Override - public String toString() { return name_; } -} diff --git a/src/main/java/com/yahoo/sketches/vector/matrix/package-info.java b/src/main/java/com/yahoo/sketches/vector/matrix/package-info.java deleted file mode 100644 index 5a307a9..0000000 --- a/src/main/java/com/yahoo/sketches/vector/matrix/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2017, Yahoo! Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root - * for terms. - */ - -/** - * <p>This package contains a Matrix class that wraps one of several underlying matrix - * implementations. It can be used to provide a stable public API independent of the - * specific linear algebra package used for computation.</p> - * - * <p>These Matrix objects can be serialized and deserialized to/from a compact form.</p> - */ -package com.yahoo.sketches.vector.matrix; diff --git a/src/main/java/com/yahoo/sketches/vector/package-info.java b/src/main/java/com/yahoo/sketches/vector/package-info.java deleted file mode 100644 index 8f1c2e3..0000000 --- a/src/main/java/com/yahoo/sketches/vector/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2017, Yahoo! Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root - * for terms. - */ - -/** - * This is the parent package for all vector sketch algorithms. Any classes at this level are - * used by more than one sub-package. - */ -package com.yahoo.sketches.vector; diff --git a/src/main/java/com/yahoo/sketches/vector/MatrixFamily.java b/src/main/java/org/apache/datasketches/vector/MatrixFamily.java similarity index 82% rename from src/main/java/com/yahoo/sketches/vector/MatrixFamily.java rename to src/main/java/org/apache/datasketches/vector/MatrixFamily.java index 22a6954..dec7952 100644 --- a/src/main/java/com/yahoo/sketches/vector/MatrixFamily.java +++ b/src/main/java/org/apache/datasketches/vector/MatrixFamily.java @@ -1,9 +1,23 @@ /* - * Copyright 2017, Yahoo, Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms. + * 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 com.yahoo.sketches.vector; +package org.apache.datasketches.vector; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/com/yahoo/sketches/vector/decomposition/FrequentDirections.java b/src/main/java/org/apache/datasketches/vector/decomposition/FrequentDirections.java similarity index 83% rename from src/main/java/com/yahoo/sketches/vector/decomposition/FrequentDirections.java rename to src/main/java/org/apache/datasketches/vector/decomposition/FrequentDirections.java index 04c8a9f..c3dff17 100644 --- a/src/main/java/com/yahoo/sketches/vector/decomposition/FrequentDirections.java +++ b/src/main/java/org/apache/datasketches/vector/decomposition/FrequentDirections.java @@ -1,38 +1,52 @@ /* - * Copyright 2017, Yahoo, Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms. + * 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 com.yahoo.sketches.vector.decomposition; - -import static com.yahoo.memory.UnsafeUtil.LS; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.EMPTY_FLAG_MASK; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.SER_VER; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.extractFamilyID; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.extractFlags; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.extractK; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.extractN; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.extractNumColumns; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.extractNumRows; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.extractSVAdjustment; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.extractSerVer; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.getAndCheckPreLongs; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.insertFamilyID; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.insertFlags; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.insertK; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.insertN; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.insertNumColumns; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.insertNumRows; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.insertPreLongs; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.insertSVAdjustment; -import static com.yahoo.sketches.vector.decomposition.PreambleUtil.insertSerVer; - -import com.yahoo.memory.Memory; -import com.yahoo.memory.WritableMemory; -import com.yahoo.sketches.vector.MatrixFamily; -import com.yahoo.sketches.vector.matrix.Matrix; -import com.yahoo.sketches.vector.matrix.MatrixBuilder; -import com.yahoo.sketches.vector.matrix.MatrixType; +package org.apache.datasketches.vector.decomposition; + +import static org.apache.datasketches.memory.UnsafeUtil.LS; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.EMPTY_FLAG_MASK; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.SER_VER; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.extractFamilyID; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.extractFlags; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.extractK; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.extractN; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.extractNumColumns; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.extractNumRows; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.extractSVAdjustment; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.extractSerVer; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.getAndCheckPreLongs; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.insertFamilyID; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.insertFlags; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.insertK; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.insertN; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.insertNumColumns; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.insertNumRows; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.insertPreLongs; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.insertSVAdjustment; +import static org.apache.datasketches.vector.decomposition.PreambleUtil.insertSerVer; + +import org.apache.datasketches.memory.Memory; +import org.apache.datasketches.memory.WritableMemory; +import org.apache.datasketches.vector.MatrixFamily; +import org.apache.datasketches.vector.matrix.Matrix; +import org.apache.datasketches.vector.matrix.MatrixBuilder; +import org.apache.datasketches.vector.matrix.MatrixType; /** * This class implements the Frequent Directions algorithm proposed by Edo Liberty in "Simple and diff --git a/src/main/java/com/yahoo/sketches/vector/decomposition/MatrixOps.java b/src/main/java/org/apache/datasketches/vector/decomposition/MatrixOps.java similarity index 79% rename from src/main/java/com/yahoo/sketches/vector/decomposition/MatrixOps.java rename to src/main/java/org/apache/datasketches/vector/decomposition/MatrixOps.java index b0dfcf1..845ad46 100644 --- a/src/main/java/com/yahoo/sketches/vector/decomposition/MatrixOps.java +++ b/src/main/java/org/apache/datasketches/vector/decomposition/MatrixOps.java @@ -1,15 +1,32 @@ -/* Directly derived from LGPL'd Matrix Toolkit for Java: - * https://github.com/fommil/matrix-toolkits-java/blob/master/src/main/java/no/uib/cipr/matrix/SVD.java +/* + * 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 com.yahoo.sketches.vector.decomposition; +package org.apache.datasketches.vector.decomposition; -import com.yahoo.sketches.vector.matrix.Matrix; +import org.apache.datasketches.vector.matrix.Matrix; /** * Computes singular value decompositions and related Matrix operations needed by Frequent Directions. May * return as many singular values as exist, but other operations will limit output to k dimensions. */ +// Directly derived from LGPL'd Matrix Toolkit for Java: +// https://github.com/fommil/matrix-toolkits-java/blob/master/src/main/java/no/uib/cipr/matrix/SVD.java abstract class MatrixOps { // iterations for SISVD diff --git a/src/main/java/com/yahoo/sketches/vector/decomposition/MatrixOpsImplOjAlgo.java b/src/main/java/org/apache/datasketches/vector/decomposition/MatrixOpsImplOjAlgo.java similarity index 85% rename from src/main/java/com/yahoo/sketches/vector/decomposition/MatrixOpsImplOjAlgo.java rename to src/main/java/org/apache/datasketches/vector/decomposition/MatrixOpsImplOjAlgo.java index 57dfc3e..401d00b 100644 --- a/src/main/java/com/yahoo/sketches/vector/decomposition/MatrixOpsImplOjAlgo.java +++ b/src/main/java/org/apache/datasketches/vector/decomposition/MatrixOpsImplOjAlgo.java @@ -1,4 +1,23 @@ -package com.yahoo.sketches.vector.decomposition; +/* + * 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.datasketches.vector.decomposition; import java.util.Optional; @@ -10,9 +29,9 @@ import org.ojalgo.matrix.store.PrimitiveDenseStore; import org.ojalgo.matrix.store.SparseStore; import org.ojalgo.random.Normal; -import com.yahoo.sketches.vector.matrix.Matrix; -import com.yahoo.sketches.vector.matrix.MatrixImplOjAlgo; -import com.yahoo.sketches.vector.matrix.MatrixType; +import org.apache.datasketches.vector.matrix.Matrix; +import org.apache.datasketches.vector.matrix.MatrixImplOjAlgo; +import org.apache.datasketches.vector.matrix.MatrixType; class MatrixOpsImplOjAlgo extends MatrixOps { private double[] sv_; diff --git a/src/main/java/com/yahoo/sketches/vector/decomposition/PreambleUtil.java b/src/main/java/org/apache/datasketches/vector/decomposition/PreambleUtil.java similarity index 88% rename from src/main/java/com/yahoo/sketches/vector/decomposition/PreambleUtil.java rename to src/main/java/org/apache/datasketches/vector/decomposition/PreambleUtil.java index 0de11d3..6d2762c 100644 --- a/src/main/java/com/yahoo/sketches/vector/decomposition/PreambleUtil.java +++ b/src/main/java/org/apache/datasketches/vector/decomposition/PreambleUtil.java @@ -1,14 +1,28 @@ /* - * Copyright 2017, Yahoo, Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms. + * 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 com.yahoo.sketches.vector.decomposition; +package org.apache.datasketches.vector.decomposition; -import static com.yahoo.memory.UnsafeUtil.unsafe; +import static org.apache.datasketches.memory.UnsafeUtil.unsafe; -import com.yahoo.memory.Memory; -import com.yahoo.sketches.vector.MatrixFamily; +import org.apache.datasketches.memory.Memory; +import org.apache.datasketches.vector.MatrixFamily; /** * This class defines the preamble items structure and provides basic utilities for some of the key fields. diff --git a/src/main/java/com/yahoo/sketches/vector/decomposition/SVDAlgo.java b/src/main/java/org/apache/datasketches/vector/decomposition/SVDAlgo.java similarity index 55% rename from src/main/java/com/yahoo/sketches/vector/decomposition/SVDAlgo.java rename to src/main/java/org/apache/datasketches/vector/decomposition/SVDAlgo.java index 36b5462..87d2bd2 100644 --- a/src/main/java/com/yahoo/sketches/vector/decomposition/SVDAlgo.java +++ b/src/main/java/org/apache/datasketches/vector/decomposition/SVDAlgo.java @@ -1,4 +1,23 @@ -package com.yahoo.sketches.vector.decomposition; +/* + * 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.datasketches.vector.decomposition; /** * This class allows a choice of algorithms for Singular Value Decomposition. The options are: diff --git a/src/main/java/org/apache/datasketches/vector/decomposition/package-info.java b/src/main/java/org/apache/datasketches/vector/decomposition/package-info.java new file mode 100644 index 0000000..0a03e12 --- /dev/null +++ b/src/main/java/org/apache/datasketches/vector/decomposition/package-info.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +/** + * <p>This package is dedicated to streaming algorithms that enable approximate matrix + * decompositions.</p> + * + * <p>These sketches are mergeable and can be serialized and deserialized to/from a compact + * form.</p> + */ +package org.apache.datasketches.vector.decomposition; diff --git a/src/main/java/com/yahoo/sketches/vector/matrix/Matrix.java b/src/main/java/org/apache/datasketches/vector/matrix/Matrix.java similarity index 86% rename from src/main/java/com/yahoo/sketches/vector/matrix/Matrix.java rename to src/main/java/org/apache/datasketches/vector/matrix/Matrix.java index a1eb8ef..947bb1e 100644 --- a/src/main/java/com/yahoo/sketches/vector/matrix/Matrix.java +++ b/src/main/java/org/apache/datasketches/vector/matrix/Matrix.java @@ -1,17 +1,30 @@ /* - * Copyright 2017, Yahoo! Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root - * for terms. + * 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 com.yahoo.sketches.vector.matrix; +package org.apache.datasketches.vector.matrix; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.LS; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.LS; import org.ojalgo.matrix.store.PrimitiveDenseStore; -import com.yahoo.memory.Memory; -import com.yahoo.sketches.vector.MatrixFamily; +import org.apache.datasketches.memory.Memory; +import org.apache.datasketches.vector.MatrixFamily; /** * Provides an implementation-agnostic wrapper around Matrix classes. diff --git a/src/main/java/com/yahoo/sketches/vector/matrix/MatrixBuilder.java b/src/main/java/org/apache/datasketches/vector/matrix/MatrixBuilder.java similarity index 58% rename from src/main/java/com/yahoo/sketches/vector/matrix/MatrixBuilder.java rename to src/main/java/org/apache/datasketches/vector/matrix/MatrixBuilder.java index cbc7a39..059fc91 100644 --- a/src/main/java/com/yahoo/sketches/vector/matrix/MatrixBuilder.java +++ b/src/main/java/org/apache/datasketches/vector/matrix/MatrixBuilder.java @@ -1,10 +1,23 @@ /* - * Copyright 2017, Yahoo! Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root - * for terms. + * 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 com.yahoo.sketches.vector.matrix; +package org.apache.datasketches.vector.matrix; /** * Provides a builder for Matrix objects. diff --git a/src/main/java/com/yahoo/sketches/vector/matrix/MatrixImplOjAlgo.java b/src/main/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgo.java similarity index 78% rename from src/main/java/com/yahoo/sketches/vector/matrix/MatrixImplOjAlgo.java rename to src/main/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgo.java index 726f239..4bcc8f1 100644 --- a/src/main/java/com/yahoo/sketches/vector/matrix/MatrixImplOjAlgo.java +++ b/src/main/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgo.java @@ -1,26 +1,39 @@ /* - * Copyright 2017, Yahoo! Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root - * for terms. + * 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 com.yahoo.sketches.vector.matrix; +package org.apache.datasketches.vector.matrix; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.COMPACT_FLAG_MASK; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.extractFamilyID; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.extractFlags; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.extractNumColumns; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.extractNumColumnsUsed; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.extractNumRows; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.extractNumRowsUsed; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.extractPreLongs; -import static com.yahoo.sketches.vector.matrix.MatrixPreambleUtil.extractSerVer; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.COMPACT_FLAG_MASK; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.extractFamilyID; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.extractFlags; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.extractNumColumns; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.extractNumColumnsUsed; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.extractNumRows; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.extractNumRowsUsed; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.extractPreLongs; +import static org.apache.datasketches.vector.matrix.MatrixPreambleUtil.extractSerVer; import org.ojalgo.matrix.store.PrimitiveDenseStore; -import com.yahoo.memory.Memory; -import com.yahoo.memory.WritableMemory; -import com.yahoo.sketches.vector.MatrixFamily; +import org.apache.datasketches.memory.Memory; +import org.apache.datasketches.memory.WritableMemory; +import org.apache.datasketches.vector.MatrixFamily; public final class MatrixImplOjAlgo extends Matrix { private PrimitiveDenseStore mtx_; diff --git a/src/main/java/com/yahoo/sketches/vector/matrix/MatrixPreambleUtil.java b/src/main/java/org/apache/datasketches/vector/matrix/MatrixPreambleUtil.java similarity index 88% rename from src/main/java/com/yahoo/sketches/vector/matrix/MatrixPreambleUtil.java rename to src/main/java/org/apache/datasketches/vector/matrix/MatrixPreambleUtil.java index 8110b8f..efa79f1 100644 --- a/src/main/java/com/yahoo/sketches/vector/matrix/MatrixPreambleUtil.java +++ b/src/main/java/org/apache/datasketches/vector/matrix/MatrixPreambleUtil.java @@ -1,14 +1,28 @@ /* - * Copyright 2017, Yahoo, Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms. + * 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 com.yahoo.sketches.vector.matrix; +package org.apache.datasketches.vector.matrix; -import static com.yahoo.memory.UnsafeUtil.unsafe; +import static org.apache.datasketches.memory.UnsafeUtil.unsafe; -import com.yahoo.memory.Memory; -import com.yahoo.sketches.vector.MatrixFamily; +import org.apache.datasketches.memory.Memory; +import org.apache.datasketches.vector.MatrixFamily; /** * This class defines the preamble items structure and provides basic utilities for some of the diff --git a/src/main/java/org/apache/datasketches/vector/matrix/MatrixType.java b/src/main/java/org/apache/datasketches/vector/matrix/MatrixType.java new file mode 100644 index 0000000..f24acfa --- /dev/null +++ b/src/main/java/org/apache/datasketches/vector/matrix/MatrixType.java @@ -0,0 +1,39 @@ +/* + * 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.datasketches.vector.matrix; + +public enum MatrixType { + OJALGO(1, "ojAlgo"); + + private int id_; + private String name_; + + MatrixType(final int id, final String name) { + id_ = id; + name_ = name; + } + + public int getId() { return id_; } + + public String getName() { return name_; } + + @Override + public String toString() { return name_; } +} diff --git a/src/main/java/org/apache/datasketches/vector/matrix/package-info.java b/src/main/java/org/apache/datasketches/vector/matrix/package-info.java new file mode 100644 index 0000000..125d023 --- /dev/null +++ b/src/main/java/org/apache/datasketches/vector/matrix/package-info.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +/** + * <p>This package contains a Matrix class that wraps one of several underlying matrix + * implementations. It can be used to provide a stable public API independent of the + * specific linear algebra package used for computation.</p> + * + * <p>These Matrix objects can be serialized and deserialized to/from a compact form.</p> + */ +package org.apache.datasketches.vector.matrix; diff --git a/src/main/java/org/apache/datasketches/vector/package-info.java b/src/main/java/org/apache/datasketches/vector/package-info.java new file mode 100644 index 0000000..6a2db18 --- /dev/null +++ b/src/main/java/org/apache/datasketches/vector/package-info.java @@ -0,0 +1,24 @@ +/* + * 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. + */ + +/** + * This is the parent package for all vector sketch algorithms. Any classes at this level are + * used by more than one sub-package. + */ +package org.apache.datasketches.vector; diff --git a/src/test/java/com/yahoo/sketches/vector/matrix/MatrixBuilderTest.java b/src/test/java/com/yahoo/sketches/vector/matrix/MatrixBuilderTest.java deleted file mode 100644 index 4beb32b..0000000 --- a/src/test/java/com/yahoo/sketches/vector/matrix/MatrixBuilderTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2017, Yahoo! Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root - * for terms. - */ - -package com.yahoo.sketches.vector.matrix; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.testng.annotations.Test; - -public class MatrixBuilderTest { - @Test - public void checkBuild() { - final MatrixBuilder builder = new MatrixBuilder(); - assertEquals(builder.getBackingType(), MatrixType.OJALGO); // default type - - Matrix m = builder.build(128, 512); - assertNotNull(m); - - m = builder.build(128, 512); - assertNotNull(m); - } - - @Test - public void checkSetType() { - final MatrixBuilder builder = new MatrixBuilder(); - final MatrixType type = builder.getBackingType(); - assertEquals(type, MatrixType.OJALGO); // default type - assertEquals(type.getId(), MatrixType.OJALGO.getId()); - assertEquals(type.getName(), MatrixType.OJALGO.getName()); - } - -} diff --git a/src/test/java/com/yahoo/sketches/vector/decomposition/FrequentDirectionsTest.java b/src/test/java/org/apache/datasketches/vector/decomposition/FrequentDirectionsTest.java similarity index 90% rename from src/test/java/com/yahoo/sketches/vector/decomposition/FrequentDirectionsTest.java rename to src/test/java/org/apache/datasketches/vector/decomposition/FrequentDirectionsTest.java index d9485b3..df4e6d5 100644 --- a/src/test/java/com/yahoo/sketches/vector/decomposition/FrequentDirectionsTest.java +++ b/src/test/java/org/apache/datasketches/vector/decomposition/FrequentDirectionsTest.java @@ -1,9 +1,23 @@ /* - * Copyright 2017, Yahoo, Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms. + * 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 com.yahoo.sketches.vector.decomposition; +package org.apache.datasketches.vector.decomposition; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -15,10 +29,10 @@ import java.util.Arrays; import org.testng.annotations.Test; -import com.yahoo.memory.Memory; -import com.yahoo.memory.WritableMemory; -import com.yahoo.sketches.vector.MatrixFamily; -import com.yahoo.sketches.vector.matrix.Matrix; +import org.apache.datasketches.memory.Memory; +import org.apache.datasketches.memory.WritableMemory; +import org.apache.datasketches.vector.MatrixFamily; +import org.apache.datasketches.vector.matrix.Matrix; public class FrequentDirectionsTest { @Test diff --git a/src/test/java/com/yahoo/sketches/vector/decomposition/MatrixOpsTest.java b/src/test/java/org/apache/datasketches/vector/decomposition/MatrixOpsTest.java similarity index 76% rename from src/test/java/com/yahoo/sketches/vector/decomposition/MatrixOpsTest.java rename to src/test/java/org/apache/datasketches/vector/decomposition/MatrixOpsTest.java index b8ea789..d438d5c 100644 --- a/src/test/java/com/yahoo/sketches/vector/decomposition/MatrixOpsTest.java +++ b/src/test/java/org/apache/datasketches/vector/decomposition/MatrixOpsTest.java @@ -1,13 +1,32 @@ -package com.yahoo.sketches.vector.decomposition; +/* + * 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.datasketches.vector.decomposition; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; import org.testng.annotations.Test; -import com.yahoo.sketches.vector.matrix.Matrix; -import com.yahoo.sketches.vector.matrix.MatrixBuilder; -import com.yahoo.sketches.vector.matrix.MatrixType; +import org.apache.datasketches.vector.matrix.Matrix; +import org.apache.datasketches.vector.matrix.MatrixBuilder; +import org.apache.datasketches.vector.matrix.MatrixType; public class MatrixOpsTest { diff --git a/src/test/java/org/apache/datasketches/vector/matrix/MatrixBuilderTest.java b/src/test/java/org/apache/datasketches/vector/matrix/MatrixBuilderTest.java new file mode 100644 index 0000000..24feb17 --- /dev/null +++ b/src/test/java/org/apache/datasketches/vector/matrix/MatrixBuilderTest.java @@ -0,0 +1,49 @@ +/* + * 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.datasketches.vector.matrix; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.testng.annotations.Test; + +public class MatrixBuilderTest { + @Test + public void checkBuild() { + final MatrixBuilder builder = new MatrixBuilder(); + assertEquals(builder.getBackingType(), MatrixType.OJALGO); // default type + + Matrix m = builder.build(128, 512); + assertNotNull(m); + + m = builder.build(128, 512); + assertNotNull(m); + } + + @Test + public void checkSetType() { + final MatrixBuilder builder = new MatrixBuilder(); + final MatrixType type = builder.getBackingType(); + assertEquals(type, MatrixType.OJALGO); // default type + assertEquals(type.getId(), MatrixType.OJALGO.getId()); + assertEquals(type.getName(), MatrixType.OJALGO.getName()); + } + +} diff --git a/src/test/java/com/yahoo/sketches/vector/matrix/MatrixImplOjAlgoTest.java b/src/test/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgoTest.java similarity index 86% rename from src/test/java/com/yahoo/sketches/vector/matrix/MatrixImplOjAlgoTest.java rename to src/test/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgoTest.java index c745587..c1310d3 100644 --- a/src/test/java/com/yahoo/sketches/vector/matrix/MatrixImplOjAlgoTest.java +++ b/src/test/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgoTest.java @@ -1,9 +1,23 @@ /* - * Copyright 2017, Yahoo, Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms. + * 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 com.yahoo.sketches.vector.matrix; +package org.apache.datasketches.vector.matrix; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; @@ -11,8 +25,8 @@ import static org.testng.Assert.fail; import org.ojalgo.matrix.store.PrimitiveDenseStore; import org.testng.annotations.Test; -import com.yahoo.memory.Memory; -import com.yahoo.memory.WritableMemory; +import org.apache.datasketches.memory.Memory; +import org.apache.datasketches.memory.WritableMemory; public class MatrixImplOjAlgoTest { @Test diff --git a/src/test/java/com/yahoo/sketches/vector/matrix/MatrixTest.java b/src/test/java/org/apache/datasketches/vector/matrix/MatrixTest.java similarity index 82% rename from src/test/java/com/yahoo/sketches/vector/matrix/MatrixTest.java rename to src/test/java/org/apache/datasketches/vector/matrix/MatrixTest.java index 8be75cc..ca34bc0 100644 --- a/src/test/java/com/yahoo/sketches/vector/matrix/MatrixTest.java +++ b/src/test/java/org/apache/datasketches/vector/matrix/MatrixTest.java @@ -1,9 +1,23 @@ /* - * Copyright 2017, Yahoo, Inc. - * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms. + * 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 com.yahoo.sketches.vector.matrix; +package org.apache.datasketches.vector.matrix; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -13,9 +27,9 @@ import static org.testng.Assert.fail; import org.testng.annotations.Test; -import com.yahoo.memory.Memory; -import com.yahoo.memory.WritableMemory; -import com.yahoo.sketches.vector.MatrixFamily; +import org.apache.datasketches.memory.Memory; +import org.apache.datasketches.memory.WritableMemory; +import org.apache.datasketches.vector.MatrixFamily; public class MatrixTest { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
