Java Code Examples for org.apache.hadoop.hbase.client.Get#hasFamilies()
The following examples show how to use
org.apache.hadoop.hbase.client.Get#hasFamilies() .
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: TransactionAwareHTableTest.java From phoenix-tephra with Apache License 2.0 | 6 votes |
private void verifyRows(Table 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 2
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 3
Source File: TransactionAwareHTableTest.java From phoenix-tephra with Apache License 2.0 | 6 votes |
private void verifyRows(Table 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 4
Source File: TransactionAwareHTableTest.java From phoenix-tephra with Apache License 2.0 | 6 votes |
private void verifyRows(Table 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 5
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 6
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 7
Source File: TransactionAwareHTableTest.java From phoenix-tephra with Apache License 2.0 | 6 votes |
private void verifyRows(Table 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 8
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 9
Source File: ProtobufUtil.java From hbase with Apache License 2.0 | 4 votes |
/** * Create a protocol buffer Get based on a client Get. * * @param get the client Get * @return a protocol buffer Get * @throws IOException */ public static ClientProtos.Get toGet( final Get get) throws IOException { ClientProtos.Get.Builder builder = ClientProtos.Get.newBuilder(); builder.setRow(UnsafeByteOperations.unsafeWrap(get.getRow())); builder.setCacheBlocks(get.getCacheBlocks()); builder.setMaxVersions(get.getMaxVersions()); if (get.getFilter() != null) { builder.setFilter(ProtobufUtil.toFilter(get.getFilter())); } get.getColumnFamilyTimeRange().forEach((cf, timeRange) -> { builder.addCfTimeRange(HBaseProtos.ColumnFamilyTimeRange.newBuilder() .setColumnFamily(UnsafeByteOperations.unsafeWrap(cf)) .setTimeRange(toTimeRange(timeRange)) .build()); }); builder.setTimeRange(ProtobufUtil.toTimeRange(get.getTimeRange())); Map<String, byte[]> attributes = get.getAttributesMap(); if (!attributes.isEmpty()) { NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder(); for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) { attributeBuilder.setName(attribute.getKey()); attributeBuilder.setValue(UnsafeByteOperations.unsafeWrap(attribute.getValue())); builder.addAttribute(attributeBuilder.build()); } } if (get.hasFamilies()) { Column.Builder columnBuilder = Column.newBuilder(); Map<byte[], NavigableSet<byte[]>> families = get.getFamilyMap(); for (Map.Entry<byte[], NavigableSet<byte[]>> family: families.entrySet()) { NavigableSet<byte[]> qualifiers = family.getValue(); columnBuilder.setFamily(UnsafeByteOperations.unsafeWrap(family.getKey())); columnBuilder.clearQualifier(); if (qualifiers != null && qualifiers.size() > 0) { for (byte[] qualifier: qualifiers) { columnBuilder.addQualifier(UnsafeByteOperations.unsafeWrap(qualifier)); } } builder.addColumn(columnBuilder.build()); } } if (get.getMaxResultsPerColumnFamily() >= 0) { builder.setStoreLimit(get.getMaxResultsPerColumnFamily()); } if (get.getRowOffsetPerColumnFamily() > 0) { builder.setStoreOffset(get.getRowOffsetPerColumnFamily()); } if (get.isCheckExistenceOnly()){ builder.setExistenceOnly(true); } if (get.getConsistency() != null && get.getConsistency() != Consistency.STRONG) { builder.setConsistency(toConsistency(get.getConsistency())); } Boolean loadColumnFamiliesOnDemand = get.getLoadColumnFamiliesOnDemandValue(); if (loadColumnFamiliesOnDemand != null) { builder.setLoadColumnFamiliesOnDemand(loadColumnFamiliesOnDemand); } return builder.build(); }