Skip to content

Commit

Permalink
Fix warning and usage of ByteArraySet.toArray (#79)
Browse files Browse the repository at this point in the history
* Use ByteArraySet

* Simplified equals logic

* Update MultiIndex

* Update ByteArray

* Revert ByteArraySet changes (#82)

Co-authored-by: Quentin LeCorre <quentin@jwplayer.com>

* Revert cache update changes

* Addressed comments

Co-authored-by: Quentin LeCorre <quentin@jwplayer.com>
Co-authored-by: Eric Weaver <eweaver@jwplayer.com>
  • Loading branch information
3 people authored Nov 17, 2020
1 parent 35bf288 commit 0fde4f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/jwplayer/southpaw/index/MultiIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public Set<String> verifyIndexState() {
AbstractMap.SimpleEntry<byte[], byte[]> pair = iter.next();
ByteArray revIndexPrimaryKey = new ByteArray(pair.getKey());
ByteArraySet revIndexForeignKeySet = ByteArraySet.deserialize(pair.getValue());
for (ByteArray indexPrimaryKey : revIndexForeignKeySet.toArray()) {
for (ByteArray indexPrimaryKey : revIndexForeignKeySet) {
ByteArraySet indexForeignKeySet = getIndexEntry(indexPrimaryKey);

if(indexForeignKeySet != null) {
Expand All @@ -323,7 +323,7 @@ public Set<String> verifyReverseIndexState() {
AbstractMap.SimpleEntry<byte[], byte[]> pair = iter.next();
ByteArray indexPrimaryKey = new ByteArray(pair.getKey());
ByteArraySet indexForeignKeySet = ByteArraySet.deserialize(pair.getValue());
for (ByteArray revIndexPrimaryKey : indexForeignKeySet.toArray()) {
for (ByteArray revIndexPrimaryKey : indexForeignKeySet) {
ByteArraySet revIndexforeignKeySet = getForeignKeys(revIndexPrimaryKey);

if(revIndexforeignKeySet != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jwplayer/southpaw/util/ByteArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* Wrapper class for byte arrays so we can use them as keys in maps.
*/
public class ByteArray implements Comparable<ByteArray>, Serializable {
private static final long serialVersionUID = -6277178128299377659L;
private static final Bytes.ByteArrayComparator comparator = Bytes.BYTES_LEXICO_COMPARATOR;
private byte[] bytes;

Expand Down Expand Up @@ -108,7 +109,6 @@ public boolean equals(Object object) {
* @param bytes - The bytes to convert
* @return - A collection of ByteArrays
*/
@SuppressWarnings("unchecked")
public static Set<ByteArray> fromBytes(byte[] bytes) {
Set<ByteArray> set = new HashSet<>();
int index = 0;
Expand Down

0 comments on commit 0fde4f7

Please sign in to comment.