org.apache.hadoop.hbase.CellUtil Java Examples
The following examples show how to use
org.apache.hadoop.hbase.CellUtil.
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: FromClientSideBase.java From hbase with Apache License 2.0 | 6 votes |
protected void assertSingleResult(Result result, byte [] row, byte [] family, byte [] qualifier, byte [] value) { assertTrue("Expected row [" + Bytes.toString(row) + "] " + "Got row [" + Bytes.toString(result.getRow()) +"]", equals(row, result.getRow())); assertEquals("Expected a single key but result contains " + result.size(), 1, result.size()); Cell kv = result.rawCells()[0]; assertTrue("Expected family [" + Bytes.toString(family) + "] " + "Got family [" + Bytes.toString(CellUtil.cloneFamily(kv)) + "]", equals(family, CellUtil.cloneFamily(kv))); assertTrue("Expected qualifier [" + Bytes.toString(qualifier) + "] " + "Got qualifier [" + Bytes.toString(CellUtil.cloneQualifier(kv)) + "]", equals(qualifier, CellUtil.cloneQualifier(kv))); assertTrue("Expected value [" + Bytes.toString(value) + "] " + "Got value [" + Bytes.toString(CellUtil.cloneValue(kv)) + "]", equals(value, CellUtil.cloneValue(kv))); }
Example #2
Source File: JobHistoryRawService.java From hraven with Apache License 2.0 | 6 votes |
/** * attempts to approximately set the job submit time based on the last * modification time of the job history file * @param value result * @return approximate job submit time * @throws MissingColumnInResultException */ public long getApproxSubmitTime(Result value) throws MissingColumnInResultException { if (value == null) { throw new IllegalArgumentException( "Cannot get last modification time from " + "a null hbase result"); } Cell cell = value.getColumnLatestCell(Constants.INFO_FAM_BYTES, Constants.JOBHISTORY_LAST_MODIFIED_COL_BYTES); if (cell == null) { throw new MissingColumnInResultException(Constants.INFO_FAM_BYTES, Constants.JOBHISTORY_LAST_MODIFIED_COL_BYTES); } byte[] lastModTimeBytes = CellUtil.cloneValue(cell); // we try to approximately set the job submit time based on when the job // history file // was last modified and an average job duration long lastModTime = Bytes.toLong(lastModTimeBytes); long jobSubmitTimeMillis = lastModTime - Constants.AVERGAE_JOB_DURATION; LOG.debug("Approximate job submit time is " + jobSubmitTimeMillis + " based on " + lastModTime); return jobSubmitTimeMillis; }
Example #3
Source File: ResponseTimeMapper.java From pinpoint with Apache License 2.0 | 6 votes |
@Override public ResponseTime mapRow(Result result, int rowNum) throws Exception { if (result.isEmpty()) { return null; } final byte[] rowKey = getOriginalKey(result.getRow()); ResponseTime responseTime = createResponseTime(rowKey); for (Cell cell : result.rawCells()) { if (CellUtil.matchingFamily(cell, HbaseColumnFamily.MAP_STATISTICS_SELF_VER2_COUNTER.getName())) { recordColumn(responseTime, cell); } if (logger.isDebugEnabled()) { String columnFamily = Bytes.toString(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()); logger.debug("unknown column family:{}", columnFamily); } } return responseTime; }
Example #4
Source File: Indexer.java From hbase-indexer with Apache License 2.0 | 6 votes |
/** * Delete all values for a single column family from Solr. */ private void deleteFamily(KeyValue deleteKeyValue, SolrUpdateCollector updateCollector, UniqueKeyFormatter uniqueKeyFormatter, byte[] tableName) { String rowField = conf.getRowField(); String cfField = conf.getColumnFamilyField(); String rowValue; String familyValue; if (uniqueKeyFormatter instanceof UniqueTableKeyFormatter) { UniqueTableKeyFormatter uniqueTableKeyFormatter = (UniqueTableKeyFormatter) uniqueKeyFormatter; rowValue = uniqueTableKeyFormatter.formatRow(CellUtil.cloneRow(deleteKeyValue), tableName); familyValue = uniqueTableKeyFormatter.formatFamily(CellUtil.cloneFamily(deleteKeyValue), tableName); } else { rowValue = uniqueKeyFormatter.formatRow(CellUtil.cloneRow(deleteKeyValue)); familyValue = uniqueKeyFormatter.formatFamily(CellUtil.cloneFamily(deleteKeyValue)); } if (rowField != null && cfField != null) { updateCollector.deleteByQuery(String.format("(%s:%s)AND(%s:%s)", rowField, rowValue, cfField, familyValue)); } else { log.warn(String.format( "Can't delete row %s and family %s from Solr because row and/or family fields not included in the indexer configuration", rowValue, familyValue)); } }
Example #5
Source File: ProtobufLogTestHelper.java From hbase with Apache License 2.0 | 6 votes |
public static void doRead(ProtobufLogReader reader, boolean withTrailer, RegionInfo hri, TableName tableName, int columnCount, int recordCount, byte[] row, long timestamp) throws IOException { if (withTrailer) { assertNotNull(reader.trailer); } else { assertNull(reader.trailer); } for (int i = 0; i < recordCount; ++i) { WAL.Entry entry = reader.next(); assertNotNull(entry); assertEquals(columnCount, entry.getEdit().size()); assertArrayEquals(hri.getEncodedNameAsBytes(), entry.getKey().getEncodedRegionName()); assertEquals(tableName, entry.getKey().getTableName()); int idx = 0; for (Cell val : entry.getEdit().getCells()) { assertTrue(Bytes.equals(row, 0, row.length, val.getRowArray(), val.getRowOffset(), val.getRowLength())); assertArrayEquals(toValue(i, idx), CellUtil.cloneValue(val)); idx++; } } assertNull(reader.next()); }
Example #6
Source File: TestFromClientSide5.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testAppendWithoutWAL() throws Exception { List<Result> resultsWithWal = doAppend(true); List<Result> resultsWithoutWal = doAppend(false); assertEquals(resultsWithWal.size(), resultsWithoutWal.size()); for (int i = 0; i != resultsWithWal.size(); ++i) { Result resultWithWal = resultsWithWal.get(i); Result resultWithoutWal = resultsWithoutWal.get(i); assertEquals(resultWithWal.rawCells().length, resultWithoutWal.rawCells().length); for (int j = 0; j != resultWithWal.rawCells().length; ++j) { Cell cellWithWal = resultWithWal.rawCells()[j]; Cell cellWithoutWal = resultWithoutWal.rawCells()[j]; assertArrayEquals(CellUtil.cloneRow(cellWithWal), CellUtil.cloneRow(cellWithoutWal)); assertArrayEquals(CellUtil.cloneFamily(cellWithWal), CellUtil.cloneFamily(cellWithoutWal)); assertArrayEquals(CellUtil.cloneQualifier(cellWithWal), CellUtil.cloneQualifier(cellWithoutWal)); assertArrayEquals(CellUtil.cloneValue(cellWithWal), CellUtil.cloneValue(cellWithoutWal)); } } }
Example #7
Source File: ApplyAndFilterDeletesFilter.java From phoenix with Apache License 2.0 | 6 votes |
/** * @param next * @return */ public boolean matchesPoint(KeyValue next) { // point deletes only apply to the exact KV that they reference, so we only need to ensure // that the timestamp matches exactly. Because we sort by timestamp first, either the next // keyvalue has the exact timestamp or is an older (smaller) timestamp, and we can allow that // one. if (pointDelete != null && CellUtil.matchingFamily(pointDelete, next) && CellUtil.matchingQualifier(pointDelete, next)) { if (pointDelete.getTimestamp() == next.getTimestamp()) { return true; } // clear the point delete since the TS must not be matching coveringDelete.pointDelete = null; } return false; }
Example #8
Source File: TransactionVisibilityFilter.java From phoenix-tephra with Apache License 2.0 | 6 votes |
@Override public Cell transformCell(Cell cell) throws IOException { // Convert Tephra deletes back into HBase deletes if (tx.getVisibilityLevel() == Transaction.VisibilityLevel.SNAPSHOT_ALL) { if (DeleteTracker.isFamilyDelete(cell)) { return new KeyValue(CellUtil.cloneRow(cell), CellUtil.cloneFamily(cell), null, cell.getTimestamp(), KeyValue.Type.DeleteFamily); } else if (isColumnDelete(cell)) { // Note: in some cases KeyValue.Type.Delete is used in Delete object, // and in some other cases KeyValue.Type.DeleteColumn is used. // Since Tephra cannot distinguish between the two, we return KeyValue.Type.DeleteColumn. // KeyValue.Type.DeleteColumn makes both CellUtil.isDelete and CellUtil.isDeleteColumns return true, and will // work in both cases. return new KeyValue(CellUtil.cloneRow(cell), CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell), cell.getTimestamp(), KeyValue.Type.DeleteColumn); } } return cell; }
Example #9
Source File: TransactionAwareHTableTest.java From phoenix-tephra with Apache License 2.0 | 6 votes |
private void verifyRows(HTableInterface table, Get get, List<byte[]> expectedValues) throws Exception { Result result = table.get(get); if (expectedValues == null) { assertTrue(result.isEmpty()); } else { assertFalse(result.isEmpty()); byte[] family = TestBytes.family; byte[] col = TestBytes.qualifier; if (get.hasFamilies()) { family = get.getFamilyMap().keySet().iterator().next(); col = get.getFamilyMap().get(family).first(); } Iterator<Cell> it = result.getColumnCells(family, col).iterator(); for (byte[] expectedValue : expectedValues) { Assert.assertTrue(it.hasNext()); assertArrayEquals(expectedValue, CellUtil.cloneValue(it.next())); } } }
Example #10
Source File: TestResult.java From hbase with Apache License 2.0 | 6 votes |
public void testBasicGetColumn() throws Exception { KeyValue [] kvs = genKVs(row, family, value, 1, 100); Arrays.sort(kvs, CellComparator.getInstance()); Result r = Result.create(kvs); for (int i = 0; i < 100; ++i) { final byte[] qf = Bytes.toBytes(i); List<Cell> ks = r.getColumnCells(family, qf); assertEquals(1, ks.size()); assertTrue(CellUtil.matchingQualifier(ks.get(0), qf)); assertEquals(ks.get(0), r.getColumnLatestCell(family, qf)); } }
Example #11
Source File: IndexToolForNonTxGlobalIndexIT.java From phoenix with Apache License 2.0 | 6 votes |
private List<String> verifyRunStatusFromResultTable(Connection conn, Long scn, String indexTable, int totalRows, List<String> expectedStatus) throws SQLException, IOException { Table hIndexToolTable = conn.unwrap(PhoenixConnection.class).getQueryServices() .getTable(RESULT_TABLE_NAME_BYTES); Assert.assertEquals(totalRows, TestUtil.getRowCount(hIndexToolTable, false)); List<String> output = new ArrayList<>(); Scan s = new Scan(); s.setRowPrefixFilter(Bytes.toBytes(String.format("%s%s%s", scn, ROW_KEY_SEPARATOR, indexTable))); ResultScanner rs = hIndexToolTable.getScanner(s); int count =0; for(Result r : rs) { Assert.assertTrue(r != null); List<Cell> cells = r.getColumnCells(RESULT_TABLE_COLUMN_FAMILY, INDEX_TOOL_RUN_STATUS_BYTES); Assert.assertEquals(cells.size(), 1); Assert.assertTrue(Bytes.toString(CellUtil.cloneRow(cells.get(0))).startsWith(String.valueOf(scn))); output.add(Bytes.toString(CellUtil.cloneValue(cells.get(0)))); count++; } //for each region Assert.assertEquals(3, count); for(int i=0; i< count; i++) { Assert.assertEquals(expectedStatus.get(i), output.get(i)); } return output; }
Example #12
Source File: IndexRegionObserver.java From phoenix with Apache License 2.0 | 6 votes |
/** * IndexMaintainer.getIndexedColumns() returns the data column references for indexed columns. The data columns are * grouped into three classes, pk columns (data table pk columns), the indexed columns (the columns for which * we want to have indexing; they form the prefix for the primary key for the index table (after salt and tenant id)) * and covered columns. The purpose of this method is to find out if all the indexed columns are included in the * pending data table mutation pointed by multiMutation. */ private boolean hasAllIndexedColumns(IndexMaintainer indexMaintainer, MultiMutation multiMutation) { Map<byte[], List<Cell>> familyMap = multiMutation.getFamilyCellMap(); for (ColumnReference columnReference : indexMaintainer.getIndexedColumns()) { byte[] family = columnReference.getFamily(); List<Cell> cellList = familyMap.get(family); if (cellList == null) { return false; } boolean has = false; for (Cell cell : cellList) { if (CellUtil.matchingColumn(cell, family, columnReference.getQualifier())) { has = true; break; } } if (!has) { return false; } } return true; }
Example #13
Source File: TransactionVisibilityFilter.java From phoenix-tephra with Apache License 2.0 | 6 votes |
@Override public Cell transformCell(Cell cell) throws IOException { // Convert Tephra deletes back into HBase deletes if (tx.getVisibilityLevel() == Transaction.VisibilityLevel.SNAPSHOT_ALL) { if (DeleteTracker.isFamilyDelete(cell)) { return new KeyValue(CellUtil.cloneRow(cell), CellUtil.cloneFamily(cell), null, cell.getTimestamp(), KeyValue.Type.DeleteFamily); } else if (isColumnDelete(cell)) { // Note: in some cases KeyValue.Type.Delete is used in Delete object, // and in some other cases KeyValue.Type.DeleteColumn is used. // Since Tephra cannot distinguish between the two, we return KeyValue.Type.DeleteColumn. // KeyValue.Type.DeleteColumn makes both CellUtil.isDelete and CellUtil.isDeleteColumns return true, and will // work in both cases. return new KeyValue(CellUtil.cloneRow(cell), CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell), cell.getTimestamp(), KeyValue.Type.DeleteColumn); } } return cell; }
Example #14
Source File: HbaseSessions.java From hugegraph with Apache License 2.0 | 6 votes |
/** * Just for debug */ @SuppressWarnings("unused") private void dump(String table, Scan scan) throws IOException { System.out.println(String.format(">>>> scan table %s with %s", table, scan)); RowIterator iterator = this.scan(table, scan); while (iterator.hasNext()) { Result row = iterator.next(); System.out.println(StringEncoding.format(row.getRow())); CellScanner cellScanner = row.cellScanner(); while (cellScanner.advance()) { Cell cell = cellScanner.current(); byte[] key = CellUtil.cloneQualifier(cell); byte[] val = CellUtil.cloneValue(cell); System.out.println(String.format(" %s=%s", StringEncoding.format(key), StringEncoding.format(val))); } } }
Example #15
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 6 votes |
/** * Gets a list of {@link RegionPruneInfo} for given regions. Returns all regions if the given regions set is null. * * @param regions a set of regions * @return list of {@link RegionPruneInfo}s. * @throws IOException when not able to read the data from HBase */ public List<RegionPruneInfo> getPruneInfoForRegions(@Nullable SortedSet<byte[]> regions) throws IOException { List<RegionPruneInfo> regionPruneInfos = new ArrayList<>(); try (Table stateTable = stateTableSupplier.get()) { byte[] startRow = makeRegionKey(EMPTY_BYTE_ARRAY); Scan scan = new Scan(startRow, REGION_KEY_PREFIX_STOP); scan.addColumn(FAMILY, PRUNE_UPPER_BOUND_COL); try (ResultScanner scanner = stateTable.getScanner(scan)) { Result next; while ((next = scanner.next()) != null) { byte[] region = getRegionFromKey(next.getRow()); if (regions == null || regions.contains(region)) { Cell cell = next.getColumnLatestCell(FAMILY, PRUNE_UPPER_BOUND_COL); if (cell != null) { byte[] pruneUpperBoundBytes = CellUtil.cloneValue(cell); long timestamp = cell.getTimestamp(); regionPruneInfos.add(new RegionPruneInfo(region, Bytes.toStringBinary(region), Bytes.toLong(pruneUpperBoundBytes), timestamp)); } } } } } return Collections.unmodifiableList(regionPruneInfos); }
Example #16
Source File: MultipleColumnPrefixFilter.java From hbase with Apache License 2.0 | 6 votes |
public ReturnCode filterColumn(Cell cell) { byte [] qualifier = CellUtil.cloneQualifier(cell); TreeSet<byte []> lesserOrEqualPrefixes = (TreeSet<byte []>) sortedPrefixes.headSet(qualifier, true); if (lesserOrEqualPrefixes.size() != 0) { byte [] largestPrefixSmallerThanQualifier = lesserOrEqualPrefixes.last(); if (Bytes.startsWith(qualifier, largestPrefixSmallerThanQualifier)) { return ReturnCode.INCLUDE; } if (lesserOrEqualPrefixes.size() == sortedPrefixes.size()) { return ReturnCode.NEXT_ROW; } else { hint = sortedPrefixes.higher(largestPrefixSmallerThanQualifier); return ReturnCode.SEEK_NEXT_USING_HINT; } } else { hint = sortedPrefixes.first(); return ReturnCode.SEEK_NEXT_USING_HINT; } }
Example #17
Source File: IndexHalfStoreFileReader.java From phoenix with Apache License 2.0 | 6 votes |
/** * @param fs * @param p * @param cacheConf * @param in * @param size * @param r * @param conf * @param indexMaintainers * @param viewConstants * @param regionInfo * @param regionStartKeyInHFile * @param splitKey * @throws IOException */ public IndexHalfStoreFileReader(final FileSystem fs, final Path p, final CacheConfig cacheConf, final FSDataInputStreamWrapper in, long size, final Reference r, final Configuration conf, final Map<ImmutableBytesWritable, IndexMaintainer> indexMaintainers, final byte[][] viewConstants, final HRegionInfo regionInfo, byte[] regionStartKeyInHFile, byte[] splitKey) throws IOException { super(fs, p, in, size, cacheConf, conf); this.splitkey = splitKey == null ? r.getSplitKey() : splitKey; // Is it top or bottom half? this.top = Reference.isTopFileRegion(r.getFileRegion()); this.splitRow = CellUtil.cloneRow(KeyValue.createKeyValueFromKey(splitkey)); this.indexMaintainers = indexMaintainers; this.viewConstants = viewConstants; this.regionInfo = regionInfo; this.regionStartKeyInHFile = regionStartKeyInHFile; this.offset = regionStartKeyInHFile.length; }
Example #18
Source File: JobHistoryRawService.java From hraven with Apache License 2.0 | 6 votes |
/** * returns the raw byte representation of job history from the result value * @param value result * @return byte array of job history raw * * @throws MissingColumnInResultException */ public byte[] getJobHistoryRawFromResult(Result value) throws MissingColumnInResultException { if (value == null) { throw new IllegalArgumentException("Cannot create InputStream from null"); } Cell cell = value.getColumnLatestCell(Constants.RAW_FAM_BYTES, Constants.JOBHISTORY_COL_BYTES); // Could be that there is no conf file (only a history file). if (cell == null) { throw new MissingColumnInResultException(Constants.RAW_FAM_BYTES, Constants.JOBHISTORY_COL_BYTES); } byte[] jobHistoryRaw = CellUtil.cloneValue(cell); return jobHistoryRaw; }
Example #19
Source File: SingleColumnValueFilter.java From hbase with Apache License 2.0 | 6 votes |
@Override public ReturnCode filterCell(final Cell c) { // System.out.println("REMOVE KEY=" + keyValue.toString() + ", value=" + Bytes.toString(keyValue.getValue())); if (this.matchedColumn) { // We already found and matched the single column, all keys now pass return ReturnCode.INCLUDE; } else if (this.latestVersionOnly && this.foundColumn) { // We found but did not match the single column, skip to next row return ReturnCode.NEXT_ROW; } if (!CellUtil.matchingColumn(c, this.columnFamily, this.columnQualifier)) { return ReturnCode.INCLUDE; } foundColumn = true; if (filterColumnValue(c)) { return this.latestVersionOnly? ReturnCode.NEXT_ROW: ReturnCode.INCLUDE; } this.matchedColumn = true; return ReturnCode.INCLUDE; }
Example #20
Source File: RSRpcServices.java From hbase with Apache License 2.0 | 6 votes |
private static Get toGet(final Mutation mutation) throws IOException { if(!(mutation instanceof Increment) && !(mutation instanceof Append)) { throw new AssertionError("mutation must be a instance of Increment or Append"); } Get get = new Get(mutation.getRow()); CellScanner cellScanner = mutation.cellScanner(); while (!cellScanner.advance()) { Cell cell = cellScanner.current(); get.addColumn(CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell)); } if (mutation instanceof Increment) { // Increment Increment increment = (Increment) mutation; get.setTimeRange(increment.getTimeRange().getMin(), increment.getTimeRange().getMax()); } else { // Append Append append = (Append) mutation; get.setTimeRange(append.getTimeRange().getMin(), append.getTimeRange().getMax()); } for (Entry<String, byte[]> entry : mutation.getAttributesMap().entrySet()) { get.setAttribute(entry.getKey(), entry.getValue()); } return get; }
Example #21
Source File: BackupSystemTable.java From hbase with Apache License 2.0 | 6 votes |
public String[] getListOfBackupIdsFromDeleteOperation() throws IOException { LOG.trace("Get delete operation for backup ids"); Get get = createGetForDeleteOperation(); try (Table table = connection.getTable(tableName)) { Result res = table.get(get); if (res.isEmpty()) { return null; } Cell cell = res.listCells().get(0); byte[] val = CellUtil.cloneValue(cell); if (val.length == 0) { return null; } return new String(val).split(","); } }
Example #22
Source File: TableInputFormat.java From hbase with Apache License 2.0 | 5 votes |
/** * Parses a combined family and qualifier and adds either both or just the * family in case there is no qualifier. This assumes the older colon * divided notation, e.g. "family:qualifier". * * @param scan The Scan to update. * @param familyAndQualifier family and qualifier * @throws IllegalArgumentException When familyAndQualifier is invalid. */ private static void addColumn(Scan scan, byte[] familyAndQualifier) { byte [][] fq = CellUtil.parseColumn(familyAndQualifier); if (fq.length == 1) { scan.addFamily(fq[0]); } else if (fq.length == 2) { scan.addColumn(fq[0], fq[1]); } else { throw new IllegalArgumentException("Invalid familyAndQualifier provided."); } }
Example #23
Source File: TestPassCustomCellViaRegionObserver.java From hbase with Apache License 2.0 | 5 votes |
private static void assertResult(Result result, byte[] expectedValue) { assertFalse(result.isEmpty()); for (Cell c : result.rawCells()) { assertTrue(c.toString(), Bytes.equals(ROW, CellUtil.cloneRow(c))); assertTrue(c.toString(), Bytes.equals(FAMILY, CellUtil.cloneFamily(c))); assertTrue(c.toString(), Bytes.equals(expectedValue, CellUtil.cloneValue(c))); } }
Example #24
Source File: RowPrefixFixedLengthBloomContext.java From hbase with Apache License 2.0 | 5 votes |
/** * @param cell the cell * @return the new cell created by row prefix */ private Cell getRowPrefixCell(Cell cell) { byte[] row = CellUtil.copyRow(cell); return ExtendedCellBuilderFactory.create(CellBuilderType.DEEP_COPY) .setRow(row, 0, Math.min(prefixLength, row.length)) .setType(Cell.Type.Put) .build(); }
Example #25
Source File: AgentEventMapper.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public List<AgentEventBo> mapRow(Result result, int rowNum) throws Exception { if (result.isEmpty()) { return Collections.emptyList(); } List<AgentEventBo> agentEvents = new ArrayList<>(); for (Cell cell : result.rawCells()) { final int code = CellUtils.qualifierToInt(cell); final AgentEventType eventType = AgentEventType.getTypeByCode(code); if (eventType == null) { continue; } byte[] value = CellUtil.cloneValue(cell); final Buffer buffer = new FixedBuffer(value); final int version = buffer.readInt(); switch (version) { case 0 : case 1 : final String agentId = buffer.readPrefixedString(); final long startTimestamp = buffer.readLong(); final long eventTimestamp = buffer.readLong(); final byte[] eventMessage = buffer.readPrefixedBytes(); final AgentEventBo agentEvent = new AgentEventBo(version, agentId, startTimestamp, eventTimestamp, eventType); agentEvent.setEventBody(eventMessage); agentEvents.add(agentEvent); break; default : break; } } return agentEvents; }
Example #26
Source File: IndexRebuildRegionScanner.java From phoenix with Apache License 2.0 | 5 votes |
private static Cell getCell(Mutation m, byte[] family, byte[] qualifier) { List<Cell> cellList = m.getFamilyCellMap().get(family); if (cellList == null) { return null; } for (Cell cell : cellList) { if (CellUtil.matchingQualifier(cell, qualifier)) { return cell; } } return null; }
Example #27
Source File: TestBlocksRead.java From hbase with Apache License 2.0 | 5 votes |
private static void verifyData(Cell kv, String expectedRow, String expectedCol, long expectedVersion) { assertTrue("RowCheck", CellUtil.matchingRows(kv, Bytes.toBytes(expectedRow))); assertTrue("ColumnCheck", CellUtil.matchingQualifier(kv, Bytes.toBytes(expectedCol))); assertEquals("TSCheck", expectedVersion, kv.getTimestamp()); assertTrue("ValueCheck", CellUtil.matchingValue(kv, genValue(expectedRow, expectedCol, expectedVersion))); }
Example #28
Source File: AndExpressionTest.java From phoenix with Apache License 2.0 | 5 votes |
private Cell createCell(String name, Boolean value) { byte[] valueBytes = value == null ? null : value ? PBoolean.TRUE_BYTES : PBoolean.FALSE_BYTES; return CellUtil.createCell( Bytes.toBytes("row"), QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, Bytes.toBytes(name), 1, KeyValue.Type.Put.getCode(), valueBytes); }
Example #29
Source File: TestJobHistoryRawService.java From hraven with Apache License 2.0 | 5 votes |
@Test public void testGetApproxSubmitTime() throws IOException, MissingColumnInResultException { JobHistoryRawService rawService = new JobHistoryRawService(hbaseConnection); Cell[] cells = new Cell[1]; long modts = 1396550668000L; cells[0] = CellUtil.createCell(Bytes.toBytes("someRowKey"), Constants.INFO_FAM_BYTES, Constants.JOBHISTORY_LAST_MODIFIED_COL_BYTES, HConstants.LATEST_TIMESTAMP, KeyValue.Type.Put.getCode(), Bytes.toBytes(modts)); Result result = Result.create(cells); long st = rawService.getApproxSubmitTime(result); long expts = modts - Constants.AVERGAE_JOB_DURATION; assertEquals(expts, st); }
Example #30
Source File: BackupSystemTable.java From hbase with Apache License 2.0 | 5 votes |
/** * Converts cell to backup set list. * @param current current cell * @return backup set as array of table names */ private String[] cellValueToBackupSet(Cell current) { byte[] data = CellUtil.cloneValue(current); if (!ArrayUtils.isEmpty(data)) { return Bytes.toString(data).split(","); } return new String[0]; }