From 159aecf60c150e797e4a8f809ad7952d97f610d1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 25 Jan 2019 12:03:39 +0100 Subject: [PATCH] Remove odl-triemap and related code This has been superseded by tech.pantheon.triemap, remove legacy wrappers. JIRA: YANGTOOLS-930 Change-Id: Ic93cef46ae75fcbcff10498e2383dfc6d1c3e0c2 Signed-off-by: Robert Varga --- artifacts/pom.xml | 12 - docs/pom.xml | 4 - features/features-yangtools/pom.xml | 6 - features/odl-triemap/pom.xml | 56 ----- .../odl-triemap/src/main/feature/feature.xml | 7 - .../src/main/feature/feature.xml | 2 +- .../src/main/feature/feature.xml | 2 +- .../src/main/feature/feature.xml | 2 +- .../src/main/feature/feature.xml | 2 +- features/odl-yangtools-util/pom.xml | 4 +- features/pom.xml | 1 - pom.xml | 1 - third-party/README.md | 2 - third-party/pom.xml | 29 --- third-party/triemap/LICENSE-2.0.html | 235 ------------------ third-party/triemap/README.md | 83 ------- third-party/triemap/pom.xml | 82 ------ .../yangtools/triemap/ImmutableTrieMap.java | 44 ---- .../yangtools/triemap/MutableTrieMap.java | 44 ---- .../yangtools/triemap/TrieMap.java | 206 --------------- .../yangtools/triemap/package-info.java | 20 -- .../yangtools/triemap/SnapshotTest.java | 70 ------ .../triemap/TestCNodeFlagCollision.java | 53 ---- .../TestCNodeInsertionIncorrectOrder.java | 38 --- .../yangtools/triemap/TestHashCollisions.java | 196 --------------- .../triemap/TestHashCollisionsRemove.java | 47 ---- .../TestHashCollisionsRemoveIterator.java | 50 ---- .../yangtools/triemap/TestInsert.java | 57 ----- .../triemap/TestMultiThreadAddDelete.java | 108 -------- .../triemap/TestMultiThreadInserts.java | 51 ---- .../triemap/TestMultiThreadMapIterator.java | 151 ----------- .../yangtools/triemap/TestSerialization.java | 54 ---- 32 files changed, 6 insertions(+), 1713 deletions(-) delete mode 100644 features/odl-triemap/pom.xml delete mode 100644 features/odl-triemap/src/main/feature/feature.xml delete mode 100644 third-party/README.md delete mode 100644 third-party/pom.xml delete mode 100644 third-party/triemap/LICENSE-2.0.html delete mode 100644 third-party/triemap/README.md delete mode 100644 third-party/triemap/pom.xml delete mode 100644 third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ImmutableTrieMap.java delete mode 100644 third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/MutableTrieMap.java delete mode 100644 third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java delete mode 100644 third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/package-info.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/SnapshotTest.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeFlagCollision.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeInsertionIncorrectOrder.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisions.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemove.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemoveIterator.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInsert.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadAddDelete.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadInserts.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadMapIterator.java delete mode 100644 third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestSerialization.java diff --git a/artifacts/pom.xml b/artifacts/pom.xml index b2c7c240bb..d2cff423f3 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -207,11 +207,6 @@ util 3.0.0-SNAPSHOT - - org.opendaylight.yangtools - triemap - 1.1.9-SNAPSHOT - @@ -244,13 +239,6 @@ - - org.opendaylight.yangtools - odl-triemap - 1.1.9-SNAPSHOT - xml - features - org.opendaylight.yangtools odl-yangtools-util diff --git a/docs/pom.xml b/docs/pom.xml index bc7ecf9bf7..4375c608de 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -162,10 +162,6 @@ org.opendaylight.yangtools util - - org.opendaylight.yangtools - triemap - org.opendaylight.yangtools diff --git a/features/features-yangtools/pom.xml b/features/features-yangtools/pom.xml index 97641c472a..5f5fd8c28c 100644 --- a/features/features-yangtools/pom.xml +++ b/features/features-yangtools/pom.xml @@ -36,12 +36,6 @@ - - org.opendaylight.yangtools - odl-triemap - features - xml - org.opendaylight.yangtools odl-yangtools-codec diff --git a/features/odl-triemap/pom.xml b/features/odl-triemap/pom.xml deleted file mode 100644 index e4aeb49b50..0000000000 --- a/features/odl-triemap/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.odlparent - single-feature-parent - 4.0.9 - - - - org.opendaylight.yangtools - odl-triemap - 1.1.9-SNAPSHOT - feature - OpenDaylight :: Yangtools :: TrieMap - Concurrent hash-trie implementation - - - - - org.opendaylight.yangtools - yangtools-artifacts - 3.0.0-SNAPSHOT - import - pom - - - - - - - org.opendaylight.odlparent - odl-guava - xml - features - - - tech.pantheon.triemap - pt-triemap - xml - features - - - org.opendaylight.yangtools - triemap - - - diff --git a/features/odl-triemap/src/main/feature/feature.xml b/features/odl-triemap/src/main/feature/feature.xml deleted file mode 100644 index e4ab6c8580..0000000000 --- a/features/odl-triemap/src/main/feature/feature.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - odl-guava - pt-triemap - - diff --git a/features/odl-yangtools-codec/src/main/feature/feature.xml b/features/odl-yangtools-codec/src/main/feature/feature.xml index c5b4a166af..ae0b23c45b 100644 --- a/features/odl-yangtools-codec/src/main/feature/feature.xml +++ b/features/odl-yangtools-codec/src/main/feature/feature.xml @@ -1,5 +1,5 @@ - + odl-gson odl-stax2-api diff --git a/features/odl-yangtools-data/src/main/feature/feature.xml b/features/odl-yangtools-data/src/main/feature/feature.xml index 06ec216935..e2c6308c78 100644 --- a/features/odl-yangtools-data/src/main/feature/feature.xml +++ b/features/odl-yangtools-data/src/main/feature/feature.xml @@ -1,5 +1,5 @@ - + odl-antlr4 diff --git a/features/odl-yangtools-exp-xpath-impl/src/main/feature/feature.xml b/features/odl-yangtools-exp-xpath-impl/src/main/feature/feature.xml index 4e0fb8a69e..b99ab09134 100644 --- a/features/odl-yangtools-exp-xpath-impl/src/main/feature/feature.xml +++ b/features/odl-yangtools-exp-xpath-impl/src/main/feature/feature.xml @@ -1,5 +1,5 @@ - + odl-antlr4 diff --git a/features/odl-yangtools-parser/src/main/feature/feature.xml b/features/odl-yangtools-parser/src/main/feature/feature.xml index 2d3d29e99a..b42a25e524 100644 --- a/features/odl-yangtools-parser/src/main/feature/feature.xml +++ b/features/odl-yangtools-parser/src/main/feature/feature.xml @@ -1,5 +1,5 @@ - + odl-antlr4 diff --git a/features/odl-yangtools-util/pom.xml b/features/odl-yangtools-util/pom.xml index 46687e4597..d08fba4f2a 100644 --- a/features/odl-yangtools-util/pom.xml +++ b/features/odl-yangtools-util/pom.xml @@ -37,8 +37,8 @@ - org.opendaylight.yangtools - odl-triemap + tech.pantheon.triemap + pt-triemap xml features diff --git a/features/pom.xml b/features/pom.xml index 199b3e5ca9..a1dbcac705 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -24,7 +24,6 @@ - odl-triemap odl-yangtools-codec odl-yangtools-common odl-yangtools-data-api diff --git a/pom.xml b/pom.xml index 20af9d1c59..43b40b2533 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,6 @@ features yang yang-validation-tool - third-party diff --git a/third-party/README.md b/third-party/README.md deleted file mode 100644 index ca71475a3f..0000000000 --- a/third-party/README.md +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains projects which have been seeded from external -source code. See individual projects for their specific licenses. diff --git a/third-party/pom.xml b/third-party/pom.xml deleted file mode 100644 index f8a4abd8f1..0000000000 --- a/third-party/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - org.opendaylight.odlparent - odlparent-lite - 4.0.9 - - - - 4.0.0 - org.opendaylight.yangtools - third-party-aggregator - 3.0.0-SNAPSHOT - pom - - - triemap - - - diff --git a/third-party/triemap/LICENSE-2.0.html b/third-party/triemap/LICENSE-2.0.html deleted file mode 100644 index 23208832f0..0000000000 --- a/third-party/triemap/LICENSE-2.0.html +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - - - Apache License, Version 2.0 - The Apache Software Foundation - - -

- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/ -

- -

- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -

- -

1. Definitions.

- -

- "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. -

- -

- "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. -

- -

- "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. -

- -

- "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. -

- -

- "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. -

- -

- "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. -

- -

- "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). -

- -

- "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. -

- -

- "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." -

- -

- "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. -

- -

2. Grant of Copyright License. - Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. -

- -

3. Grant of Patent License. - Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. -

- -

4. Redistribution. - You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: -

-
    -
  1. You must give any other recipients of the Work or - Derivative Works a copy of this License; and -

  2. - -
  3. You must cause any modified files to carry prominent notices - stating that You changed the files; and -

  4. - -
  5. You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and -

  6. - -
  7. If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. -
  8. -
-You may add Your own copyright statement to Your modifications and -may provide additional or different license terms and conditions -for use, reproduction, or distribution of Your modifications, or -for any such Derivative Works as a whole, provided Your use, -reproduction, and distribution of the Work otherwise complies with -the conditions stated in this License. - -

5. Submission of Contributions. - Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. -

- -

6. Trademarks. - This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. -

- -

7. Disclaimer of Warranty. - Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. -

- -

8. Limitation of Liability. - In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. -

- -

9. Accepting Warranty or Additional Liability. - While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. -

- -

- END OF TERMS AND CONDITIONS -

- - \ No newline at end of file diff --git a/third-party/triemap/README.md b/third-party/triemap/README.md deleted file mode 100644 index d1c3b566b2..0000000000 --- a/third-party/triemap/README.md +++ /dev/null @@ -1,83 +0,0 @@ -About -============================= - -This is a Java port of a concurrent trie hash map implementation from the Scala collections library. It is almost a line-by-line -conversion from Scala to Java. - -Idea + implementation techniques can be found in these reports written by Aleksandar Prokopec: - * http://infoscience.epfl.ch/record/166908/files/ctries-techreport.pdf - this is a nice introduction to Ctries, along with a correctness proof - * http://lamp.epfl.ch/~prokopec/ctries-snapshot.pdf - a more up-to-date writeup which describes the snapshot operation - -The original Scala implementation can be found here and is a part of scala.collection.concurrent: - * [Scala implementation](https://github.com/scala/scala/blob/930c85d6c96507d798d1847ea078eebf93dc0acb/src/library/scala/collection/concurrent/TrieMap.scala) - -Some of the tests and implementation details were borrowed from this project: - * https://github.com/flegall/concurrent-hash-trie - -Implementation status : - * The given implementation is complete and implements all features of the original Scala implementation including support for - snapshots. - * Wherever necessary, code was adapted to be more easily usable in Java, e.g. it returns Objects instead of Option as - many methods of Scala's collections do. - * This class implements all the ConcurrentMap & Iterator methods and passes all the tests. Can be used as a drop-in replacement - for usual Java maps, including ConcurrentHashMap. - - -What is a concurrent trie hash map also known as ctrie? -======================================================== -ctrie is a lock-Free Concurrent Hash Array Mapped Trie. - -A concurrent hash-trie or Ctrie is a concurrent thread-safe lock-free implementation of a hash array mapped trie. - -It is used to implement the concurrent map abstraction. It has particularly scalable concurrent insert and remove operations -and is memory-efficient. - -It supports O(1), atomic, lock-free snapshots which are used to implement linearizable lock-free size, iterator and clear operations. -The cost of evaluating the (lazy) snapshot is distributed across subsequent updates, thus making snapshot evaluation horizontally scalable. - -The original Scala-based implementation of the Ctrie is a part of the Scala standard library since the version 2.10. - -More info about Ctries: - -- http://infoscience.epfl.ch/record/166908/files/ctries-techreport.pdf - this is a nice introduction to Ctries, along with a correctness proof -- http://lamp.epfl.ch/~prokopec/ctries-snapshot.pdf - a more up-to-date writeup (more coherent with the current version of the code) which describes the snapshot operation - - -License -=============================== - -This library is licensed under the Apache 2.0 license. - - -Usage -=============================== - -Usage of this library is very simple. Simply import the class com.romix.scala.collection.concurrent.TrieMap and use it as a usual Map. - - import com.romix.scala.collection.concurrent.TrieMap; - - Map myMap = new TrieMap (); - myMap.put("key", "value"); - - -Building the library -=============================== - -Use a usual `mvn clean install` - -Using the library with Maven projects -===================================== -The prebuilt binaries of the library are available from Maven central. Please use the following dependency in your POM files: - - - com.github.romix - java-concurrent-hash-trie-map - 0.2.1 - - - -External dependencies -===================================== -This library is self-contained. It does not depend on any additional libraries. In particular, it does not require the rather big Scala's -standard library to be used. - diff --git a/third-party/triemap/pom.xml b/third-party/triemap/pom.xml deleted file mode 100644 index 1874fc76ca..0000000000 --- a/third-party/triemap/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - 4.0.0 - - org.opendaylight.yangtools - bundle-parent - 3.0.0-SNAPSHOT - ../../bundle-parent - - - triemap - 1.1.9-SNAPSHOT - bundle - - Java implementation of a concurrent trie hash map from Scala collections library - - - - tech.pantheon.triemap - triemap - - - com.google.guava - guava - - - - - - - maven-checkstyle-plugin - - checkstyle.violationSeverity=warning - - - - check-license - - check - - - - true - - - - - - com.github.spotbugs - spotbugs-maven-plugin - - true - - - - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - diff --git a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ImmutableTrieMap.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ImmutableTrieMap.java deleted file mode 100644 index fb267037cc..0000000000 --- a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ImmutableTrieMap.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -/** - * An immutable TrieMap. - * - * @author Robert Varga - * - * @param the type of keys maintained by this map - * @param the type of mapped values - * @deprecated use {@link tech.pantheon.triemap.ImmutableTrieMap} instead. - */ -@Deprecated -public final class ImmutableTrieMap extends TrieMap { - private static final long serialVersionUID = 1L; - - ImmutableTrieMap(final tech.pantheon.triemap.ImmutableTrieMap delegate) { - super(delegate); - } - - @Override - public TrieMap mutableSnapshot() { - return new MutableTrieMap<>(delegate().mutableSnapshot()); - } - - @Override - public ImmutableTrieMap immutableSnapshot() { - return this; - } -} diff --git a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/MutableTrieMap.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/MutableTrieMap.java deleted file mode 100644 index 31f749a6c2..0000000000 --- a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/MutableTrieMap.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -/** - * A mutable TrieMap. - * - * @author Robert Varga - * - * @param the type of keys maintained by this map - * @param the type of mapped values - * @deprecated use {@link tech.pantheon.triemap.MutableTrieMap} instead. - */ -@Deprecated -public final class MutableTrieMap extends TrieMap { - private static final long serialVersionUID = 1L; - - MutableTrieMap(final tech.pantheon.triemap.MutableTrieMap delegate) { - super(delegate); - } - - @Override - public ImmutableTrieMap immutableSnapshot() { - return new ImmutableTrieMap<>(delegate().immutableSnapshot()); - } - - @Override - public MutableTrieMap mutableSnapshot() { - return new MutableTrieMap<>(delegate().mutableSnapshot()); - } -} diff --git a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java deleted file mode 100644 index b5db32c495..0000000000 --- a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static java.util.Objects.requireNonNull; - -import com.google.common.collect.ForwardingObject; -import java.io.Serializable; -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentMap; -import java.util.function.BiFunction; -import java.util.function.Function; - -/** - * This is a port of Scala's TrieMap class from the Scala Collections library. This implementation does not support - * null keys nor null values. - * - * @author Aleksandar Prokopec (original Scala implementation) - * @author Roman Levenstein (original Java 6 port) - * @author Robert Varga - * - * @param the type of keys maintained by this map - * @param the type of mapped values - * @deprecated use {@link tech.pantheon.triemap.TrieMap} instead. - */ -@Deprecated -public abstract class TrieMap extends ForwardingObject implements ConcurrentMap, Serializable { - private static final long serialVersionUID = 1L; - - private final tech.pantheon.triemap.TrieMap delegate; - - TrieMap(final tech.pantheon.triemap.TrieMap delegate) { - this.delegate = requireNonNull(delegate); - } - - public static MutableTrieMap create() { - return new MutableTrieMap<>(tech.pantheon.triemap.TrieMap.create()); - } - - /** - * Returns a snapshot of this TrieMap. This operation is lock-free and - * linearizable. Modification operations on this Map and the returned one - * are isolated from each other. - * - *

- * The snapshot is lazily updated - the first time some branch in the - * snapshot or this TrieMap are accessed, they are rewritten. This means - * that the work of rebuilding both the snapshot and this TrieMap is - * distributed across all the threads doing updates or accesses subsequent - * to the snapshot creation. - * - * @return A read-write TrieMap containing the contents of this map. - */ - public abstract TrieMap mutableSnapshot(); - - /** - * Returns a read-only snapshot of this TrieMap. This operation is lock-free - * and linearizable. - * - *

- * The snapshot is lazily updated - the first time some branch of this - * TrieMap are accessed, it is rewritten. The work of creating the snapshot - * is thus distributed across subsequent updates and accesses on this - * TrieMap by all threads. Note that the snapshot itself is never rewritten - * unlike when calling {@link #mutableSnapshot()}, but the obtained snapshot - * cannot be modified. - * - *

- * This method is used by other methods such as `size` and `iterator`. - * - * @return A read-only TrieMap containing the contents of this map. - */ - public abstract ImmutableTrieMap immutableSnapshot(); - - @Override - public final boolean containsKey(final Object key) { - return delegate.containsKey(key); - } - - @Override - public final boolean containsValue(final Object value) { - return delegate.containsValue(value); - } - - @Override - public final Set> entrySet() { - return delegate.entrySet(); - } - - @Override - public final Set keySet() { - return delegate.keySet(); - } - - @Override - public final V get(final Object key) { - return delegate.get(key); - } - - @Override - public final void clear() { - delegate.clear(); - } - - @Override - public final V put(final K key, final V value) { - return delegate.put(key, value); - } - - @Override - public final V putIfAbsent(final K key, final V value) { - return delegate.putIfAbsent(key, value); - } - - @Override - public final V remove(final Object key) { - return delegate.remove(key); - } - - @Override - public final boolean remove(final Object key, final Object value) { - return delegate.remove(key, value); - } - - @Override - public final boolean replace(final K key, final V oldValue, final V newValue) { - return delegate.replace(key, oldValue, newValue); - } - - @Override - public final V replace(final K key, final V value) { - return delegate.replace(key, value); - } - - @Override - public final int size() { - return delegate.size(); - } - - @Override - public final boolean isEmpty() { - return delegate.isEmpty(); - } - - @Override - public final void putAll(final Map m) { - delegate.putAll(m); - } - - @Override - public final Collection values() { - return delegate.values(); - } - - @Override - public final V compute(final K key, final BiFunction remappingFunction) { - return delegate.compute(key, remappingFunction); - } - - @Override - public final V computeIfAbsent(final K key, final Function mappingFunction) { - return delegate.computeIfAbsent(key, mappingFunction); - } - - @Override - public final V computeIfPresent(final K key, - final BiFunction remappingFunction) { - return delegate.computeIfPresent(key, remappingFunction); - } - - @Override - public final V merge(final K key, final V value, - final BiFunction remappingFunction) { - return delegate.merge(key, value, remappingFunction); - } - - @Override - public final int hashCode() { - return delegate.hashCode(); - } - - @Override - public final boolean equals(final Object o) { - return delegate.equals(o); - } - - @Override - protected final tech.pantheon.triemap.TrieMap delegate() { - return delegate; - } -} diff --git a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/package-info.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/package-info.java deleted file mode 100644 index c0139bd641..0000000000 --- a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * (C) Copyright 2017 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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. - */ -/** - * Implementation of {@link java.util.Map} on top - * of a concurrent hash-trie. - */ -package org.opendaylight.yangtools.triemap; diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/SnapshotTest.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/SnapshotTest.java deleted file mode 100644 index a77ab91aa8..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/SnapshotTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * (C) Copyright 2017 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.Map; -import org.junit.Before; -import org.junit.Test; - -@Deprecated -public class SnapshotTest { - private TrieMap map; - - @Before - public void setUp() { - map = TrieMap.create(); - map.put("k1", "v1"); - map.put("k2", "v2"); - } - - private static void assertMutableIsolation(final Map m1, final Map m2) { - assertTrue(m2.containsKey("k1")); - assertTrue(m2.containsKey("k2")); - - m1.remove("k1"); - assertFalse(m1.containsKey("k1")); - assertTrue(m2.containsKey("k1")); - - m2.remove("k2"); - assertFalse(m1.containsKey("k1")); - assertTrue(m2.containsKey("k1")); - - assertEquals(1, m1.size()); - assertEquals(1, m2.size()); - } - - @Test - public void testMutableSnapshotIsolation() { - assertMutableIsolation(map, map.mutableSnapshot()); - } - - @Test - public void testMutableSnapshotIsolationAcrossImmutable() { - final TrieMap snap = map.immutableSnapshot(); - assertTrue(snap.containsKey("k1")); - assertTrue(snap.containsKey("k2")); - - assertMutableIsolation(map, snap.mutableSnapshot()); - - assertTrue(snap.containsKey("k1")); - assertTrue(snap.containsKey("k2")); - - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeFlagCollision.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeFlagCollision.java deleted file mode 100644 index c5d5ca6d2d..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeFlagCollision.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; - -import java.util.Map; -import org.junit.Test; - -@Deprecated -public class TestCNodeFlagCollision { - @Test - public void testCNodeFlagCollision() { - final Map map = TrieMap.create(); - final Integer z15169 = Integer.valueOf(15169); - final Integer z28336 = Integer.valueOf(28336); - - assertNull(map.get(z15169)); - assertNull(map.get(z28336)); - - map.put(z15169, z15169); - assertSame(z15169, map.get(z15169)); - assertNull(map.get(z28336)); - - map.put(z28336, z28336); - assertSame(z15169, map.get(z15169)); - assertSame(z28336, map.get(z28336)); - - map.remove(z15169); - - assertNull(map.get(z15169)); - assertSame(z28336, map.get(z28336)); - - map.remove(z28336); - - assertNull(map.get(z15169)); - assertNull(map.get(z28336)); - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeInsertionIncorrectOrder.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeInsertionIncorrectOrder.java deleted file mode 100644 index 9d34781f4a..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeInsertionIncorrectOrder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertSame; - -import java.util.Map; -import org.junit.Test; - -@Deprecated -public class TestCNodeInsertionIncorrectOrder { - - @Test - public void testCNodeInsertionIncorrectOrder() { - final Map map = TrieMap.create(); - final Integer z3884 = Integer.valueOf(3884); - final Integer z4266 = Integer.valueOf(4266); - map.put(z3884, z3884); - assertSame(z3884, map.get(z3884)); - - map.put(z4266, z4266); - assertSame(z3884, map.get(z3884)); - assertSame(z4266, map.get(z4266)); - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisions.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisions.java deleted file mode 100644 index 2135af380c..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisions.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -@Deprecated -public class TestHashCollisions { - @Test - public void testHashCollisions() { - final TrieMap bt = TrieMap.create(); - - insertStrings(bt); - insertChars(bt); - insertInts(bt); - insertBytes(bt); - - removeStrings(bt); - removeChars(bt); - removeInts(bt); - removeBytes(bt); - - insertStrings(bt); - insertInts(bt); - insertBytes(bt); - insertChars(bt); - - removeBytes(bt); - removeStrings(bt); - removeChars(bt); - removeInts(bt); - - insertStrings(bt); - insertInts(bt); - insertBytes(bt); - insertChars(bt); - - removeStrings(bt); - removeChars(bt); - removeInts(bt); - removeBytes(bt); - - insertStrings(bt); - insertInts(bt); - insertBytes(bt); - insertChars(bt); - - removeChars(bt); - removeInts(bt); - removeBytes(bt); - removeStrings(bt); - - insertStrings(bt); - insertInts(bt); - insertBytes(bt); - insertChars(bt); - - removeInts(bt); - removeBytes(bt); - removeStrings(bt); - removeChars(bt); - } - - private static void insertChars(final TrieMap bt) { - assertNull(bt.put('a', 'a')); - assertNull(bt.put('b', 'b')); - assertNull(bt.put('c', 'c')); - assertNull(bt.put('d', 'd')); - assertNull(bt.put('e', 'e')); - - assertEquals('a', bt.put('a', 'a')); - assertEquals('b', bt.put('b', 'b')); - assertEquals('c', bt.put('c', 'c')); - assertEquals('d', bt.put('d', 'd')); - assertEquals('e', bt.put('e', 'e')); - } - - private static void insertStrings(final TrieMap bt) { - assertNull(bt.put("a", "a")); - assertNull(bt.put("b", "b")); - assertNull(bt.put("c", "c")); - assertNull(bt.put("d", "d")); - assertNull(bt.put("e", "e")); - - assertEquals("a", bt.put("a", "a")); - assertEquals("b", bt.put("b", "b")); - assertEquals("c", bt.put("c", "c")); - assertEquals("d", bt.put("d", "d")); - assertEquals("e", bt.put("e", "e")); - } - - private static void insertBytes(final TrieMap bt) { - for (byte i = 0; i < 128 && i >= 0; i++) { - final Byte bigB = Byte.valueOf(i); - assertNull(bt.put(bigB, bigB)); - assertEquals(bigB, bt.put(bigB, bigB)); - } - } - - private static void insertInts(final TrieMap bt) { - for (int i = 0; i < 128; i++) { - final Integer bigI = Integer.valueOf(i); - assertNull(bt.put(bigI, bigI)); - assertEquals(bigI, bt.put(bigI, bigI)); - } - } - - private static void removeChars(final TrieMap bt) { - assertNotNull(bt.get('a')); - assertNotNull(bt.get('b')); - assertNotNull(bt.get('c')); - assertNotNull(bt.get('d')); - assertNotNull(bt.get('e')); - - assertNotNull(bt.remove('a')); - assertNotNull(bt.remove('b')); - assertNotNull(bt.remove('c')); - assertNotNull(bt.remove('d')); - assertNotNull(bt.remove('e')); - - assertNull(bt.remove('a')); - assertNull(bt.remove('b')); - assertNull(bt.remove('c')); - assertNull(bt.remove('d')); - assertNull(bt.remove('e')); - - assertNull(bt.get('a')); - assertNull(bt.get('b')); - assertNull(bt.get('c')); - assertNull(bt.get('d')); - assertNull(bt.get('e')); - } - - private static void removeStrings(final TrieMap bt) { - assertNotNull(bt.get("a")); - assertNotNull(bt.get("b")); - assertNotNull(bt.get("c")); - assertNotNull(bt.get("d")); - assertNotNull(bt.get("e")); - - assertNotNull(bt.remove("a")); - assertNotNull(bt.remove("b")); - assertNotNull(bt.remove("c")); - assertNotNull(bt.remove("d")); - assertNotNull(bt.remove("e")); - - assertNull(bt.remove("a")); - assertNull(bt.remove("b")); - assertNull(bt.remove("c")); - assertNull(bt.remove("d")); - assertNull(bt.remove("e")); - - assertNull(bt.get("a")); - assertNull(bt.get("b")); - assertNull(bt.get("c")); - assertNull(bt.get("d")); - assertNull(bt.get("e")); - } - - private static void removeInts(final TrieMap bt) { - for (int i = 0; i < 128; i++) { - final Integer bigI = Integer.valueOf(i); - assertNotNull(bt.get(bigI)); - assertNotNull(bt.remove(bigI)); - assertNull(bt.remove(bigI)); - assertNull(bt.get(bigI)); - } - } - - private static void removeBytes(final TrieMap bt) { - for (byte i = 0; i < 128 && i >= 0; i++) { - final Byte bigB = Byte.valueOf(i); - assertNotNull(bt.get(bigB)); - assertNotNull(bt.remove(bigB)); - assertNull(bt.remove(bigB)); - assertNull(bt.get(bigB)); - } - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemove.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemove.java deleted file mode 100644 index 7d0962471d..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemove.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.Map; -import org.junit.Test; - -@Deprecated -public class TestHashCollisionsRemove { - private static final int COUNT = 50000; - - @Test - public void testHashCollisionsRemove() { - final Map bt = TrieMap.create(); - - for (int j = 0; j < COUNT; j++) { - for (final Object o : TestMultiThreadMapIterator.getObjects(j)) { - bt.put(o, o); - } - } - - for (int j = 0; j < COUNT; j++) { - for (final Object o : TestMultiThreadMapIterator.getObjects(j)) { - bt.remove(o); - } - } - - assertEquals(0, bt.size()); - assertTrue(bt.isEmpty()); - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemoveIterator.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemoveIterator.java deleted file mode 100644 index 37f234eb00..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemoveIterator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import org.junit.Test; - -@Deprecated -public class TestHashCollisionsRemoveIterator { - private static final int COUNT = 50000; - - @Test - public void testHashCollisionsRemoveIterator() { - final Map bt = TrieMap.create(); - for (int j = 0; j < COUNT; j++) { - bt.put(Integer.valueOf(j), Integer.valueOf(j)); - } - - final Collection list = new ArrayList<>(COUNT); - final Iterator> it = bt.entrySet().iterator(); - while (it.hasNext()) { - list.add(it.next().getKey()); - it.remove(); - } - - assertEquals(0, bt.size()); - assertTrue(bt.isEmpty()); - assertEquals(COUNT, list.size()); - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInsert.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInsert.java deleted file mode 100644 index 138b29e068..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInsert.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -@Deprecated -public class TestInsert { - @Test - public void testInsert() { - final TrieMap bt = TrieMap.create(); - assertNull(bt.put("a", "a")); - assertNull(bt.put("b", "b")); - assertNull(bt.put("c", "b")); - assertNull(bt.put("d", "b")); - assertNull(bt.put("e", "b")); - - for (int i = 0; i < 10000; i++) { - assertNull(bt.put(Integer.valueOf(i), Integer.valueOf(i))); - final Object lookup = bt.get(Integer.valueOf(i)); - assertEquals(Integer.valueOf(i), lookup); - } - - bt.toString(); - } - - @Test(expected = NullPointerException.class) - public void testNullKey() { - TrieMap.create().put(null, ""); - } - - @Test(expected = NullPointerException.class) - public void testNullValue() { - TrieMap.create().put("", null); - } - - @Test(expected = NullPointerException.class) - public void testNullBoth() { - TrieMap.create().put(null, null); - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadAddDelete.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadAddDelete.java deleted file mode 100644 index bbfe70ed3d..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadAddDelete.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class TestMultiThreadAddDelete { - private static final Logger LOG = LoggerFactory.getLogger(TestMultiThreadAddDelete.class); - private static final int RETRIES = 1; - private static final int N_THREADS = 7; - private static final int COUNT = 50 * 1000; - - @Test - public void testMultiThreadAddDelete() throws InterruptedException { - for (int j = 0; j < RETRIES; j++) { - final Map bt = TrieMap.create(); - - { - final ExecutorService es = Executors.newFixedThreadPool(N_THREADS); - for (int i = 0; i < N_THREADS; i++) { - final int threadNo = i; - es.execute(() -> { - for (int k = 0; k < COUNT; k++) { - if (k % N_THREADS == threadNo) { - bt.put(Integer.valueOf(k), Integer.valueOf(k)); - } - } - }); - } - es.shutdown(); - es.awaitTermination(5, TimeUnit.MINUTES); - } - - assertEquals(COUNT, bt.size()); - assertFalse(bt.isEmpty()); - - { - final ExecutorService es = Executors.newFixedThreadPool(N_THREADS); - for (int i = 0; i < N_THREADS; i++) { - final int threadNo = i; - es.execute(() -> { - for (int k = 0; k < COUNT; k++) { - if (k % N_THREADS == threadNo) { - bt.remove(Integer.valueOf(k)); - } - } - }); - } - es.shutdown(); - es.awaitTermination(5, TimeUnit.MINUTES); - } - - - assertEquals(0, bt.size()); - assertTrue(bt.isEmpty()); - - { - final ExecutorService es = Executors.newFixedThreadPool(N_THREADS); - for (int i = 0; i < N_THREADS; i++) { - final int threadNo = i; - es.execute(() -> { - for (int j1 = 0; j1 < COUNT; j1++) { - if (j1 % N_THREADS == threadNo) { - bt.put(Integer.valueOf(j1), Integer.valueOf(j1)); - if (!bt.containsKey(Integer.valueOf(j1))) { - LOG.error("Key {} not present", j1); - } - bt.remove(Integer.valueOf(j1)); - if (bt.containsKey(Integer.valueOf(j1))) { - LOG.error("Key {} is still present", j1); - } - } - } - }); - } - es.shutdown(); - es.awaitTermination(5, TimeUnit.MINUTES); - } - - assertEquals(0, bt.size()); - assertTrue(bt.isEmpty()); - } - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadInserts.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadInserts.java deleted file mode 100644 index d775e074fd..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadInserts.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertEquals; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import org.junit.Test; - -@Deprecated -public class TestMultiThreadInserts { - @Test - public void testMultiThreadInserts() throws InterruptedException { - final int nThreads = 2; - final ExecutorService es = Executors.newFixedThreadPool(nThreads); - final TrieMap bt = TrieMap.create(); - for (int i = 0; i < nThreads; i++) { - final int threadNo = i; - es.execute(() -> { - for (int j = 0; j < 500 * 1000; j++) { - if (j % nThreads == threadNo) { - bt.put(Integer.valueOf(j), Integer.valueOf(j)); - } - } - }); - } - - es.shutdown(); - es.awaitTermination(5, TimeUnit.MINUTES); - - for (int j = 0; j < 500 * 1000; j++) { - final Object lookup = bt.get(Integer.valueOf(j)); - assertEquals(Integer.valueOf(j), lookup); - } - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadMapIterator.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadMapIterator.java deleted file mode 100644 index 1e2e1f9ecd..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadMapIterator.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class TestMultiThreadMapIterator { - private static final Logger LOG = LoggerFactory.getLogger(TestMultiThreadMapIterator.class); - private static final int NTHREADS = 7; - - @Test - public void testMultiThreadMapIterator() throws InterruptedException { - final Map bt = TrieMap.create(); - for (int j = 0; j < 50 * 1000; j++) { - for (final Object o : getObjects(j)) { - bt.put(o, o); - } - } - - LOG.debug("Size of initialized map is {}", bt.size()); - int count = 0; - { - final ExecutorService es = Executors.newFixedThreadPool(NTHREADS); - for (int i = 0; i < NTHREADS; i++) { - final int threadNo = i; - es.execute(() -> { - for (Entry e : bt.entrySet()) { - if (accepts(threadNo, NTHREADS, e.getKey())) { - String newValue = "TEST:" + threadNo; - e.setValue(newValue); - } - } - }); - } - - es.shutdown(); - es.awaitTermination(5, TimeUnit.MINUTES); - } - - count = 0; - for (final Map.Entry kv : bt.entrySet()) { - assertTrue(kv.getValue() instanceof String); - count++; - } - assertEquals(50000 + 2000 + 1000 + 100, count); - - final ConcurrentHashMap removed = new ConcurrentHashMap<>(); - { - final ExecutorService es = Executors.newFixedThreadPool(NTHREADS); - for (int i = 0; i < NTHREADS; i++) { - final int threadNo = i; - es.execute(() -> { - for (final Iterator> it = bt.entrySet().iterator(); it.hasNext();) { - final Entry e = it.next(); - Object key = e.getKey(); - if (accepts(threadNo, NTHREADS, key)) { - if (null == bt.get(key)) { - LOG.error("Key {} is not present", key); - } - it.remove(); - if (null != bt.get(key)) { - LOG.error("Key {} is still present", key); - } - removed.put(key, key); - } - } - }); - } - - es.shutdown(); - es.awaitTermination(5, TimeUnit.MINUTES); - } - - count = 0; - for (final Object value : bt.keySet()) { - value.toString(); - count++; - } - for (final Object o : bt.keySet()) { - if (!removed.contains(bt.get(o))) { - LOG.error("Not removed: {}", o); - } - } - assertEquals(0, count); - assertEquals(0, bt.size()); - assertTrue(bt.isEmpty()); - } - - protected static boolean accepts(final int threadNo, final int nrThreads, final Object key) { - final int val = getKeyValue(key); - return val >= 0 ? val % nrThreads == threadNo : false; - } - - private static int getKeyValue(final Object key) { - if (key instanceof Integer) { - return ((Integer) key).intValue(); - } else if (key instanceof Character) { - return Math.abs(Character.getNumericValue((Character) key) + 1); - } else if (key instanceof Short) { - return ((Short) key).intValue() + 2; - } else if (key instanceof Byte) { - return ((Byte) key).intValue() + 3; - } else { - return -1; - } - } - - static Collection getObjects(final int j) { - final Collection results = new ArrayList<>(4); - results.add(Integer.valueOf(j)); - if (j < 2000) { - results.add(Character.valueOf((char) j)); - } - if (j < 1000) { - results.add(Short.valueOf((short) j)); - } - if (j < 100) { - results.add(Byte.valueOf((byte) j)); - } - - return results; - } -} diff --git a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestSerialization.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestSerialization.java deleted file mode 100644 index 45c01e4ace..0000000000 --- a/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestSerialization.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others. - * - * Licensed 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.opendaylight.yangtools.triemap; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import org.junit.Assert; -import org.junit.Test; - -@Deprecated -public class TestSerialization { - @Test - public void testSerialization() throws IOException, ClassNotFoundException { - TrieMap map = TrieMap.create(); - - map.put("dude-0", "tom"); - map.put("dude-1", "john"); - map.put("dude-3", "ravi"); - map.put("dude-4", "alex"); - - TrieMap expected = map.immutableSnapshot(); - - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - final ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(expected); - oos.close(); - - final byte[] bytes = bos.toByteArray(); - final ByteArrayInputStream bis = new ByteArrayInputStream(bytes); - final ObjectInputStream ois = new ObjectInputStream(bis); - - @SuppressWarnings("unchecked") - final TrieMap actual = (TrieMap) ois.readObject(); - ois.close(); - - Assert.assertEquals(expected, actual); - } -} -- 2.36.6