Java Code Examples for org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toGet()
The following examples show how to use
org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toGet() .
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: TestGet.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testAttributesSerialization() throws IOException { Get get = new Get(Bytes.toBytes("row")); get.setAttribute("attribute1", Bytes.toBytes("value1")); get.setAttribute("attribute2", Bytes.toBytes("value2")); get.setAttribute("attribute3", Bytes.toBytes("value3")); ClientProtos.Get getProto = ProtobufUtil.toGet(get); Get get2 = ProtobufUtil.toGet(getProto); Assert.assertNull(get2.getAttribute("absent")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get2.getAttribute("attribute1"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get2.getAttribute("attribute2"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value3"), get2.getAttribute("attribute3"))); Assert.assertEquals(3, get2.getAttributesMap().size()); }
Example 2
Source File: TestSerialization.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testGet() throws Exception { byte[] row = Bytes.toBytes("row"); byte[] fam = Bytes.toBytes("fam"); byte[] qf1 = Bytes.toBytes("qf1"); long ts = System.currentTimeMillis(); int maxVersions = 2; Get get = new Get(row); get.addColumn(fam, qf1); get.setTimeRange(ts, ts + 1); get.readVersions(maxVersions); ClientProtos.Get getProto = ProtobufUtil.toGet(get); Get desGet = ProtobufUtil.toGet(getProto); assertTrue(Bytes.equals(get.getRow(), desGet.getRow())); Set<byte[]> set = null; Set<byte[]> desSet = null; for (Map.Entry<byte[], NavigableSet<byte[]>> entry : get.getFamilyMap().entrySet()) { assertTrue(desGet.getFamilyMap().containsKey(entry.getKey())); set = entry.getValue(); desSet = desGet.getFamilyMap().get(entry.getKey()); for (byte[] qualifier : set) { assertTrue(desSet.contains(qualifier)); } } assertEquals(get.getMaxVersions(), desGet.getMaxVersions()); TimeRange tr = get.getTimeRange(); TimeRange desTr = desGet.getTimeRange(); assertEquals(tr.getMax(), desTr.getMax()); assertEquals(tr.getMin(), desTr.getMin()); }
Example 3
Source File: AdapterPartition.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override protected Result doGet(Get get) throws IOException{ if (!useProxy) { try { return delegate.doGet(get); } catch (AccessDeniedException ade) { activateProxy(ade); } } try { try (java.sql.Connection jdbcConnection = connectionPool.getConnection(); PreparedStatement statement = jdbcConnection.prepareStatement("call SYSCS_UTIL.SYSCS_HBASE_OPERATION(?, ?, ?)")) { statement.setString(1, tableName.toString()); statement.setString(2, "get"); ClientProtos.Get getRequest = ProtobufUtil.toGet(get); statement.setBlob(3, new ArrayInputStream(getRequest.toByteArray())); try (ResultSet rs = statement.executeQuery()) { if (!rs.next()) { throw new IOException("No results for get"); } Blob blob = rs.getBlob(1); byte[] bytes = blob.getBytes(1, (int) blob.length()); ClientProtos.Result result = ClientProtos.Result.parseFrom(bytes); return ProtobufUtil.toResult(result); } } } catch (SQLException e) { throw new IOException(e); } }