[GitHub] [commons-geometry] acid1103 commented on a change in pull request #39: GEOMETRY-46: Add additional UnitVector methods

2019-09-24 Thread GitBox
acid1103 commented on a change in pull request #39: GEOMETRY-46: Add additional 
UnitVector methods
URL: https://github.com/apache/commons-geometry/pull/39#discussion_r327889925
 
 

 ##
 File path: 
commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
 ##
 @@ -120,6 +130,16 @@ public void testNormSq() {
 Assert.assertEquals(9.0, Vector1D.of(-3).normSq(), TEST_TOLERANCE);
 }
 
+@Test
+public void testNormSq_unitVectors()
+{
 
 Review comment:
   I thought I caught all those, but I must have missed that file. Should be 
fixed now :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Commented] (GEOMETRY-46) Additional UnitVector methods

2019-09-24 Thread Matt Juntunen (Jira)


[ 
https://issues.apache.org/jira/browse/GEOMETRY-46?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16937286#comment-16937286
 ] 

Matt Juntunen commented on GEOMETRY-46:
---

This PR is ready to go.

> Additional UnitVector methods
> -
>
> Key: GEOMETRY-46
> URL: https://issues.apache.org/jira/browse/GEOMETRY-46
> Project: Apache Commons Geometry
>  Issue Type: Improvement
>Reporter: Matt Juntunen
>Priority: Minor
>  Labels: easyfix, pull-request-available, starter
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> The following methods should be overridden in the {{UnitVector}} private 
> subclasses of the {{Vector?D}} classes:
> * {{normSq}} -- should return {{1}} for consistency with {{norm}}
> * {{negate}} -- should be overridden to also return a {{UnitVector}} instance 
> instead of a regular {{Vector?D}} 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (POOL-376) invalidateObject should not return NullPointerException

2019-09-24 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/POOL-376?focusedWorklogId=317927=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-317927
 ]

ASF GitHub Bot logged work on POOL-376:
---

Author: ASF GitHub Bot
Created on: 25/Sep/19 00:28
Start Date: 25/Sep/19 00:28
Worklog Time Spent: 10m 
  Work Description: psteitz commented on pull request #24: POOL-376 
invalidateObject should not throw NPE
URL: https://github.com/apache/commons-pool/pull/24
 
 
   
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 317927)
Time Spent: 0.5h  (was: 20m)

> invalidateObject should not return NullPointerException
> ---
>
> Key: POOL-376
> URL: https://issues.apache.org/jira/browse/POOL-376
> Project: Commons Pool
>  Issue Type: Bug
>Affects Versions: 2.6.2
>Reporter: M Sazzadul Hoque
>Priority: Critical
>  Labels: pull-request-available, pull-requests-available
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {{GenericObjectPool.invalidateObject(T obj)}} should not return 
> {{NullPointerException}} when obj is not null.
> Please see following stack trace:
> {code:java}
> Caused by: java.lang.NullPointerException
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.putLast(LinkedBlockingDeque.java:454)
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.put(LinkedBlockingDeque.java:788)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.destroy(GenericObjectPool.java:939)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.invalidateObject(GenericObjectPool.java:618)
> {code}
> Apparent reason: In {{destroy(PooledObject toDestroy)}}, create() may 
> return null even though {{toDestroy}} is already destroyed.
> *Please make the fix available for JDK 1.7.*



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (POOL-356) deadlock if borrowObject gets called to fast and maxIdle is 0

2019-09-24 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/POOL-356?focusedWorklogId=317926=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-317926
 ]

ASF GitHub Bot logged work on POOL-356:
---

Author: ASF GitHub Bot
Created on: 25/Sep/19 00:28
Start Date: 25/Sep/19 00:28
Worklog Time Spent: 10m 
  Work Description: psteitz commented on pull request #25: POOL-356 and 
POOL-376
URL: https://github.com/apache/commons-pool/pull/25
 
 
   
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 317926)
Time Spent: 1h  (was: 50m)

> deadlock if borrowObject gets called to fast and maxIdle is 0
> -
>
> Key: POOL-356
> URL: https://issues.apache.org/jira/browse/POOL-356
> Project: Commons Pool
>  Issue Type: Bug
>Affects Versions: 2.6.0
>Reporter: Mark Struberg
>Assignee: Mark Struberg
>Priority: Major
> Fix For: 2.6.1
>
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> I figured this while creating a unit test for OpenJPA. But also did see this 
> in real production with commons-dbcp2. See DBCP-513 for more info.
> See this comment for a precise explanation what happens 
> https://issues.apache.org/jira/browse/DBCP-513?focusedCommentId=16660545=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16660545
> The problem is basically that the logic to immediately destroy a pool object 
> does not notify the DeLinkedQueue:
> {code}
> if (isClosed() || maxIdleSave > -1 && maxIdleSave <= 
> idleObjects.size()) {
> try {
> destroy(p);
> {code}
> But the borrowObject code is locking on that condition...
> {code}
> if (borrowMaxWaitMillis < 0) {
> p = idleObjects.takeFirst();
> } 
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-pool] psteitz merged pull request #25: POOL-356 and POOL-376

2019-09-24 Thread GitBox
psteitz merged pull request #25: POOL-356 and POOL-376
URL: https://github.com/apache/commons-pool/pull/25
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-pool] psteitz closed pull request #24: POOL-376 invalidateObject should not throw NPE

2019-09-24 Thread GitBox
psteitz closed pull request #24: POOL-376 invalidateObject should not throw NPE
URL: https://github.com/apache/commons-pool/pull/24
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-geometry] darkma773r commented on a change in pull request #39: GEOMETRY-46: Add additional UnitVector methods

2019-09-24 Thread GitBox
darkma773r commented on a change in pull request #39: GEOMETRY-46: Add 
additional UnitVector methods
URL: https://github.com/apache/commons-geometry/pull/39#discussion_r327887113
 
 

 ##
 File path: 
commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
 ##
 @@ -565,5 +571,11 @@ public Vector2D normalize() {
 public Vector2D withNorm(final double mag) {
 return multiply(mag);
 }
+
+/** {@inheritDoc} */
+@Override
+public UnitVector negate() {
+return new UnitVector(-super.x, -super.y);
 
 Review comment:
   I will defer to the compiler, in that case:-)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-geometry] acid1103 commented on a change in pull request #39: GEOMETRY-46: Add additional UnitVector methods

2019-09-24 Thread GitBox
acid1103 commented on a change in pull request #39: GEOMETRY-46: Add additional 
UnitVector methods
URL: https://github.com/apache/commons-geometry/pull/39#discussion_r327886108
 
 

 ##
 File path: 
commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
 ##
 @@ -565,5 +571,11 @@ public Vector2D normalize() {
 public Vector2D withNorm(final double mag) {
 return multiply(mag);
 }
+
+/** {@inheritDoc} */
+@Override
+public UnitVector negate() {
+return new UnitVector(-super.x, -super.y);
 
 Review comment:
   Removing super doesn't work, as the compiler thinks we're trying to access 
VectorXD.x statically, and using `this.x` doesn't work, as the compiler 
complains about VectorXD.x being private.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Commented] (GEOMETRY-60) JDK 13 Build Fails

2019-09-24 Thread Matt Juntunen (Jira)


[ 
https://issues.apache.org/jira/browse/GEOMETRY-60?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16937271#comment-16937271
 ] 

Matt Juntunen commented on GEOMETRY-60:
---

So, what changes are you proposing here? I'd like to get our github build 
passing again.

> JDK 13 Build Fails
> --
>
> Key: GEOMETRY-60
> URL: https://issues.apache.org/jira/browse/GEOMETRY-60
> Project: Apache Commons Geometry
>  Issue Type: Bug
>Reporter: Matt Juntunen
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> The build for JDK 13 is failing on Travis.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GEOMETRY-46) Additional UnitVector methods

2019-09-24 Thread Matt Juntunen (Jira)


[ 
https://issues.apache.org/jira/browse/GEOMETRY-46?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16937269#comment-16937269
 ] 

Matt Juntunen commented on GEOMETRY-46:
---

I added some small comments in github on the PR related to style. 
Unfortunately, our github build is broken on jdk 13+ so we don't get a green 
light on it. [~erans], are you okay with merging anyway?

> Additional UnitVector methods
> -
>
> Key: GEOMETRY-46
> URL: https://issues.apache.org/jira/browse/GEOMETRY-46
> Project: Apache Commons Geometry
>  Issue Type: Improvement
>Reporter: Matt Juntunen
>Priority: Minor
>  Labels: easyfix, pull-request-available, starter
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> The following methods should be overridden in the {{UnitVector}} private 
> subclasses of the {{Vector?D}} classes:
> * {{normSq}} -- should return {{1}} for consistency with {{norm}}
> * {{negate}} -- should be overridden to also return a {{UnitVector}} instance 
> instead of a regular {{Vector?D}} 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-geometry] darkma773r commented on issue #39: GEOMETRY-46: Add additional UnitVector methods

2019-09-24 Thread GitBox
darkma773r commented on issue #39: GEOMETRY-46: Add additional UnitVector 
methods
URL: https://github.com/apache/commons-geometry/pull/39#issuecomment-534791241
 
 
   I don't think any more tests are necessary since the changes are so simple.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-geometry] darkma773r commented on issue #39: GEOMETRY-46: Add additional UnitVector methods

2019-09-24 Thread GitBox
darkma773r commented on issue #39: GEOMETRY-46: Add additional UnitVector 
methods
URL: https://github.com/apache/commons-geometry/pull/39#issuecomment-534790726
 
 
   Thanks for the PR! I added a couple of nit-picky comments but it otherwise 
looks great.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-geometry] darkma773r commented on a change in pull request #39: GEOMETRY-46: Add additional UnitVector methods

2019-09-24 Thread GitBox
darkma773r commented on a change in pull request #39: GEOMETRY-46: Add 
additional UnitVector methods
URL: https://github.com/apache/commons-geometry/pull/39#discussion_r327879599
 
 

 ##
 File path: 
commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
 ##
 @@ -565,5 +571,11 @@ public Vector2D normalize() {
 public Vector2D withNorm(final double mag) {
 return multiply(mag);
 }
+
+/** {@inheritDoc} */
+@Override
+public UnitVector negate() {
+return new UnitVector(-super.x, -super.y);
 
 Review comment:
   Can we remove the super here? Same in the other classes.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-geometry] darkma773r commented on a change in pull request #39: GEOMETRY-46: Add additional UnitVector methods

2019-09-24 Thread GitBox
darkma773r commented on a change in pull request #39: GEOMETRY-46: Add 
additional UnitVector methods
URL: https://github.com/apache/commons-geometry/pull/39#discussion_r327879251
 
 

 ##
 File path: 
commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
 ##
 @@ -120,6 +130,16 @@ public void testNormSq() {
 Assert.assertEquals(9.0, Vector1D.of(-3).normSq(), TEST_TOLERANCE);
 }
 
+@Test
+public void testNormSq_unitVectors()
+{
 
 Review comment:
   Watch the braces in this file. This one should go on the previous line.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Resolved] (NET-673) IMAPClient.APPEND does not always calculate the correct length

2019-09-24 Thread Sebb (Jira)


 [ 
https://issues.apache.org/jira/browse/NET-673?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sebb resolved NET-673.
--
Resolution: Fixed

commit 33d23d6b6a3201cc3ffe2eb16a0e8a1a4a4b4c8a

NET-673 IMAPClient.APPEND does not always calculate the correct length
---
 src/changes/changes.xml   | 3 +++
 src/main/java/org/apache/commons/net/imap/IMAPClient.java | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)


> IMAPClient.APPEND does not always calculate the correct length
> --
>
> Key: NET-673
> URL: https://issues.apache.org/jira/browse/NET-673
> Project: Commons Net
>  Issue Type: Bug
>  Components: IMAP
>Reporter: Sebb
>Priority: Major
>
> The APPEND command requires the length of the body.
> This is the number of bytes on the wire, not the number of characters in the 
> String.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (NET-673) IMAPClient.APPEND does not always calculate the correct length

2019-09-24 Thread Sebb (Jira)
Sebb created NET-673:


 Summary: IMAPClient.APPEND does not always calculate the correct 
length
 Key: NET-673
 URL: https://issues.apache.org/jira/browse/NET-673
 Project: Commons Net
  Issue Type: Bug
  Components: IMAP
Reporter: Sebb


The APPEND command requires the length of the body.

This is the number of bytes on the wire, not the number of characters in the 
String.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-rng] coveralls edited a comment on issue #67: RNG-116: RandomSource to expose supported interfaces.

2019-09-24 Thread GitBox
coveralls edited a comment on issue #67: RNG-116: RandomSource to expose 
supported interfaces.
URL: https://github.com/apache/commons-rng/pull/67#issuecomment-534260653
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/25907921/badge)](https://coveralls.io/builds/25907921)
   
   Coverage increased (+0.0005%) to 99.417% when pulling 
**c8922306d051945a3da67a701d5a0252c39db232 on aherbert:improvement-RNG-116** 
into **8a9a84d51b5521a2d255eb076285393581c9e095 on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-rng] aherbert commented on issue #67: RNG-116: RandomSource to expose supported interfaces.

2019-09-24 Thread GitBox
aherbert commented on issue #67: RNG-116: RandomSource to expose supported 
interfaces.
URL: https://github.com/apache/commons-rng/pull/67#issuecomment-534757581
 
 
   Dropped method:
   
   public int getSeedByteSize();
   
   Exposing the byte size of the seed allows seed construction as a raw byte 
array without also performing any extra requirements of the generator, e.g. 
non-zero bytes, high complexity bytes.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Updated] (GEOMETRY-46) Additional UnitVector methods

2019-09-24 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/GEOMETRY-46?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated GEOMETRY-46:
---
Labels: easyfix pull-request-available starter  (was: easyfix starter)

> Additional UnitVector methods
> -
>
> Key: GEOMETRY-46
> URL: https://issues.apache.org/jira/browse/GEOMETRY-46
> Project: Apache Commons Geometry
>  Issue Type: Improvement
>Reporter: Matt Juntunen
>Priority: Minor
>  Labels: easyfix, pull-request-available, starter
>
> The following methods should be overridden in the {{UnitVector}} private 
> subclasses of the {{Vector?D}} classes:
> * {{normSq}} -- should return {{1}} for consistency with {{norm}}
> * {{negate}} -- should be overridden to also return a {{UnitVector}} instance 
> instead of a regular {{Vector?D}} 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-geometry] acid1103 opened a new pull request #39: GEOMETRY-46: Add additional UnitVector methods

2019-09-24 Thread GitBox
acid1103 opened a new pull request #39: GEOMETRY-46: Add additional UnitVector 
methods
URL: https://github.com/apache/commons-geometry/pull/39
 
 
   This should resolve 
[GEOMETRY-46](https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-46?filter=allopenissues).
 Are there any tests which should be added to this commit?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Updated] (BCEL-291) Verifier rejects invokevirtual on array: org.apache.bcel.generic.ClassGenException: [Ljava/lang/Object; does not represent an ObjectType

2019-09-24 Thread Gary Gregory (Jira)


 [ 
https://issues.apache.org/jira/browse/BCEL-291?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary Gregory updated BCEL-291:
--
Fix Version/s: (was: 6.4.0)
   6.4.1

> Verifier rejects invokevirtual on array: 
> org.apache.bcel.generic.ClassGenException: [Ljava/lang/Object; does not 
> represent an ObjectType
> 
>
> Key: BCEL-291
> URL: https://issues.apache.org/jira/browse/BCEL-291
> Project: Commons BCEL
>  Issue Type: Bug
>Affects Versions: 6.0
>Reporter: Peter Burka
>Priority: Major
> Fix For: 6.4.1
>
>
> If a Java program invokes a java.lang.Object method on a variable whose 
> static type is an array, the methodref associated with the invokevirtual will 
> refer to an array class.
> When the BCEL verifier encounters such a class, it fails with a 
> ClassGenException.
> Test case:
> {noformat}
> public class Bug1 {
> public static Object[] bug(Object[] arg) {
>   return arg.clone();
> }
> }
> {noformat}
> Outoput:
> {noformat}
> JustIce by Enver Haase, (C) 2001-2002.
> 
> 
> Now verifying: Bug1
> Pass 1:
> VERIFIED_OK
> Passed verification.
> Pass 2:
> VERIFIED_OK
> Passed verification.
> Pass 3a, method number 0 ['public void ()']:
> VERIFIED_OK
> Passed verification.
> Pass 3b, method number 0 ['public void ()']:
> VERIFIED_OK
> Passed verification.
> Exception in thread "main" org.apache.bcel.generic.ClassGenException: 
> [Ljava/lang/Object; does not represent an ObjectType
>   at 
> org.apache.bcel.generic.FieldOrMethod.getLoadClassType(FieldOrMethod.java:137)
>   at 
> org.apache.bcel.verifier.statics.Pass3aVerifier$InstOperandConstraintVisitor.visitLoadClass(Pass3aVerifier.java:521)
>   at org.apache.bcel.generic.INVOKEVIRTUAL.accept(INVOKEVIRTUAL.java:85)
>   at 
> org.apache.bcel.generic.InstructionHandle.accept(InstructionHandle.java:302)
>   at 
> org.apache.bcel.verifier.statics.Pass3aVerifier.pass3StaticInstructionOperandsChecks(Pass3aVerifier.java:443)
>   at 
> org.apache.bcel.verifier.statics.Pass3aVerifier.do_verify(Pass3aVerifier.java:208)
>   at org.apache.bcel.verifier.PassVerifier.verify(PassVerifier.java:71)
>   at org.apache.bcel.verifier.Verifier.doPass3a(Verifier.java:89)
>   at org.apache.bcel.verifier.Verifier.main(Verifier.java:216)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327640858
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/CountingBloomFilter.java
 ##
 @@ -0,0 +1,178 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * A counting bloom filter.
+ *
+ * 
+ * This bloom filter maintains a count of the number of times a bit has been
+ * turned on. This allows for removal of bloom filters from the filter.
+ * 
+ * 
+ * Instances are immutable.
+ * 
+ *
+ * @since 4.5
+ *
+ */
+public class CountingBloomFilter extends StandardBloomFilter {
+
+// the count of entries
 
 Review comment:
   Merge this // comment into the Javadoc.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327640382
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/BloomFilter.java
 ##
 @@ -0,0 +1,94 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.util.BitSet;
+
+/**
+ * The interface for all BloomFilter implementations. Instances of BloomFilters
+ * should be immutable.
+ */
 
 Review comment:
   Since public classes should have a `@since` tag.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327641887
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/FilterConfig.java
 ##
 @@ -0,0 +1,173 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Filter configuration class.
+ * 
+ * This class contains the values for the filter configuration and is used to
+ * convert a ProtoBloomFilter into a BloomFilter.
+ * 
+ *
+ * @see http://hur.st/bloomfilter?n=3=1.0E-5;>Bloom Filter
+ *  calculator
+ *
+ * @since 4.5
+ */
+public final class FilterConfig implements Serializable {
+private static final long serialVersionUID = 8857015449149940190L;
+private static final double LOG_OF_2 = Math.log(2.0);
+
+// ~ −0.090619058
+private static final double DENOMINATOR = Math.log(1.0 / (Math.pow(2.0, 
LOG_OF_2)));
+// number of items in the filter
+private final int numberOfItems;
+// probability of false positives defined as 1 in x;
+private final int probability;
+// number of bits in the filter;
+private final int numberOfBits;
+// number of hash functions
+private final int numberOfHashFunctions;
+
+private transient Integer hashCode;
+
+/**
+ * Create a filter configuration with the specified number of items and
+ * probability.
+ *
+ * @param numberOfItems Number of items to be placed in the filter.
+ * @param probability   The probability of duplicates expressed as 1 in x.
+ */
+public FilterConfig(final int numberOfItems, final int probability) {
+if (numberOfItems < 1) {
+throw new IllegalArgumentException("Number of Items must be 
greater than 0");
+}
+if (probability < 1) {
+throw new IllegalArgumentException("Probability must be greater 
than 0");
+}
+this.numberOfItems = numberOfItems;
+this.probability = probability;
+final double dp = 1.0 / probability;
+final Double dm = Math.ceil((numberOfItems * Math.log(dp)) / 
DENOMINATOR);
+if (dm > Integer.MAX_VALUE) {
+throw new IllegalArgumentException("Resulting filter has more than 
" + Integer.MAX_VALUE + " bits");
+}
+this.numberOfBits = dm.intValue();
+final Long lk = Math.round((LOG_OF_2 * numberOfBits) / numberOfItems);
+/*
+ * normally we would check that lk is <- Integer.MAX_VALUE but since
+ * numberOfBits is at most Integer.MAX_VALUE the numerator of lk is 
log(2) *
+ * Integer.MAX_VALUE = 646456992.9449 the value of lk can not be above
+ * Integer.MAX_VALUE.
+ */
+numberOfHashFunctions = lk.intValue();
+}
+
+/**
+ * Get the number of items that are expected in the filter. AKA: {@code n }
 
 Review comment:
   "Gets..."


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327642152
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/FilterConfig.java
 ##
 @@ -0,0 +1,173 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Filter configuration class.
+ * 
+ * This class contains the values for the filter configuration and is used to
+ * convert a ProtoBloomFilter into a BloomFilter.
+ * 
+ *
+ * @see http://hur.st/bloomfilter?n=3=1.0E-5;>Bloom Filter
+ *  calculator
+ *
+ * @since 4.5
+ */
+public final class FilterConfig implements Serializable {
+private static final long serialVersionUID = 8857015449149940190L;
+private static final double LOG_OF_2 = Math.log(2.0);
+
+// ~ −0.090619058
+private static final double DENOMINATOR = Math.log(1.0 / (Math.pow(2.0, 
LOG_OF_2)));
+// number of items in the filter
+private final int numberOfItems;
+// probability of false positives defined as 1 in x;
+private final int probability;
+// number of bits in the filter;
+private final int numberOfBits;
+// number of hash functions
+private final int numberOfHashFunctions;
+
+private transient Integer hashCode;
+
+/**
+ * Create a filter configuration with the specified number of items and
+ * probability.
+ *
+ * @param numberOfItems Number of items to be placed in the filter.
+ * @param probability   The probability of duplicates expressed as 1 in x.
+ */
+public FilterConfig(final int numberOfItems, final int probability) {
+if (numberOfItems < 1) {
+throw new IllegalArgumentException("Number of Items must be 
greater than 0");
+}
+if (probability < 1) {
+throw new IllegalArgumentException("Probability must be greater 
than 0");
+}
+this.numberOfItems = numberOfItems;
+this.probability = probability;
+final double dp = 1.0 / probability;
+final Double dm = Math.ceil((numberOfItems * Math.log(dp)) / 
DENOMINATOR);
+if (dm > Integer.MAX_VALUE) {
+throw new IllegalArgumentException("Resulting filter has more than 
" + Integer.MAX_VALUE + " bits");
+}
+this.numberOfBits = dm.intValue();
+final Long lk = Math.round((LOG_OF_2 * numberOfBits) / numberOfItems);
+/*
+ * normally we would check that lk is <- Integer.MAX_VALUE but since
+ * numberOfBits is at most Integer.MAX_VALUE the numerator of lk is 
log(2) *
+ * Integer.MAX_VALUE = 646456992.9449 the value of lk can not be above
+ * Integer.MAX_VALUE.
+ */
+numberOfHashFunctions = lk.intValue();
+}
+
+/**
+ * Get the number of items that are expected in the filter. AKA: {@code n }
+ *
+ * @return the number of items.
+ */
+public int getNumberOfItems() {
+return numberOfItems;
+}
+
+/**
+ * The probability of a false positive (collision) expressed as {@code 1/x 
}.
+ * AKA: {@code 1/p }
+ *
+ * @return the x in 1/x.
+ */
+public int getProbability() {
+return probability;
+}
+
+/**
+ * The number of bits in the bloom filter. AKA: {@code m }
+ *
+ * @return the number of bits in the bloom filter.
+ */
+public int getNumberOfBits() {
+return numberOfBits;
+}
+
+/**
+ * The number of hash functions used to construct the filter. AKA: {@code 
k }
 
 Review comment:
   "Gets..."


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r325403761
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/BloomFilter.java
 ##
 @@ -0,0 +1,258 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.util.BitSet;
+
+import org.apache.commons.collections4.bloomfilters.ProtoBloomFilter.Hash;
+
+/**
+ * A bloom filter.
+ * 
+ * Instances are immutable.
+ * 
+ * @since 4.5
+ *
+ */
+public class BloomFilter {
+   
+   /* The maximum log depth is the depth at which
+* the log calculation makes no difference to the double result. 
+*/
+   private final static int MAX_LOG_DEPTH = 25;
+
+   // the bitset we are using
+   protected final BitSet bitSet;
+
+   // the hamming value once we have calculated it.
+   private transient Integer hamming;
+
+   // the base 2 log of the bloom filter considered as an integer.
+   private transient Double logValue;
+
+   /**
+* Constructor.
+* 
+* @param protoFilter the protoFilter to build this bloom filter from.
+* @param config the Filter configuration to use to build the bloom 
filter.
+*/
+   public BloomFilter(ProtoBloomFilter protoFilter, FilterConfig config) {
+   this.bitSet = new BitSet(config.getNumberOfBits());
+   for (Hash hash : protoFilter.hashes) {
+   hash.populate(bitSet, config);
+   }   
+   this.hamming = null;
+   this.logValue = null;
+   }
+   
+   /**
+* Constructor.
+* 
+* A copy of the bitSet parameter is made so that the bloom filter is 
isolated
+* from any further changes in the bitSet.
+* 
+* @param bitSet The bit set that was built by the config.
+*/
+   protected BloomFilter(BitSet bitSet)
+   {
+   this.bitSet = (BitSet)bitSet.clone();
+   this.hamming = null;
+   this.logValue = null;
+   }
+
+   /**
+* Return true if other  this == other
+* 
+* This is the inverse of the match method.
+* 
+* X.match(Y) is the same as Y.inverseMatch(X)
+* 
+* @param other the other bloom filter to match.
+* @return true if they match.
+*/
+   public boolean inverseMatch(final BloomFilter other) {
+   return other.match(this);
+   }
+
+   /**
+* Return true if this  other == this.
+* 
+* This is the standard bloom filter match.
+* 
+* @param other the other bloom filter to match.
+* @return true if they match.
+*/
+   public final boolean match(final BloomFilter other) {
+   BitSet temp = BitSet.valueOf(this.bitSet.toByteArray());
+   temp.and(other.bitSet);
+   return temp.equals(this.bitSet);
+   }
+
+   /**
+* Calculate the hamming distance from this bloom filter to the other. 
The
+* hamming distance is defined as this xor other and is the number of 
bits that
+* have to be flipped to convert one filter to the other.
+* 
+* @param other The other bloom filter to calculate the distance to.
+* @return the distance.
+*/
+   public final int distance(final BloomFilter other) {
+   BitSet temp = BitSet.valueOf(this.bitSet.toByteArray());
+   temp.xor(other.bitSet);
+   return temp.cardinality();
+   }
+
+   /**
+* Get the hamming weight for this filter.
+* 
+* This is the number of bits that are on in the filter.
+* 
+* @return The hamming weight.
+*/
+   public final int getHammingWeight() {
+   if (hamming == null) {
+   hamming = bitSet.cardinality();
+   }
+   return hamming;
+   }
+
+   /**
+* The the log(2) of this bloom filter. This is 

[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r325404103
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/BloomFilter.java
 ##
 @@ -0,0 +1,258 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.util.BitSet;
+
+import org.apache.commons.collections4.bloomfilters.ProtoBloomFilter.Hash;
+
+/**
+ * A bloom filter.
+ * 
+ * Instances are immutable.
+ * 
+ * @since 4.5
+ *
 
 Review comment:
   No extra line after since tag.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327642368
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/FilterConfig.java
 ##
 @@ -0,0 +1,173 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Filter configuration class.
+ * 
+ * This class contains the values for the filter configuration and is used to
+ * convert a ProtoBloomFilter into a BloomFilter.
+ * 
+ *
+ * @see http://hur.st/bloomfilter?n=3=1.0E-5;>Bloom Filter
+ *  calculator
+ *
+ * @since 4.5
+ */
+public final class FilterConfig implements Serializable {
+private static final long serialVersionUID = 8857015449149940190L;
+private static final double LOG_OF_2 = Math.log(2.0);
+
+// ~ −0.090619058
+private static final double DENOMINATOR = Math.log(1.0 / (Math.pow(2.0, 
LOG_OF_2)));
+// number of items in the filter
+private final int numberOfItems;
+// probability of false positives defined as 1 in x;
+private final int probability;
+// number of bits in the filter;
+private final int numberOfBits;
+// number of hash functions
+private final int numberOfHashFunctions;
+
+private transient Integer hashCode;
+
+/**
+ * Create a filter configuration with the specified number of items and
+ * probability.
+ *
+ * @param numberOfItems Number of items to be placed in the filter.
+ * @param probability   The probability of duplicates expressed as 1 in x.
+ */
+public FilterConfig(final int numberOfItems, final int probability) {
+if (numberOfItems < 1) {
+throw new IllegalArgumentException("Number of Items must be 
greater than 0");
+}
+if (probability < 1) {
+throw new IllegalArgumentException("Probability must be greater 
than 0");
+}
+this.numberOfItems = numberOfItems;
+this.probability = probability;
+final double dp = 1.0 / probability;
+final Double dm = Math.ceil((numberOfItems * Math.log(dp)) / 
DENOMINATOR);
+if (dm > Integer.MAX_VALUE) {
+throw new IllegalArgumentException("Resulting filter has more than 
" + Integer.MAX_VALUE + " bits");
+}
+this.numberOfBits = dm.intValue();
+final Long lk = Math.round((LOG_OF_2 * numberOfBits) / numberOfItems);
+/*
+ * normally we would check that lk is <- Integer.MAX_VALUE but since
+ * numberOfBits is at most Integer.MAX_VALUE the numerator of lk is 
log(2) *
+ * Integer.MAX_VALUE = 646456992.9449 the value of lk can not be above
+ * Integer.MAX_VALUE.
+ */
+numberOfHashFunctions = lk.intValue();
+}
+
+/**
+ * Get the number of items that are expected in the filter. AKA: {@code n }
+ *
+ * @return the number of items.
+ */
+public int getNumberOfItems() {
+return numberOfItems;
+}
+
+/**
+ * The probability of a false positive (collision) expressed as {@code 1/x 
}.
+ * AKA: {@code 1/p }
+ *
+ * @return the x in 1/x.
+ */
+public int getProbability() {
+return probability;
+}
+
+/**
+ * The number of bits in the bloom filter. AKA: {@code m }
+ *
+ * @return the number of bits in the bloom filter.
+ */
+public int getNumberOfBits() {
+return numberOfBits;
+}
+
+/**
+ * The number of hash functions used to construct the filter. AKA: {@code 
k }
+ *
+ * @return the number of hash functions used to construct the filter.
+ */
+public int getNumberOfHashFunctions() {
+return numberOfHashFunctions;
+}
+
+/**
+ * The number of bytes in the bloom filter.
+ *
+ * @return the number of bytes in the bloom filter.
+ */
+public int getNumberOfBytes() {
+return Double.valueOf(Math.ceil(numberOfBits / 8.0)).intValue();
+}
+
+@Override
+public boolean equals(Object o) {
+if (o instanceof 

[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327640148
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/BloomFilter.java
 ##
 @@ -0,0 +1,94 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.util.BitSet;
+
+/**
+ * The interface for all BloomFilter implementations. Instances of BloomFilters
+ * should be immutable.
+ */
+public interface BloomFilter {
+
+/**
+ * Return true if other  this == other
 
 Review comment:
   Start Javadoc comments with "Returns" instead of "Return"; "Gets" instead of 
"Get" and so on.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327646194
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/FilterConfig.java
 ##
 @@ -0,0 +1,173 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Filter configuration class.
+ * 
+ * This class contains the values for the filter configuration and is used to
+ * convert a ProtoBloomFilter into a BloomFilter.
+ * 
+ *
+ * @see http://hur.st/bloomfilter?n=3=1.0E-5;>Bloom Filter
+ *  calculator
+ *
+ * @since 4.5
+ */
+public final class FilterConfig implements Serializable {
 
 Review comment:
   Seems like an odd class name, why not prefix the class name with 'Bloom'? 
Would this class _ever_ apply to non-bloom classes?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327646708
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/ProtoBloomFilter.java
 ##
 @@ -0,0 +1,558 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Stream;
+
+/**
+ * A prototypical bloom filter definition.
+ * 
+ * The ProtoBloomFilter contains the information necessary to create a concrete
+ * bloom filter with a given filter configuration. The construction of the
+ * ProtoBloomFilter is far more compute expensive than making the concrete 
bloom
+ * filter from the proto filter. Concrete implementations of BloomFilter are
+ * built from the ProtoBloomFilter.
+ * 
+ *
+ * @since 4.5
+ * @see FilterConfig
+ *
+ */
+public final class ProtoBloomFilter implements Comparable {
+
+private final List hashes;
+private transient Integer hashCode;
+
+/**
+ * An empty ProtoBloomFilter. Used to create empty BloomFilters.
+ */
+public static final ProtoBloomFilter EMPTY = new 
ProtoBloomFilter(Collections.emptyList());
+
+/**
+ * Get a builder .
+ *
+ * @return a new builder.
+ */
+public static Builder builder() {
+return new Builder();
+}
+
+/* package private for testing */
+/**
+ * Constructor
+ *
+ * @param hashes the two longs that were created by the murmur hash 
function.
+ */
+ProtoBloomFilter(Collection hashes) {
+this.hashes = new ArrayList();
+this.hashes.addAll(hashes);
+// sort so compareTo and equals work properly
+Collections.sort(this.hashes);
+}
+
+private Object writeReplace() {
+return new ProtoSerProxy(this);
+}
+
+/**
+ * Get the count of hashed items included in this proto bloom filter.
+ *
+ * @return The number of unique items in this proto filter.
+ */
+public int getItemCount() {
+return hashes.size();
+}
+
+/**
+ * Get the stream of hashes included in this proto bloom filter.
+ *
+ * @return the stream of hashes.
+ */
+public Stream getHashes() {
+return hashes.stream();
+}
+
+/**
+ * Get the count of unique hashed items included in this proto bloom 
filter.
+ *
+ * @return the number of unique items hashed into the proto bloom filter.
+ */
+public int getUniqueItemCount() {
+return (int) getUniqueHashes().count();
+}
+
+/**
+ * Get the stream of uniques hashes included in this proto bloom filter.
+ *
+ * @return the stream of unique hashes.
+ */
+public Stream getUniqueHashes() {
+return hashes.stream().distinct();
+}
+
+@Override
+public int hashCode() {
+if (hashCode == null) {
+hashCode = Objects.hash(hashes);
+}
+return hashCode.intValue();
+}
+
+@Override
+public int compareTo(ProtoBloomFilter other) {
+Iterator otherIter = other.getHashes().iterator();
+Iterator iter = hashes.iterator();
+int result;
+while (iter.hasNext() && otherIter.hasNext()) {
+result = iter.next().compareTo(otherIter.next());
+if (result != 0) {
+return result;
+}
+}
+return otherIter.hasNext() ? -1 : 0;
+}
+
+@Override
+public boolean equals(Object o) {
+if (o instanceof ProtoBloomFilter) {
+return compareTo((ProtoBloomFilter) o) == 0;
+}
+return false;
+}
+
+@Override
+public String toString() {
+return String.format("ProtoBloomFilter[ %s, %s]", hashes.size(), 
hashCode());
+}
+

[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r325403610
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/BloomFilter.java
 ##
 @@ -65,7 +90,7 @@ public boolean inverseMatch(final BloomFilter other) {
}
 
/**
-* Return true if this & other == this.
+* Return true if this  other == this.
 
 Review comment:
   Get methods should start Javadocs with "Gets ...".


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327647091
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/ProtoBloomFilter.java
 ##
 @@ -0,0 +1,558 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Stream;
+
+/**
+ * A prototypical bloom filter definition.
+ * 
+ * The ProtoBloomFilter contains the information necessary to create a concrete
+ * bloom filter with a given filter configuration. The construction of the
+ * ProtoBloomFilter is far more compute expensive than making the concrete 
bloom
+ * filter from the proto filter. Concrete implementations of BloomFilter are
+ * built from the ProtoBloomFilter.
+ * 
+ *
+ * @since 4.5
+ * @see FilterConfig
+ *
+ */
+public final class ProtoBloomFilter implements Comparable {
+
+private final List hashes;
+private transient Integer hashCode;
+
+/**
+ * An empty ProtoBloomFilter. Used to create empty BloomFilters.
+ */
+public static final ProtoBloomFilter EMPTY = new 
ProtoBloomFilter(Collections.emptyList());
+
+/**
+ * Get a builder .
+ *
+ * @return a new builder.
+ */
+public static Builder builder() {
+return new Builder();
+}
+
+/* package private for testing */
+/**
+ * Constructor
+ *
+ * @param hashes the two longs that were created by the murmur hash 
function.
+ */
+ProtoBloomFilter(Collection hashes) {
+this.hashes = new ArrayList();
+this.hashes.addAll(hashes);
+// sort so compareTo and equals work properly
+Collections.sort(this.hashes);
+}
+
+private Object writeReplace() {
+return new ProtoSerProxy(this);
+}
+
+/**
+ * Get the count of hashed items included in this proto bloom filter.
+ *
+ * @return The number of unique items in this proto filter.
+ */
+public int getItemCount() {
+return hashes.size();
+}
+
+/**
+ * Get the stream of hashes included in this proto bloom filter.
+ *
+ * @return the stream of hashes.
+ */
+public Stream getHashes() {
+return hashes.stream();
+}
+
+/**
+ * Get the count of unique hashed items included in this proto bloom 
filter.
+ *
+ * @return the number of unique items hashed into the proto bloom filter.
+ */
+public int getUniqueItemCount() {
+return (int) getUniqueHashes().count();
+}
+
+/**
+ * Get the stream of uniques hashes included in this proto bloom filter.
+ *
+ * @return the stream of unique hashes.
+ */
+public Stream getUniqueHashes() {
+return hashes.stream().distinct();
+}
+
+@Override
+public int hashCode() {
+if (hashCode == null) {
+hashCode = Objects.hash(hashes);
+}
+return hashCode.intValue();
+}
+
+@Override
+public int compareTo(ProtoBloomFilter other) {
+Iterator otherIter = other.getHashes().iterator();
+Iterator iter = hashes.iterator();
+int result;
+while (iter.hasNext() && otherIter.hasNext()) {
+result = iter.next().compareTo(otherIter.next());
+if (result != 0) {
+return result;
+}
+}
+return otherIter.hasNext() ? -1 : 0;
+}
+
+@Override
+public boolean equals(Object o) {
+if (o instanceof ProtoBloomFilter) {
+return compareTo((ProtoBloomFilter) o) == 0;
+}
+return false;
+}
+
+@Override
+public String toString() {
+return String.format("ProtoBloomFilter[ %s, %s]", hashes.size(), 
hashCode());
+}
+

[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r325403976
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/BloomFilter.java
 ##
 @@ -0,0 +1,258 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.util.BitSet;
+
+import org.apache.commons.collections4.bloomfilters.ProtoBloomFilter.Hash;
+
+/**
+ * A bloom filter.
+ * 
+ * Instances are immutable.
+ * 
+ * @since 4.5
+ *
+ */
+public class BloomFilter {
+   
+   /* The maximum log depth is the depth at which
+* the log calculation makes no difference to the double result. 
+*/
+   private final static int MAX_LOG_DEPTH = 25;
+
+   // the bitset we are using
+   protected final BitSet bitSet;
+
+   // the hamming value once we have calculated it.
+   private transient Integer hamming;
+
+   // the base 2 log of the bloom filter considered as an integer.
+   private transient Double logValue;
+
+   /**
+* Constructor.
+* 
+* @param protoFilter the protoFilter to build this bloom filter from.
+* @param config the Filter configuration to use to build the bloom 
filter.
+*/
+   public BloomFilter(ProtoBloomFilter protoFilter, FilterConfig config) {
+   this.bitSet = new BitSet(config.getNumberOfBits());
+   for (Hash hash : protoFilter.hashes) {
+   hash.populate(bitSet, config);
+   }   
+   this.hamming = null;
+   this.logValue = null;
+   }
+   
+   /**
+* Constructor.
+* 
+* A copy of the bitSet parameter is made so that the bloom filter is 
isolated
+* from any further changes in the bitSet.
+* 
+* @param bitSet The bit set that was built by the config.
+*/
+   protected BloomFilter(BitSet bitSet)
+   {
+   this.bitSet = (BitSet)bitSet.clone();
+   this.hamming = null;
+   this.logValue = null;
+   }
+
+   /**
+* Return true if other  this == other
+* 
+* This is the inverse of the match method.
+* 
+* X.match(Y) is the same as Y.inverseMatch(X)
+* 
+* @param other the other bloom filter to match.
+* @return true if they match.
+*/
+   public boolean inverseMatch(final BloomFilter other) {
+   return other.match(this);
+   }
+
+   /**
+* Return true if this  other == this.
+* 
+* This is the standard bloom filter match.
+* 
+* @param other the other bloom filter to match.
+* @return true if they match.
+*/
+   public final boolean match(final BloomFilter other) {
+   BitSet temp = BitSet.valueOf(this.bitSet.toByteArray());
+   temp.and(other.bitSet);
+   return temp.equals(this.bitSet);
+   }
+
+   /**
+* Calculate the hamming distance from this bloom filter to the other. 
The
+* hamming distance is defined as this xor other and is the number of 
bits that
+* have to be flipped to convert one filter to the other.
+* 
+* @param other The other bloom filter to calculate the distance to.
+* @return the distance.
+*/
+   public final int distance(final BloomFilter other) {
+   BitSet temp = BitSet.valueOf(this.bitSet.toByteArray());
+   temp.xor(other.bitSet);
+   return temp.cardinality();
+   }
+
+   /**
+* Get the hamming weight for this filter.
+* 
+* This is the number of bits that are on in the filter.
+* 
+* @return The hamming weight.
+*/
+   public final int getHammingWeight() {
+   if (hamming == null) {
+   hamming = bitSet.cardinality();
+   }
+   return hamming;
+   }
+
+   /**
+* The the log(2) of this bloom filter. This is 

[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327640675
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/CountingBloomFilter.java
 ##
 @@ -0,0 +1,178 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * A counting bloom filter.
+ *
+ * 
+ * This bloom filter maintains a count of the number of times a bit has been
+ * turned on. This allows for removal of bloom filters from the filter.
+ * 
+ * 
+ * Instances are immutable.
+ * 
+ *
+ * @since 4.5
+ *
 
 Review comment:
   No extra empty line needed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327641989
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/FilterConfig.java
 ##
 @@ -0,0 +1,173 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Filter configuration class.
+ * 
+ * This class contains the values for the filter configuration and is used to
+ * convert a ProtoBloomFilter into a BloomFilter.
+ * 
+ *
+ * @see http://hur.st/bloomfilter?n=3=1.0E-5;>Bloom Filter
+ *  calculator
+ *
+ * @since 4.5
+ */
+public final class FilterConfig implements Serializable {
+private static final long serialVersionUID = 8857015449149940190L;
+private static final double LOG_OF_2 = Math.log(2.0);
+
+// ~ −0.090619058
+private static final double DENOMINATOR = Math.log(1.0 / (Math.pow(2.0, 
LOG_OF_2)));
+// number of items in the filter
+private final int numberOfItems;
+// probability of false positives defined as 1 in x;
+private final int probability;
+// number of bits in the filter;
+private final int numberOfBits;
+// number of hash functions
+private final int numberOfHashFunctions;
+
+private transient Integer hashCode;
+
+/**
+ * Create a filter configuration with the specified number of items and
+ * probability.
+ *
+ * @param numberOfItems Number of items to be placed in the filter.
+ * @param probability   The probability of duplicates expressed as 1 in x.
+ */
+public FilterConfig(final int numberOfItems, final int probability) {
+if (numberOfItems < 1) {
+throw new IllegalArgumentException("Number of Items must be 
greater than 0");
+}
+if (probability < 1) {
+throw new IllegalArgumentException("Probability must be greater 
than 0");
+}
+this.numberOfItems = numberOfItems;
+this.probability = probability;
+final double dp = 1.0 / probability;
+final Double dm = Math.ceil((numberOfItems * Math.log(dp)) / 
DENOMINATOR);
+if (dm > Integer.MAX_VALUE) {
+throw new IllegalArgumentException("Resulting filter has more than 
" + Integer.MAX_VALUE + " bits");
+}
+this.numberOfBits = dm.intValue();
+final Long lk = Math.round((LOG_OF_2 * numberOfBits) / numberOfItems);
+/*
+ * normally we would check that lk is <- Integer.MAX_VALUE but since
+ * numberOfBits is at most Integer.MAX_VALUE the numerator of lk is 
log(2) *
+ * Integer.MAX_VALUE = 646456992.9449 the value of lk can not be above
+ * Integer.MAX_VALUE.
+ */
+numberOfHashFunctions = lk.intValue();
+}
+
+/**
+ * Get the number of items that are expected in the filter. AKA: {@code n }
+ *
+ * @return the number of items.
+ */
+public int getNumberOfItems() {
+return numberOfItems;
+}
+
+/**
+ * The probability of a false positive (collision) expressed as {@code 1/x 
}.
 
 Review comment:
   "Gets..."


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327642206
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/FilterConfig.java
 ##
 @@ -0,0 +1,173 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Filter configuration class.
+ * 
+ * This class contains the values for the filter configuration and is used to
+ * convert a ProtoBloomFilter into a BloomFilter.
+ * 
+ *
+ * @see http://hur.st/bloomfilter?n=3=1.0E-5;>Bloom Filter
+ *  calculator
+ *
+ * @since 4.5
+ */
+public final class FilterConfig implements Serializable {
+private static final long serialVersionUID = 8857015449149940190L;
+private static final double LOG_OF_2 = Math.log(2.0);
+
+// ~ −0.090619058
+private static final double DENOMINATOR = Math.log(1.0 / (Math.pow(2.0, 
LOG_OF_2)));
+// number of items in the filter
+private final int numberOfItems;
+// probability of false positives defined as 1 in x;
+private final int probability;
+// number of bits in the filter;
+private final int numberOfBits;
+// number of hash functions
+private final int numberOfHashFunctions;
+
+private transient Integer hashCode;
+
+/**
+ * Create a filter configuration with the specified number of items and
+ * probability.
+ *
+ * @param numberOfItems Number of items to be placed in the filter.
+ * @param probability   The probability of duplicates expressed as 1 in x.
+ */
+public FilterConfig(final int numberOfItems, final int probability) {
+if (numberOfItems < 1) {
+throw new IllegalArgumentException("Number of Items must be 
greater than 0");
+}
+if (probability < 1) {
+throw new IllegalArgumentException("Probability must be greater 
than 0");
+}
+this.numberOfItems = numberOfItems;
+this.probability = probability;
+final double dp = 1.0 / probability;
+final Double dm = Math.ceil((numberOfItems * Math.log(dp)) / 
DENOMINATOR);
+if (dm > Integer.MAX_VALUE) {
+throw new IllegalArgumentException("Resulting filter has more than 
" + Integer.MAX_VALUE + " bits");
+}
+this.numberOfBits = dm.intValue();
+final Long lk = Math.round((LOG_OF_2 * numberOfBits) / numberOfItems);
+/*
+ * normally we would check that lk is <- Integer.MAX_VALUE but since
+ * numberOfBits is at most Integer.MAX_VALUE the numerator of lk is 
log(2) *
+ * Integer.MAX_VALUE = 646456992.9449 the value of lk can not be above
+ * Integer.MAX_VALUE.
+ */
+numberOfHashFunctions = lk.intValue();
+}
+
+/**
+ * Get the number of items that are expected in the filter. AKA: {@code n }
+ *
+ * @return the number of items.
+ */
+public int getNumberOfItems() {
+return numberOfItems;
+}
+
+/**
+ * The probability of a false positive (collision) expressed as {@code 1/x 
}.
+ * AKA: {@code 1/p }
+ *
+ * @return the x in 1/x.
+ */
+public int getProbability() {
+return probability;
+}
+
+/**
+ * The number of bits in the bloom filter. AKA: {@code m }
+ *
+ * @return the number of bits in the bloom filter.
+ */
+public int getNumberOfBits() {
+return numberOfBits;
+}
+
+/**
+ * The number of hash functions used to construct the filter. AKA: {@code 
k }
+ *
+ * @return the number of hash functions used to construct the filter.
+ */
+public int getNumberOfHashFunctions() {
+return numberOfHashFunctions;
+}
+
+/**
+ * The number of bytes in the bloom filter.
 
 Review comment:
   "Gets..."


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

[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327642713
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/ProtoBloomFilter.java
 ##
 @@ -0,0 +1,558 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Stream;
+
+/**
+ * A prototypical bloom filter definition.
+ * 
+ * The ProtoBloomFilter contains the information necessary to create a concrete
+ * bloom filter with a given filter configuration. The construction of the
+ * ProtoBloomFilter is far more compute expensive than making the concrete 
bloom
+ * filter from the proto filter. Concrete implementations of BloomFilter are
+ * built from the ProtoBloomFilter.
+ * 
+ *
+ * @since 4.5
+ * @see FilterConfig
+ *
+ */
+public final class ProtoBloomFilter implements Comparable {
+
+private final List hashes;
+private transient Integer hashCode;
+
+/**
+ * An empty ProtoBloomFilter. Used to create empty BloomFilters.
+ */
+public static final ProtoBloomFilter EMPTY = new 
ProtoBloomFilter(Collections.emptyList());
+
+/**
+ * Get a builder .
 
 Review comment:
   Javadoc: "Creates a new builder."


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r325404275
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/BloomFilter.java
 ##
 @@ -0,0 +1,258 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.util.BitSet;
+
+import org.apache.commons.collections4.bloomfilters.ProtoBloomFilter.Hash;
+
+/**
+ * A bloom filter.
+ * 
+ * Instances are immutable.
+ * 
+ * @since 4.5
+ *
+ */
+public class BloomFilter {
+   
+   /* The maximum log depth is the depth at which
+* the log calculation makes no difference to the double result. 
+*/
+   private final static int MAX_LOG_DEPTH = 25;
+
+   // the bitset we are using
+   protected final BitSet bitSet;
+
+   // the hamming value once we have calculated it.
+   private transient Integer hamming;
+
+   // the base 2 log of the bloom filter considered as an integer.
+   private transient Double logValue;
+
+   /**
+* Constructor.
+* 
+* @param protoFilter the protoFilter to build this bloom filter from.
+* @param config the Filter configuration to use to build the bloom 
filter.
+*/
+   public BloomFilter(ProtoBloomFilter protoFilter, FilterConfig config) {
+   this.bitSet = new BitSet(config.getNumberOfBits());
+   for (Hash hash : protoFilter.hashes) {
+   hash.populate(bitSet, config);
+   }   
+   this.hamming = null;
+   this.logValue = null;
+   }
+   
+   /**
+* Constructor.
 
 Review comment:
   No need to say "Constructor".


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r327642067
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/FilterConfig.java
 ##
 @@ -0,0 +1,173 @@
+/*
+ * 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.commons.collections4.bloomfilters;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Filter configuration class.
+ * 
+ * This class contains the values for the filter configuration and is used to
+ * convert a ProtoBloomFilter into a BloomFilter.
+ * 
+ *
+ * @see http://hur.st/bloomfilter?n=3=1.0E-5;>Bloom Filter
+ *  calculator
+ *
+ * @since 4.5
+ */
+public final class FilterConfig implements Serializable {
+private static final long serialVersionUID = 8857015449149940190L;
+private static final double LOG_OF_2 = Math.log(2.0);
+
+// ~ −0.090619058
+private static final double DENOMINATOR = Math.log(1.0 / (Math.pow(2.0, 
LOG_OF_2)));
+// number of items in the filter
+private final int numberOfItems;
+// probability of false positives defined as 1 in x;
+private final int probability;
+// number of bits in the filter;
+private final int numberOfBits;
+// number of hash functions
+private final int numberOfHashFunctions;
+
+private transient Integer hashCode;
+
+/**
+ * Create a filter configuration with the specified number of items and
+ * probability.
+ *
+ * @param numberOfItems Number of items to be placed in the filter.
+ * @param probability   The probability of duplicates expressed as 1 in x.
+ */
+public FilterConfig(final int numberOfItems, final int probability) {
+if (numberOfItems < 1) {
+throw new IllegalArgumentException("Number of Items must be 
greater than 0");
+}
+if (probability < 1) {
+throw new IllegalArgumentException("Probability must be greater 
than 0");
+}
+this.numberOfItems = numberOfItems;
+this.probability = probability;
+final double dp = 1.0 / probability;
+final Double dm = Math.ceil((numberOfItems * Math.log(dp)) / 
DENOMINATOR);
+if (dm > Integer.MAX_VALUE) {
+throw new IllegalArgumentException("Resulting filter has more than 
" + Integer.MAX_VALUE + " bits");
+}
+this.numberOfBits = dm.intValue();
+final Long lk = Math.round((LOG_OF_2 * numberOfBits) / numberOfItems);
+/*
+ * normally we would check that lk is <- Integer.MAX_VALUE but since
+ * numberOfBits is at most Integer.MAX_VALUE the numerator of lk is 
log(2) *
+ * Integer.MAX_VALUE = 646456992.9449 the value of lk can not be above
+ * Integer.MAX_VALUE.
+ */
+numberOfHashFunctions = lk.intValue();
+}
+
+/**
+ * Get the number of items that are expected in the filter. AKA: {@code n }
+ *
+ * @return the number of items.
+ */
+public int getNumberOfItems() {
+return numberOfItems;
+}
+
+/**
+ * The probability of a false positive (collision) expressed as {@code 1/x 
}.
+ * AKA: {@code 1/p }
+ *
+ * @return the x in 1/x.
+ */
+public int getProbability() {
+return probability;
+}
+
+/**
+ * The number of bits in the bloom filter. AKA: {@code m }
 
 Review comment:
   "Gets..."


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] garydgregory commented on a change in pull request #83: WIP: Initial bloom filter code contribution

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #83: WIP: Initial bloom 
filter code contribution
URL: https://github.com/apache/commons-collections/pull/83#discussion_r325403162
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilters/BloomFilter.java
 ##
 @@ -39,23 +48,39 @@
/**
 * Constructor.
 * 
-* A copy of the bitSet parameter is made so that the bloom filter
-* is isolated from any further changes in the bitSet.
+* @param protoFilter the protoFilter to build this bloom filter from.
+* @param config the Filter configuration to use to build the bloom 
filter.
+*/
+   public BloomFilter(ProtoBloomFilter protoFilter, FilterConfig config) {
+   this.bitSet = new BitSet(config.getNumberOfBits());
+   for (Hash hash : protoFilter.hashes) {
+   hash.populate(bitSet, config);
+   }   
+   this.hamming = null;
+   this.logValue = null;
+   }
+   
+   /**
+* Constructor.
+* 
+* A copy of the bitSet parameter is made so that the bloom filter is 
isolated
+* from any further changes in the bitSet.
 * 
 * @param bitSet The bit set that was built by the config.
 */
-   public BloomFilter(BitSet bitSet) {
+   protected BloomFilter(BitSet bitSet)
+   {
 
 Review comment:
   Please use open braces on the same line.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Work logged] (LANG-1480) ClassUtils. getAbbreviatedName(String ,int) returns too long result

2019-09-24 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1480?focusedWorklogId=317512=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-317512
 ]

ASF GitHub Bot logged work on LANG-1480:


Author: ASF GitHub Bot
Created on: 24/Sep/19 14:12
Start Date: 24/Sep/19 14:12
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on pull request #446: LANG-1480 
getAbbreviatedName refactored to create appropriate length …
URL: https://github.com/apache/commons-lang/pull/446#discussion_r327637992
 
 

 ##
 File path: src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
 ##
 @@ -47,7 +47,7 @@
  * Unit tests {@link org.apache.commons.lang3.ClassUtils}.
  */
 @SuppressWarnings("boxing") // JUnit4 does not support primitive equality 
testing apart from long
-public class ClassUtilsTest  {
+class ClassUtilsTest  {
 
 Review comment:
   @verhas ping.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 317512)

> ClassUtils. getAbbreviatedName(String ,int) returns too long result
> ---
>
> Key: LANG-1480
> URL: https://issues.apache.org/jira/browse/LANG-1480
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.*
>Affects Versions: 3.9
> Environment: Environment independent.
>Reporter: Peter Verhas
>Assignee: Bruno P. Kinoshita
>Priority: Major
>   Original Estimate: 24h
>  Time Spent: 5h 50m
>  Remaining Estimate: 18h 10m
>
> In some cases, the algorithm decides incorrectly when to which package names 
> to abbreviate. For example, abbreviating
> {{org.apache.commons.lang3.ClassUtils}} to the length 18 will result 
> {{o.a.c.lang3.ClassUtils}} (22 characters) instead of {{o.a.c.l.ClassUtils}} 
> (18 characters as requested). The reason for this is that the algorithm 
> starts from the right and goes to the left abbreviating the packages and 
> starts to abbreviate the packages when it runs out of the available space.
> Instead, the algorithm should start from the left and abbreviate all packages 
> that would result in a too-long string without abbreviating the package name.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1480) ClassUtils. getAbbreviatedName(String ,int) returns too long result

2019-09-24 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1480?focusedWorklogId=317510=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-317510
 ]

ASF GitHub Bot logged work on LANG-1480:


Author: ASF GitHub Bot
Created on: 24/Sep/19 14:12
Start Date: 24/Sep/19 14:12
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on pull request #446: LANG-1480 
getAbbreviatedName refactored to create appropriate length …
URL: https://github.com/apache/commons-lang/pull/446#discussion_r327638102
 
 

 ##
 File path: src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
 ##
 @@ -160,26 +162,59 @@ public void test_getAbbreviatedName_Class() {
 assertEquals("", ClassUtils.getAbbreviatedName((Class) null, 1));
 assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 
1));
 assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 
5));
+assertEquals("o.a.c.l.ClassUtils", 
ClassUtils.getAbbreviatedName(ClassUtils.class, 18));
 assertEquals("j.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 13));
 assertEquals("j.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 15));
 assertEquals("java.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 20));
 }
 
+/**
+ * Test that in case the required length is larger than the name and thus 
there is no need for any shortening
+ * then the returned string object is the same as the one passed as 
argument. Note, however, that this is
+ * tested as an internal implementation detail, but it is not a guaranteed 
feature of the implementation.
+ */
 @Test
-public void test_getAbbreviatedName_Class_NegativeLen() {
+@DisplayName("When the length hint is longer than the actual length then 
the same String object is returned")
+void test_getAbbreviatedName_TooLongHint(){
+final String className = "java.lang.String";
+Assertions.assertSame(className, 
ClassUtils.getAbbreviatedName(className, className.length()+1));
+Assertions.assertSame(className, 
ClassUtils.getAbbreviatedName(className, className.length()));
+}
+
+@Test
+@DisplayName("When the desired length is negative then exception is 
thrown")
+void test_getAbbreviatedName_Class_NegativeLen() {
 assertThrows(IllegalArgumentException.class, () -> 
ClassUtils.getAbbreviatedName(String.class, -10));
 }
 
 @Test
-public void test_getAbbreviatedName_Class_ZeroLen() {
 
 Review comment:
   Let's not change the visibility of test classes and methods please.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 317510)
Remaining Estimate: 18h 10m  (was: 18h 20m)
Time Spent: 5h 50m  (was: 5h 40m)

> ClassUtils. getAbbreviatedName(String ,int) returns too long result
> ---
>
> Key: LANG-1480
> URL: https://issues.apache.org/jira/browse/LANG-1480
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.*
>Affects Versions: 3.9
> Environment: Environment independent.
>Reporter: Peter Verhas
>Assignee: Bruno P. Kinoshita
>Priority: Major
>   Original Estimate: 24h
>  Time Spent: 5h 50m
>  Remaining Estimate: 18h 10m
>
> In some cases, the algorithm decides incorrectly when to which package names 
> to abbreviate. For example, abbreviating
> {{org.apache.commons.lang3.ClassUtils}} to the length 18 will result 
> {{o.a.c.lang3.ClassUtils}} (22 characters) instead of {{o.a.c.l.ClassUtils}} 
> (18 characters as requested). The reason for this is that the algorithm 
> starts from the right and goes to the left abbreviating the packages and 
> starts to abbreviate the packages when it runs out of the available space.
> Instead, the algorithm should start from the left and abbreviate all packages 
> that would result in a too-long string without abbreviating the package name.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1480) ClassUtils. getAbbreviatedName(String ,int) returns too long result

2019-09-24 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1480?focusedWorklogId=317509=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-317509
 ]

ASF GitHub Bot logged work on LANG-1480:


Author: ASF GitHub Bot
Created on: 24/Sep/19 14:12
Start Date: 24/Sep/19 14:12
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on pull request #446: LANG-1480 
getAbbreviatedName refactored to create appropriate length …
URL: https://github.com/apache/commons-lang/pull/446#discussion_r327638057
 
 

 ##
 File path: src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
 ##
 @@ -160,26 +162,59 @@ public void test_getAbbreviatedName_Class() {
 assertEquals("", ClassUtils.getAbbreviatedName((Class) null, 1));
 assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 
1));
 assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 
5));
+assertEquals("o.a.c.l.ClassUtils", 
ClassUtils.getAbbreviatedName(ClassUtils.class, 18));
 assertEquals("j.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 13));
 assertEquals("j.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 15));
 assertEquals("java.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 20));
 }
 
+/**
+ * Test that in case the required length is larger than the name and thus 
there is no need for any shortening
+ * then the returned string object is the same as the one passed as 
argument. Note, however, that this is
+ * tested as an internal implementation detail, but it is not a guaranteed 
feature of the implementation.
+ */
 @Test
-public void test_getAbbreviatedName_Class_NegativeLen() {
 
 Review comment:
   Let's not change the visibility of test classes and methods please.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 317509)
Remaining Estimate: 18h 10m  (was: 18h 20m)
Time Spent: 5h 50m  (was: 5h 40m)

> ClassUtils. getAbbreviatedName(String ,int) returns too long result
> ---
>
> Key: LANG-1480
> URL: https://issues.apache.org/jira/browse/LANG-1480
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.*
>Affects Versions: 3.9
> Environment: Environment independent.
>Reporter: Peter Verhas
>Assignee: Bruno P. Kinoshita
>Priority: Major
>   Original Estimate: 24h
>  Time Spent: 5h 50m
>  Remaining Estimate: 18h 10m
>
> In some cases, the algorithm decides incorrectly when to which package names 
> to abbreviate. For example, abbreviating
> {{org.apache.commons.lang3.ClassUtils}} to the length 18 will result 
> {{o.a.c.lang3.ClassUtils}} (22 characters) instead of {{o.a.c.l.ClassUtils}} 
> (18 characters as requested). The reason for this is that the algorithm 
> starts from the right and goes to the left abbreviating the packages and 
> starts to abbreviate the packages when it runs out of the available space.
> Instead, the algorithm should start from the left and abbreviate all packages 
> that would result in a too-long string without abbreviating the package name.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-lang] garydgregory commented on a change in pull request #446: LANG-1480 getAbbreviatedName refactored to create appropriate length …

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #446: LANG-1480 
getAbbreviatedName refactored to create appropriate length …
URL: https://github.com/apache/commons-lang/pull/446#discussion_r327637992
 
 

 ##
 File path: src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
 ##
 @@ -47,7 +47,7 @@
  * Unit tests {@link org.apache.commons.lang3.ClassUtils}.
  */
 @SuppressWarnings("boxing") // JUnit4 does not support primitive equality 
testing apart from long
-public class ClassUtilsTest  {
+class ClassUtilsTest  {
 
 Review comment:
   @verhas ping.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-lang] garydgregory commented on a change in pull request #446: LANG-1480 getAbbreviatedName refactored to create appropriate length …

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #446: LANG-1480 
getAbbreviatedName refactored to create appropriate length …
URL: https://github.com/apache/commons-lang/pull/446#discussion_r327638102
 
 

 ##
 File path: src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
 ##
 @@ -160,26 +162,59 @@ public void test_getAbbreviatedName_Class() {
 assertEquals("", ClassUtils.getAbbreviatedName((Class) null, 1));
 assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 
1));
 assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 
5));
+assertEquals("o.a.c.l.ClassUtils", 
ClassUtils.getAbbreviatedName(ClassUtils.class, 18));
 assertEquals("j.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 13));
 assertEquals("j.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 15));
 assertEquals("java.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 20));
 }
 
+/**
+ * Test that in case the required length is larger than the name and thus 
there is no need for any shortening
+ * then the returned string object is the same as the one passed as 
argument. Note, however, that this is
+ * tested as an internal implementation detail, but it is not a guaranteed 
feature of the implementation.
+ */
 @Test
-public void test_getAbbreviatedName_Class_NegativeLen() {
+@DisplayName("When the length hint is longer than the actual length then 
the same String object is returned")
+void test_getAbbreviatedName_TooLongHint(){
+final String className = "java.lang.String";
+Assertions.assertSame(className, 
ClassUtils.getAbbreviatedName(className, className.length()+1));
+Assertions.assertSame(className, 
ClassUtils.getAbbreviatedName(className, className.length()));
+}
+
+@Test
+@DisplayName("When the desired length is negative then exception is 
thrown")
+void test_getAbbreviatedName_Class_NegativeLen() {
 assertThrows(IllegalArgumentException.class, () -> 
ClassUtils.getAbbreviatedName(String.class, -10));
 }
 
 @Test
-public void test_getAbbreviatedName_Class_ZeroLen() {
 
 Review comment:
   Let's not change the visibility of test classes and methods please.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-lang] garydgregory commented on a change in pull request #446: LANG-1480 getAbbreviatedName refactored to create appropriate length …

2019-09-24 Thread GitBox
garydgregory commented on a change in pull request #446: LANG-1480 
getAbbreviatedName refactored to create appropriate length …
URL: https://github.com/apache/commons-lang/pull/446#discussion_r327638057
 
 

 ##
 File path: src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
 ##
 @@ -160,26 +162,59 @@ public void test_getAbbreviatedName_Class() {
 assertEquals("", ClassUtils.getAbbreviatedName((Class) null, 1));
 assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 
1));
 assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 
5));
+assertEquals("o.a.c.l.ClassUtils", 
ClassUtils.getAbbreviatedName(ClassUtils.class, 18));
 assertEquals("j.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 13));
 assertEquals("j.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 15));
 assertEquals("java.lang.String", 
ClassUtils.getAbbreviatedName(String.class, 20));
 }
 
+/**
+ * Test that in case the required length is larger than the name and thus 
there is no need for any shortening
+ * then the returned string object is the same as the one passed as 
argument. Note, however, that this is
+ * tested as an internal implementation detail, but it is not a guaranteed 
feature of the implementation.
+ */
 @Test
-public void test_getAbbreviatedName_Class_NegativeLen() {
 
 Review comment:
   Let's not change the visibility of test classes and methods please.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Commented] (BEANUTILS-523) Release 1.9.4 has broken every single OSGi installation out there which uses it through Require-Bundle

2019-09-24 Thread Melloware (Jira)


[ 
https://issues.apache.org/jira/browse/BEANUTILS-523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16936692#comment-16936692
 ] 

Melloware commented on BEANUTILS-523:
-

[~chtompki] Any thought on this one?

> Release 1.9.4 has broken every single OSGi installation out there which uses 
> it through Require-Bundle
> --
>
> Key: BEANUTILS-523
> URL: https://issues.apache.org/jira/browse/BEANUTILS-523
> Project: Commons BeanUtils
>  Issue Type: Bug
>Affects Versions: 1.9.4
>Reporter: Václav Haisman
>Priority: Blocker
>  Labels: OSGi
>
> The released Beanutils 1.9.4 OSGi manifest has changed Bundle-SymbolicName 
> from previous org.apache.commons.beanutils to 
> org.apache.commons.commons-beanutils. 
> Please release a patch version that reverses this change ASAP. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (VALIDATOR-459) Allow UrlValidator/DomainValidator to skip the TLD validation

2019-09-24 Thread Gilles (Jira)


[ 
https://issues.apache.org/jira/browse/VALIDATOR-459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16936568#comment-16936568
 ] 

Gilles commented on VALIDATOR-459:
--

Feature request and discussion should be posted on the "dev" ML.

> Allow UrlValidator/DomainValidator to skip the TLD validation
> -
>
> Key: VALIDATOR-459
> URL: https://issues.apache.org/jira/browse/VALIDATOR-459
> Project: Commons Validator
>  Issue Type: Improvement
>Reporter: Christophe Lé
>Priority: Minor
>
> Hello there,
> One of my applications is validating URLs which can be on the internet OR in 
> the same network. Those from the same network are ending with *.local*. 
> Unfortunately, *.local* is not referenced anywhere in DomainValidator.
> Besides, whenever new TLDs are out, the library has to be updated with those.
> I was wondering if adding a flag to skip the TLD validation would be an 
> interesting feature to have?
>  # Whatever exotic internal TLD an application is using, if an URL points to 
> nothing it doesn't matter since ultimately, the component which is going to 
> initiate a network call will fail.
>  # If people doesn't bother about the legitimacy of a TLD, they should not be 
> _forced_ to update to the latest version of the library whenever a new TLD is 
> out. Such action should be motivated for feature or security reasons.
> This flag would only be meaningful if you don't really care about the 
> legitimacy of a TLD.
> What do you think?
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (POOL-376) invalidateObject should not return NullPointerException

2019-09-24 Thread M Sazzadul Hoque (Jira)


 [ 
https://issues.apache.org/jira/browse/POOL-376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

M Sazzadul Hoque updated POOL-376:
--
Description: 
{{GenericObjectPool.invalidateObject(T obj)}} should not return 
{{NullPointerException}} when obj is not null.

Please see following stack trace:
{code:java}
Caused by: java.lang.NullPointerException
at 
org.apache.commons.pool2.impl.LinkedBlockingDeque.putLast(LinkedBlockingDeque.java:454)
at 
org.apache.commons.pool2.impl.LinkedBlockingDeque.put(LinkedBlockingDeque.java:788)
at 
org.apache.commons.pool2.impl.GenericObjectPool.destroy(GenericObjectPool.java:939)
at 
org.apache.commons.pool2.impl.GenericObjectPool.invalidateObject(GenericObjectPool.java:618)
{code}
Apparent reason: In {{destroy(PooledObject toDestroy)}}, create() may return 
null even though {{toDestroy}} is already destroyed.

*Please make the fix available for JDK 1.7.*

  was:
{{GenericObjectPool.invalidateObject(T obj)}} should not return 
{{NullPointerException}} when obj is not null.

Please see following stack trace:
{code:java}
Caused by: java.lang.NullPointerException
at 
org.apache.commons.pool2.impl.LinkedBlockingDeque.putLast(LinkedBlockingDeque.java:454)
at 
org.apache.commons.pool2.impl.LinkedBlockingDeque.put(LinkedBlockingDeque.java:788)
at 
org.apache.commons.pool2.impl.GenericObjectPool.destroy(GenericObjectPool.java:939)
at 
org.apache.commons.pool2.impl.GenericObjectPool.invalidateObject(GenericObjectPool.java:618)
{code}
Apparent reason: In {{destroy(PooledObject toDestroy)}}, create() may return 
null even though {{toDestroy}} is already destroyed.

Please make the fix available for JDK 1.7.


> invalidateObject should not return NullPointerException
> ---
>
> Key: POOL-376
> URL: https://issues.apache.org/jira/browse/POOL-376
> Project: Commons Pool
>  Issue Type: Bug
>Affects Versions: 2.6.2
>Reporter: M Sazzadul Hoque
>Priority: Critical
>  Labels: pull-request-available, pull-requests-available
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> {{GenericObjectPool.invalidateObject(T obj)}} should not return 
> {{NullPointerException}} when obj is not null.
> Please see following stack trace:
> {code:java}
> Caused by: java.lang.NullPointerException
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.putLast(LinkedBlockingDeque.java:454)
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.put(LinkedBlockingDeque.java:788)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.destroy(GenericObjectPool.java:939)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.invalidateObject(GenericObjectPool.java:618)
> {code}
> Apparent reason: In {{destroy(PooledObject toDestroy)}}, create() may 
> return null even though {{toDestroy}} is already destroyed.
> *Please make the fix available for JDK 1.7.*



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (POOL-376) invalidateObject should not return NullPointerException

2019-09-24 Thread M Sazzadul Hoque (Jira)


 [ 
https://issues.apache.org/jira/browse/POOL-376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

M Sazzadul Hoque updated POOL-376:
--
Priority: Critical  (was: Major)

> invalidateObject should not return NullPointerException
> ---
>
> Key: POOL-376
> URL: https://issues.apache.org/jira/browse/POOL-376
> Project: Commons Pool
>  Issue Type: Bug
>Affects Versions: 2.6.2
>Reporter: M Sazzadul Hoque
>Priority: Critical
>  Labels: pull-request-available, pull-requests-available
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> {{GenericObjectPool.invalidateObject(T obj)}} should not return 
> {{NullPointerException}} when obj is not null.
> Please see following stack trace:
> {code:java}
> Caused by: java.lang.NullPointerException
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.putLast(LinkedBlockingDeque.java:454)
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.put(LinkedBlockingDeque.java:788)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.destroy(GenericObjectPool.java:939)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.invalidateObject(GenericObjectPool.java:618)
> {code}
> Apparent reason: In {{destroy(PooledObject toDestroy)}}, create() may 
> return null even though {{toDestroy}} is already destroyed.
> Please make the fix available for JDK 1.7.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (VALIDATOR-459) Allow UrlValidator/DomainValidator to skip the TLD validation

2019-09-24 Thread Michael Osipov (Jira)


[ 
https://issues.apache.org/jira/browse/VALIDATOR-459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16936562#comment-16936562
 ] 

Michael Osipov commented on VALIDATOR-459:
--

{{.local}} is a reserved domain for special usecases and not intended to be 
used the way you use it. It is a clear abuse. Please read: 
[https://en.wikipedia.org/wiki/.local]

> Allow UrlValidator/DomainValidator to skip the TLD validation
> -
>
> Key: VALIDATOR-459
> URL: https://issues.apache.org/jira/browse/VALIDATOR-459
> Project: Commons Validator
>  Issue Type: Improvement
>Reporter: Christophe Lé
>Priority: Minor
>
> Hello there,
> One of my applications is validating URLs which can be on the internet OR in 
> the same network. Those from the same network are ending with *.local*. 
> Unfortunately, *.local* is not referenced anywhere in DomainValidator.
> Besides, whenever new TLDs are out, the library has to be updated with those.
> I was wondering if adding a flag to skip the TLD validation would be an 
> interesting feature to have?
>  # Whatever exotic internal TLD an application is using, if an URL points to 
> nothing it doesn't matter since ultimately, the component which is going to 
> initiate a network call will fail.
>  # If people doesn't bother about the legitimacy of a TLD, they should not be 
> _forced_ to update to the latest version of the library whenever a new TLD is 
> out. Such action should be motivated for feature or security reasons.
> This flag would only be meaningful if you don't really care about the 
> legitimacy of a TLD.
> What do you think?
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (POOL-376) invalidateObject should not return NullPointerException

2019-09-24 Thread M Sazzadul Hoque (Jira)


 [ 
https://issues.apache.org/jira/browse/POOL-376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

M Sazzadul Hoque updated POOL-376:
--
Labels: pull-request-available pull-requests-available  (was: )

> invalidateObject should not return NullPointerException
> ---
>
> Key: POOL-376
> URL: https://issues.apache.org/jira/browse/POOL-376
> Project: Commons Pool
>  Issue Type: Bug
>Affects Versions: 2.6.2
>Reporter: M Sazzadul Hoque
>Priority: Major
>  Labels: pull-request-available, pull-requests-available
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> {{GenericObjectPool.invalidateObject(T obj)}} should not return 
> {{NullPointerException}} when obj is not null.
> Please see following stack trace:
> {code:java}
> Caused by: java.lang.NullPointerException
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.putLast(LinkedBlockingDeque.java:454)
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.put(LinkedBlockingDeque.java:788)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.destroy(GenericObjectPool.java:939)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.invalidateObject(GenericObjectPool.java:618)
> {code}
> Apparent reason: In {{destroy(PooledObject toDestroy)}}, create() may 
> return null even though {{toDestroy}} is already destroyed.
> Please make the fix available for JDK 1.7.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-imaging] kinow merged pull request #52: Fix javadoc for Java 13 (heading out of order)

2019-09-24 Thread GitBox
kinow merged pull request #52: Fix javadoc for Java 13 (heading out of order)
URL: https://github.com/apache/commons-imaging/pull/52
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Updated] (POOL-376) invalidateObject should not return NullPointerException

2019-09-24 Thread M Sazzadul Hoque (Jira)


 [ 
https://issues.apache.org/jira/browse/POOL-376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

M Sazzadul Hoque updated POOL-376:
--
Issue Type: Bug  (was: Improvement)

> invalidateObject should not return NullPointerException
> ---
>
> Key: POOL-376
> URL: https://issues.apache.org/jira/browse/POOL-376
> Project: Commons Pool
>  Issue Type: Bug
>Affects Versions: 2.6.2
>Reporter: M Sazzadul Hoque
>Priority: Major
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> {{GenericObjectPool.invalidateObject(T obj)}} should not return 
> {{NullPointerException}} when obj is not null.
> Please see following stack trace:
> {code:java}
> Caused by: java.lang.NullPointerException
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.putLast(LinkedBlockingDeque.java:454)
> at 
> org.apache.commons.pool2.impl.LinkedBlockingDeque.put(LinkedBlockingDeque.java:788)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.destroy(GenericObjectPool.java:939)
> at 
> org.apache.commons.pool2.impl.GenericObjectPool.invalidateObject(GenericObjectPool.java:618)
> {code}
> Apparent reason: In {{destroy(PooledObject toDestroy)}}, create() may 
> return null even though {{toDestroy}} is already destroyed.
> Please make the fix available for JDK 1.7.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-imaging] coveralls edited a comment on issue #52: Fix javadoc for Java 13 (heading out of order)

2019-09-24 Thread GitBox
coveralls edited a comment on issue #52: Fix javadoc for Java 13 (heading out 
of order)
URL: https://github.com/apache/commons-imaging/pull/52#issuecomment-522304064
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/25890339/badge)](https://coveralls.io/builds/25890339)
   
   Coverage remained the same at 74.416% when pulling 
**8f84ea015b9ccfd0f885211e8f97e740d8f206e1 on kinow:fix-java-13-javadoc** into 
**b684eea67f98010b67db9587dbfb0b1a2d02bb1a on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-imaging] kinow commented on issue #52: Fix javadoc for Java 13 (heading out of order)

2019-09-24 Thread GitBox
kinow commented on issue #52: Fix javadoc for Java 13 (heading out of order)
URL: https://github.com/apache/commons-imaging/pull/52#issuecomment-534442113
 
 
   Related issue in the JDK https://bugs.openjdk.java.net/browse/JDK-8223552


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-imaging] kinow closed pull request #53: Close OutputStream before toByteArray() on underlying ByteArrayOutputStream

2019-09-24 Thread GitBox
kinow closed pull request #53: Close OutputStream before toByteArray() on 
underlying ByteArrayOutputStream
URL: https://github.com/apache/commons-imaging/pull/53
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-imaging] kinow commented on issue #53: Close OutputStream before toByteArray() on underlying ByteArrayOutputStream

2019-09-24 Thread GitBox
kinow commented on issue #53: Close OutputStream before toByteArray() on 
underlying ByteArrayOutputStream
URL: https://github.com/apache/commons-imaging/pull/53#issuecomment-534433388
 
 
   Closing as per comment above. I've added a comment 
(b684eea67f98010b67db9587dbfb0b1a2d02bb1a) to let other developers know that 
the resource is intentionally left open. Thanks!


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services