Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deepCopy to VisibilityFilter #5385

Open
wants to merge 1 commit into
base: 2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> op
this.cache = new LRUMap<>(1000);
}

@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
VisibilityFilter result = (VisibilityFilter) super.deepCopy(env);
result.filterInvalid = this.filterInvalid;
result.accessEvaluator = this.accessEvaluator;
result.cache = this.cache;
return result;
}

@Override
public boolean accept(Key k, Value v) {
ByteSequence testVis = k.getColumnVisibilityData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.accumulo.core.iterators.user;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -242,4 +243,17 @@ public void testStaticConfigurators() {
assertEquals(new Authorizations("abc", "def").serialize(), opts.get("auths"));
}

@Test
public void testDeepCopyAfterInit() throws IOException {
IteratorSetting is = new IteratorSetting(1, VisibilityFilter.class);
VisibilityFilter.setAuthorizations(is, new Authorizations("abc"));
Map<String,String> opts = is.getOptions();
Filter filter = new VisibilityFilter();
TreeMap<Key,Value> source = new TreeMap<>();
filter.init(new SortedMapIterator(source), opts, null);
Filter copyFilter = (Filter) filter.deepCopy(null);
Key k = new Key("row", "cf", "cq", "abc");
assertTrue(copyFilter.accept(k, new Value()));
}

}
Loading