This is an automated email from the ASF dual-hosted git repository. ddanielr pushed a commit to branch 2.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push: new 3c5326c89f Add visibility to grep searches (#4468) 3c5326c89f is described below commit 3c5326c89f12741f3b780e13d507d0894e0d2748 Author: alerman <awle...@uwe.nsa.gov> AuthorDate: Mon Apr 22 16:13:14 2024 +0000 Add visibility to grep searches (#4468) * Add visibility to grep * Add unit tests for grep vis * Update GrepCommand description --- .../accumulo/core/iterators/user/GrepIterator.java | 2 +- .../accumulo/core/iterators/user/GrepIteratorTest.java | 18 ++++++++++++++++++ .../apache/accumulo/shell/commands/GrepCommand.java | 2 +- .../java/org/apache/accumulo/test/shell/ShellIT.java | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java index ff55b2c3da..9e3fa110c8 100644 --- a/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java +++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java @@ -44,7 +44,7 @@ public class GrepIterator extends Filter { @Override public boolean accept(Key k, Value v) { return match(v.get()) || match(k.getRowData()) || match(k.getColumnFamilyData()) - || match(k.getColumnQualifierData()); + || match(k.getColumnQualifierData()) || match(k.getColumnVisibilityData()); } protected boolean match(ByteSequence bs) { diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java index 4a793e4e23..e1c0e30fbd 100644 --- a/core/src/test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java +++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/GrepIteratorTest.java @@ -48,9 +48,13 @@ public class GrepIteratorTest { public void init() { input = new TreeMap<>(); output = new TreeMap<>(); + input.put(new Key("abcdef", "xyz", "xyz", 0), new Value("xyz")); output.put(new Key("abcdef", "xyz", "xyz", 0), new Value("xyz")); + input.put(new Key("abcdef", "cv", "cv", "colvis", 0), new Value("cv")); + output.put(new Key("abcdef", "cv", "cv", "colvis", 0), new Value("cv")); + input.put(new Key("bdf", "ace", "xyz", 0), new Value("xyz")); input.put(new Key("bdf", "abcdef", "xyz", 0), new Value("xyz")); output.put(new Key("bdf", "abcdef", "xyz", 0), new Value("xyz")); @@ -97,6 +101,20 @@ public class GrepIteratorTest { GrepIterator.setTerm(is, "def"); gi.init(new SortedMapIterator(input), is.getOptions(), null); gi.seek(new Range(), EMPTY_COL_FAMS, false); + + checkEntries(gi, output); + + input = new TreeMap<>(); + output = new TreeMap<>(); + + input.put(new Key("abcdef", "cv", "cv", "colvis", 0), new Value("cv")); + input.put(new Key("abcdef", "cv", "cv", "nomatch", 0), new Value("cv")); + output.put(new Key("abcdef", "cv", "cv", "colvis", 0), new Value("cv")); + + GrepIterator.setTerm(is, "colvis"); + gi.init(new SortedMapIterator(input), is.getOptions(), null); + gi.seek(new Range(), EMPTY_COL_FAMS, false); + checkEntries(gi, output); } } diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/GrepCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/GrepCommand.java index f4b715fdd8..bc6e10651e 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/GrepCommand.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/GrepCommand.java @@ -124,7 +124,7 @@ public class GrepCommand extends ScanCommand { @Override public String description() { - return "searches each row, column family, column qualifier and value in a" + return "searches each row, column family, column qualifier, visibility, and value in a" + " table for a substring (not a regular expression), in parallel, on the server side"; } diff --git a/test/src/main/java/org/apache/accumulo/test/shell/ShellIT.java b/test/src/main/java/org/apache/accumulo/test/shell/ShellIT.java index 4f592791f7..650ebac7c3 100644 --- a/test/src/main/java/org/apache/accumulo/test/shell/ShellIT.java +++ b/test/src/main/java/org/apache/accumulo/test/shell/ShellIT.java @@ -464,6 +464,7 @@ public class ShellIT extends SharedMiniClusterBase { String expected = "r f:q [vis]\tv"; String expectedTimestamp = "r f:q [vis] 0\tv"; exec("grep", false, "No terms specified"); + exec("grep vis", true, expected); exec("grep non_matching_string", true, ""); // historically, showing few did not pertain to ColVis or Timestamp exec("grep r", true, expected);