Java Code Examples for org.apache.hadoop.hbase.util.Bytes#copy()
The following examples show how to use
org.apache.hadoop.hbase.util.Bytes#copy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Put.java From hbase with Apache License 2.0 | 6 votes |
/** * Create a Put operation for an immutable row key, using a given timestamp. * * @param row row key * @param ts timestamp * @param rowIsImmutable whether the input row is immutable. * Set to true if the caller can guarantee that * the row will not be changed for the Put duration. */ public Put(byte[] row, long ts, boolean rowIsImmutable) { // Check and set timestamp if (ts < 0) { throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); } this.ts = ts; // Deal with row according to rowIsImmutable checkRow(row); if (rowIsImmutable) { // Row is immutable this.row = row; // Do not make a local copy, but point to the provided byte array directly } else { // Row is not immutable this.row = Bytes.copy(row, 0, row.length); // Make a local copy } }
Example 2
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 5 votes |
private Map.Entry<Long, byte[]> getTimeRegion(byte[] key) { int offset = REGION_TIME_KEY_PREFIX.length; long time = getInvertedTime(Bytes.toLong(key, offset)); offset += Bytes.SIZEOF_LONG; byte[] regionName = Bytes.copy(key, offset, key.length - offset); return Maps.immutableEntry(time, regionName); }
Example 3
Source File: ImmutableScan.java From hbase with Apache License 2.0 | 5 votes |
@Override public byte[][] getFamilies() { final byte[][] families = this.delegateScan.getFamilies(); byte[][] cloneFamilies = new byte[families.length][]; for (int i = 0; i < families.length; i++) { cloneFamilies[i] = Bytes.copy(families[i]); } return cloneFamilies; }
Example 4
Source File: Put.java From hbase with Apache License 2.0 | 5 votes |
/** * We make a copy of the passed in row key to keep local. * @param rowArray * @param rowOffset * @param rowLength * @param ts */ public Put(byte [] rowArray, int rowOffset, int rowLength, long ts) { checkRow(rowArray, rowOffset, rowLength); this.row = Bytes.copy(rowArray, rowOffset, rowLength); this.ts = ts; if (ts < 0) { throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); } }
Example 5
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 5 votes |
private Map.Entry<Long, byte[]> getTimeRegion(byte[] key) { int offset = REGION_TIME_KEY_PREFIX.length; long time = getInvertedTime(Bytes.toLong(key, offset)); offset += Bytes.SIZEOF_LONG; byte[] regionName = Bytes.copy(key, offset, key.length - offset); return Maps.immutableEntry(time, regionName); }
Example 6
Source File: DocumentInterceptor.java From examples with Apache License 2.0 | 5 votes |
protected Document cellToAvro(Cell cell, Document reuse) throws IOException { byte[] value = Bytes.copy(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); decoder = DecoderFactory.get().binaryDecoder(value, decoder); reuse = reader.read(reuse, decoder); return reuse; }
Example 7
Source File: EquiDepthStreamHistogram.java From phoenix with Apache License 2.0 | 5 votes |
/** * Get the appropriate bar for the value, extending existing bar bounds to accommodate if necessary * @param value value to add * @return the bar for the value */ @VisibleForTesting Bar getBar(byte[] value) { Bar searchKey = new Bar(value, value); int searchIdx = Collections.binarySearch(this.bars, searchKey); if (searchIdx < 0) { // copy value so later changes by caller don't affect histogram results byte[] newBound = Bytes.copy(value); if (this.bars.size() == 0) { Bar firstBar = new Bar(newBound, newBound); bars.add(firstBar); return firstBar; } int expectedIndex = Math.abs(searchIdx + 1); // jdk binary search index if (expectedIndex == bars.size()) { // no bars >= value, need to extend rightBound of last bar Bar lastBar = bars.get(expectedIndex - 1); lastBar.setRightBoundExclusive(newBound); // actually inclusive for last bar return lastBar; } else { // extend leftBound of next greatest bar Bar nextBar = bars.get(expectedIndex); nextBar.setLeftBoundInclusive(newBound); return nextBar; } } else { return bars.get(searchIdx); } }
Example 8
Source File: RowMutations.java From hbase with Apache License 2.0 | 5 votes |
/** * Create an atomic mutation for the specified row. * @param row row key * @param initialCapacity the initial capacity of the RowMutations */ public RowMutations(byte [] row, int initialCapacity) { this.row = Bytes.copy(Mutation.checkRow(row)); if (initialCapacity <= 0) { this.mutations = new ArrayList<>(); } else { this.mutations = new ArrayList<>(initialCapacity); } }
Example 9
Source File: RegionPartition.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public boolean overlapsRange(byte[] start,int startOff,int startLen,byte[] stop,int stopOff,int stopLen){ byte[] s; byte[] e; if(startOff==0 && startLen==start.length) s=start; else s=Bytes.copy(start,startOff,startLen); if(stopOff==0 && stopLen==stop.length) e=stop; else e=Bytes.copy(stop,stopOff,stopLen); return region.getRegionInfo().containsRange(s,e); }
Example 10
Source File: TransactionVisibilityFilter.java From phoenix-tephra with Apache License 2.0 | 4 votes |
public void addFamilyDelete(Cell delete) { this.familyDeleteTs = delete.getTimestamp(); this.rowKey = Bytes.copy(delete.getRowArray(), delete.getRowOffset(), delete.getRowLength()); }
Example 11
Source File: ColumnFamilyDescriptorBuilder.java From hbase with Apache License 2.0 | 4 votes |
@Override public byte[] getName() { return Bytes.copy(name); }
Example 12
Source File: MultiTableHFileOutputFormat.java From hbase with Apache License 2.0 | 4 votes |
protected static byte[] getSuffix(byte[] keyBytes) { int separatorIdx = validateCompositeKey(keyBytes); return Bytes.copy(keyBytes, separatorIdx+1, keyBytes.length - separatorIdx - 1); }
Example 13
Source File: TransactionVisibilityFilter.java From phoenix-tephra with Apache License 2.0 | 4 votes |
public void addFamilyDelete(Cell delete) { this.familyDeleteTs = delete.getTimestamp(); this.rowKey = Bytes.copy(delete.getRowArray(), delete.getRowOffset(), delete.getRowLength()); }
Example 14
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 4 votes |
private byte[] getRegionFromKey(byte[] regionKey) { int prefixLen = REGION_KEY_PREFIX.length; return Bytes.copy(regionKey, prefixLen, regionKey.length - prefixLen); }
Example 15
Source File: TransactionVisibilityFilter.java From phoenix-tephra with Apache License 2.0 | 4 votes |
public void addFamilyDelete(Cell delete) { this.familyDeleteTs = delete.getTimestamp(); this.rowKey = Bytes.copy(delete.getRowArray(), delete.getRowOffset(), delete.getRowLength()); }
Example 16
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 4 votes |
private byte[] getEmptyRegionFromKey(byte[] key) { int prefixLen = EMPTY_REGION_TIME_KEY_PREFIX.length + Bytes.SIZEOF_LONG; return Bytes.copy(key, prefixLen, key.length - prefixLen); }
Example 17
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 4 votes |
private byte[] getEmptyRegionFromKey(byte[] key) { int prefixLen = EMPTY_REGION_TIME_KEY_PREFIX.length + Bytes.SIZEOF_LONG; return Bytes.copy(key, prefixLen, key.length - prefixLen); }
Example 18
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 4 votes |
private byte[] getRegionFromKey(byte[] regionKey) { int prefixLen = REGION_KEY_PREFIX.length; return Bytes.copy(regionKey, prefixLen, regionKey.length - prefixLen); }
Example 19
Source File: MultiTableHFileOutputFormat.java From hbase with Apache License 2.0 | 4 votes |
protected static byte[] getTableName(byte[] keyBytes) { int separatorIdx = validateCompositeKey(keyBytes); return Bytes.copy(keyBytes, 0, separatorIdx); }
Example 20
Source File: Increment.java From hbase with Apache License 2.0 | 2 votes |
/** * Create a Increment operation for the specified row. * <p> * At least one column must be incremented. * @param row row key (we will make a copy of this). */ public Increment(final byte [] row, final int offset, final int length) { checkRow(row, offset, length); this.row = Bytes.copy(row, offset, length); }