/** * Returns the row ID as a byte sequence. This method returns a pointer to the key's internal data * and does not copy it. * * @return ByteSequence that points to the internal key row ID data */ public ByteSequence getRowData() { return new ArrayByteSequence(row); }
/** * Copy constructor. Copies contents of byteSequence. * * @since 2.0.0 */ public ArrayByteSequence(ByteSequence byteSequence) { this(copy(byteSequence)); }
/** * Extract the file name from the row suffix into the given {@link Text} * * @param k * Key to extract from * @param buff * Text to place file name into */ public static void getFile(Key k, Text buff) { requireNonNull(k); requireNonNull(buff); checkArgument(COLF_BYTE_SEQ.equals(k.getColumnFamilyData()), "Given metadata replication status key with incorrect colfam"); k.getRow(buff); buff.set(buff.getBytes(), section.getRowPrefix().length(), buff.getLength() - section.getRowPrefix().length()); } }
public static ByteSequence shorten(ByteSequence prev, ByteSequence current) { int minLen = Math.min(prev.length(), current.length()); for (int i = 0; i < minLen; i++) { int pb = 0xff & prev.byteAt(i); int cb = 0xff & current.byteAt(i); int diff = cb - pb; if (diff == 1) { int newLen = findNonFF(prev, i + 1); byte[] successor; if (newLen < prev.length()) { successor = Bytes.concat(prev.subSequence(0, newLen).toArray(), BFF); } else { successor = Bytes.concat(prev.subSequence(0, newLen).toArray(), B00); } return new ArrayByteSequence(successor); } else if (diff > 1) { byte[] copy = new byte[i + 1]; System.arraycopy(prev.subSequence(0, i + 1).toArray(), 0, copy, 0, i + 1); copy[i] = (byte) ((0xff & copy[i]) + 1); return new ArrayByteSequence(copy); } } ArrayByteSequence successor = new ArrayByteSequence(Bytes.concat(prev.toArray(), B00)); if (successor.equals(current)) { return null; } return successor; }
public static ByteSequence shorten(ByteSequence prev, ByteSequence current) { int minLen = Math.min(prev.length(), current.length()); for (int i = 0; i < minLen; i++) { int pb = 0xff & prev.byteAt(i); int cb = 0xff & current.byteAt(i); int diff = cb - pb; if (diff == 1) { int newLen = findNonFF(prev, i + 1); byte[] successor; if (newLen < prev.length()) { successor = Bytes.concat(prev.subSequence(0, newLen).toArray(), BFF); } else { successor = Bytes.concat(prev.subSequence(0, newLen).toArray(), B00); } return new ArrayByteSequence(successor); } else if (diff > 1) { byte[] copy = new byte[i + 1]; System.arraycopy(prev.subSequence(0, i + 1).toArray(), 0, copy, 0, i + 1); copy[i] = (byte) ((0xff & copy[i]) + 1); return new ArrayByteSequence(copy); } } ArrayByteSequence successor = new ArrayByteSequence(Bytes.concat(prev.toArray(), B00)); if (successor.equals(current)) { return null; } return successor; }
/** * Returns the column qualifier as a byte sequence. This method returns a pointer to the key's * internal data and does not copy it. * * @return ByteSequence that points to the internal key column qualifier data */ public ByteSequence getColumnQualifierData() { return new ArrayByteSequence(colQualifier); }
/** * Extract the file name from the row suffix into the given {@link Text} * * @param k * Key to extract from * @param buff * Text to place file name into */ public static void getFile(Key k, Text buff) { requireNonNull(k); requireNonNull(buff); checkArgument(COLF_BYTE_SEQ.equals(k.getColumnFamilyData()), "Given metadata replication status key with incorrect colfam"); k.getRow(buff); buff.set(buff.getBytes(), section.getRowPrefix().length(), buff.getLength() - section.getRowPrefix().length()); } }
/** * Returns the column visibility as a byte sequence. This method returns a pointer to the key's * internal data and does not copy it. * * @return ByteSequence that points to the internal key column visibility data */ public ByteSequence getColumnVisibilityData() { return new ArrayByteSequence(colVisibility); }
/** * Returns the column family as a byte sequence. This method returns a pointer to the key's * internal data and does not copy it. * * @return ByteSequence that points to the internal key column family data */ public ByteSequence getColumnFamilyData() { return new ArrayByteSequence(colFamily); }
public ByteSequence getTerm(byte expression[]) { if (type != NodeType.TERM) throw new RuntimeException(); if (expression[start] == '"') { // its a quoted term int qStart = start + 1; int qEnd = end - 1; return new ArrayByteSequence(expression, qStart, qEnd - qStart); } return new ArrayByteSequence(expression, start, end - start); } }
@Override public ByteSequence subSequence(int start, int end) { if (start > end || start < 0 || end > length) { throw new IllegalArgumentException("Bad start and/end start = " + start + " end=" + end + " offset=" + offset + " length=" + length); } return new ArrayByteSequence(data, offset + start, end - start); }
/** * Checks whether this object contains the given authorization. * * @param auth * authorization * @return true if authorization is in this collection */ public boolean contains(String auth) { return auths.contains(new ArrayByteSequence(auth)); }
/** * Checks whether this object contains the given authorization. * * @param auth * authorization, as a string encoded in UTF-8 * @return true if authorization is in this collection */ public boolean contains(byte[] auth) { return auths.contains(new ArrayByteSequence(auth)); }
/** * This method sets the expected value of a column. In order for the condition to pass the column * must exist and have this value. If a value is not set, then the column must be absent for the * condition to pass. * * @param value * value * @return this condition * @throws IllegalArgumentException * if value is null */ public Condition setValue(byte[] value) { checkArgument(value != null, "value is null"); this.val = new ArrayByteSequence(value); return this; }
/** * Creates a new condition. The initial column value and timestamp are null, and the initial * column visibility is empty. * * @param cf * column family * @param cq * column qualifier * @throws IllegalArgumentException * if any argument is null */ public Condition(byte[] cf, byte[] cq) { checkArgument(cf != null, "cf is null"); checkArgument(cq != null, "cq is null"); this.cf = new ArrayByteSequence(cf); this.cq = new ArrayByteSequence(cq); this.cv = EMPTY; }
public TermSource(SortedKeyValueIterator<Key,Value> iter, Text term, boolean notFlag) { this.iter = iter; this.term = term; this.notFlag = notFlag; // The desired column families for this source is the term itself this.seekColfams = Collections .singletonList(new ArrayByteSequence(term.getBytes(), 0, term.getLength())); }
public TermSource(SortedKeyValueIterator<Key,Value> iter, Text term) { this.iter = Objects.requireNonNull(iter); this.term = Objects.requireNonNull(term); // The desired column families for this source is the term itself this.seekColfams = Collections .singletonList(new ArrayByteSequence(term.getBytes(), 0, term.getLength())); // No current range until we're seek()'ed for the first time this.currentRange = null; }
/** * This method sets the expected value of a column. In order for the condition to pass the column * must exist and have this value. If a value is not set, then the column must be absent for the * condition to pass. See {@link #setValue(byte[])}. * * @param value * value * @return this condition * @throws IllegalArgumentException * if value is null */ public Condition setValue(Text value) { checkArgument(value != null, "value is null"); this.val = new ArrayByteSequence(value.getBytes(), 0, value.getLength()); return this; }
/** * This method sets the expected value of a column. In order for the condition to pass the column * must exist and have this value. If a value is not set, then the column must be absent for the * condition to pass. The passed-in character sequence is encoded as UTF-8. See * {@link #setValue(byte[])}. * * @param value * value * @return this condition * @throws IllegalArgumentException * if value is null */ public Condition setValue(CharSequence value) { checkArgument(value != null, "value is null"); this.val = new ArrayByteSequence(value.toString().getBytes(UTF_8)); return this; }
private ColumnQualifierFilter(SortedKeyValueIterator<Key,Value> iterator, Set<Column> columns) { super(iterator); this.columnFamilies = new HashSet<>(); this.columnsQualifiers = new HashMap<>(); for (Column col : columns) { if (col.columnQualifier != null) { ArrayByteSequence cq = new ArrayByteSequence(col.columnQualifier); HashSet<ByteSequence> cfset = this.columnsQualifiers.get(cq); if (cfset == null) { cfset = new HashSet<>(); this.columnsQualifiers.put(cq, cfset); } cfset.add(new ArrayByteSequence(col.columnFamily)); } else { // this whole column family should pass columnFamilies.add(new ArrayByteSequence(col.columnFamily)); } } }