This is an automated email from the ASF dual-hosted git repository. kturner pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new fc4bc695fd Add getData methods to Key that populate ArrayByteSequence (#4779) fc4bc695fd is described below commit fc4bc695fd35ce95a70e8e7270b204561f36bc05 Author: John K <69256191+meatballspaghe...@users.noreply.github.com> AuthorDate: Thu Aug 1 19:09:51 2024 -0400 Add getData methods to Key that populate ArrayByteSequence (#4779) Add methods getRowData, getColumnFamilyData, and getColumnQualifierData which each return ArrayByteSequence objects in Key.java. Modeled after getColumnVisibilityData method added in #4735. Fixes #4749 --- .../java/org/apache/accumulo/core/data/Key.java | 54 ++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/data/Key.java b/core/src/main/java/org/apache/accumulo/core/data/Key.java index 7d4b613af0..d6f0ebccf7 100644 --- a/core/src/main/java/org/apache/accumulo/core/data/Key.java +++ b/core/src/main/java/org/apache/accumulo/core/data/Key.java @@ -657,6 +657,21 @@ public class Key implements WritableComparable<Key>, Cloneable { return new ArrayByteSequence(row); } + /** + * Writes the row ID into the given <code>ArrayByteSequence</code> without allocating new object + * by using {@link org.apache.accumulo.core.data.ArrayByteSequence#reset(byte[], int, int)} + * method. Using this updates existing ArrayByteSequence object with reference to row data, rather + * than copying row data. + * + * @param r <code>ArrayByteSequence</code> object to copy into + * @return the <code>ArrayByteSequence</code> that was passed in + * @since 3.1.0 + */ + public ArrayByteSequence getRowData(ArrayByteSequence r) { + r.reset(row, 0, row.length); + return r; + } + /** * Gets the row ID as a <code>Text</code> object. * @@ -686,6 +701,21 @@ public class Key implements WritableComparable<Key>, Cloneable { return new ArrayByteSequence(colFamily); } + /** + * Writes the column family into the given <code>ArrayByteSequence</code> without allocating new + * object by using {@link org.apache.accumulo.core.data.ArrayByteSequence#reset(byte[], int, int)} + * method. Using this updates existing ArrayByteSequence object with reference to column family + * data, rather than copying column family data. + * + * @param cf <code>ArrayByteSequence</code> object to copy into + * @return the <code>ArrayByteSequence</code> that was passed in + * @since 3.1.0 + */ + public ArrayByteSequence getColumnFamilyData(ArrayByteSequence cf) { + cf.reset(colFamily, 0, colFamily.length); + return cf; + } + /** * Writes the column family into the given <code>Text</code>. This method gives users control over * allocation of Text objects by copying into the passed in text. @@ -729,6 +759,22 @@ public class Key implements WritableComparable<Key>, Cloneable { return new ArrayByteSequence(colQualifier); } + /** + * Writes the column qualifier into the given <code>ArrayByteSequence</code> without allocating + * new object by using + * {@link org.apache.accumulo.core.data.ArrayByteSequence#reset(byte[], int, int)} method. Using + * this updates existing ArrayByteSequence object with reference to column qualifier data, rather + * than copying column qualifier data. + * + * @param cq <code>ArrayByteSequence</code> object to copy into + * @return the <code>ArrayByteSequence</code> that was passed in + * @since 3.1.0 + */ + public ArrayByteSequence getColumnQualifierData(ArrayByteSequence cq) { + cq.reset(colQualifier, 0, colQualifier.length); + return cq; + } + /** * Writes the column qualifier into the given <code>Text</code>. This method gives users control * over allocation of Text objects by copying into the passed in text. @@ -808,9 +854,11 @@ public class Key implements WritableComparable<Key>, Cloneable { } /** - * Writes the column visibility into the given <code>ArrayByteSequence</code>. This method gives - * users control over allocation of ArrayByteSequence objects by copying into the passed in - * ArrayByteSequence. + * Writes the column visibility into the given <code>ArrayByteSequence</code> without allocating + * new object by using + * {@link org.apache.accumulo.core.data.ArrayByteSequence#reset(byte[], int, int)} method. Using + * this updates existing ArrayByteSequence object with reference to column visibility data, rather + * than copying column visibility data. * * @param cv <code>ArrayByteSequence</code> object to copy into * @return the <code>ArrayByteSequence</code> that was passed in