@Override public List<Boolean> existsAll(ByteBuffer table, List<TGet> gets) throws TIOError, TException { Table htable = getTable(table); try { boolean[] exists = htable.existsAll(getsFromThrift(gets)); List<Boolean> result = new ArrayList<>(exists.length); for (boolean exist : exists) { result.add(exist); } return result; } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
boolean[] results = table.existsAll(gets); assertFalse(results[0]); assertFalse(results[1]); gets.add(new Get(new byte[] { 0x00 })); gets.add(new Get(new byte[] { 0x00, 0x00 })); results = table.existsAll(gets); assertTrue(results[0]); assertFalse(results[1]); gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff })); gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff })); results = table.existsAll(gets); assertFalse(results[0]); assertTrue(results[1]);
@Override public boolean[] exists(List<Get> gets) throws IOException { return delegate.existsAll(gets); }
@Override public boolean[] existsAll(List<Get> gets) throws IOException { return delegate.existsAll(gets); }
@Test public void testHTableExistsAllBeforeGet() throws Exception { final byte[] ROW2 = Bytes.add(ROW, Bytes.toBytes("2")); Table table = TEST_UTIL.createTable( TableName.valueOf(name.getMethodName()), new byte[][] { FAMILY }); try { Put put = new Put(ROW); put.addColumn(FAMILY, QUALIFIER, VALUE); table.put(put); put = new Put(ROW2); put.addColumn(FAMILY, QUALIFIER, VALUE); table.put(put); Get get = new Get(ROW); Get get2 = new Get(ROW2); ArrayList<Get> getList = new ArrayList(2); getList.add(get); getList.add(get2); boolean[] exists = table.existsAll(getList); assertEquals(true, exists[0]); assertEquals(true, exists[1]); Result[] result = table.get(getList); assertEquals(false, result[0].isEmpty()); assertTrue(Bytes.equals(VALUE, result[0].getValue(FAMILY, QUALIFIER))); assertEquals(false, result[1].isEmpty()); assertTrue(Bytes.equals(VALUE, result[1].getValue(FAMILY, QUALIFIER))); } finally { table.close(); } }
public void testCheckAndDelete(Connection connection, String tableName) throws IOException { createTable(thriftAdmin, tableName); try (Table table = connection.getTable(TableName.valueOf(tableName))){ Get get = new Get(ROW_1); Result result = table.get(get); byte[] value1 = result.getValue(FAMILYA, QUALIFIER_1); byte[] value2 = result.getValue(FAMILYB, QUALIFIER_2); assertNotNull(value1); assertTrue(Bytes.equals(VALUE_1, value1)); assertNull(value2); assertTrue(table.exists(get)); assertEquals(1, table.existsAll(Collections.singletonList(get)).length); Delete delete = new Delete(ROW_1); table.checkAndMutate(ROW_1, FAMILYA).qualifier(QUALIFIER_1) .ifEquals(VALUE_1).thenDelete(delete); assertFalse(table.exists(get)); Put put = new Put(ROW_1); put.addColumn(FAMILYA, QUALIFIER_1, VALUE_1); table.put(put); assertTrue(table.checkAndMutate(ROW_1, FAMILYA).qualifier(QUALIFIER_1) .ifEquals(VALUE_1).thenPut(put)); assertFalse(table.checkAndMutate(ROW_1, FAMILYA).qualifier(QUALIFIER_1) .ifEquals(VALUE_2).thenPut(put)); } }
@Override public boolean[] exists(List<Get> gets) throws IOException { return delegate.existsAll(gets); }
@Override public boolean[] existsAll(List<Get> gets) throws IOException { return delegate.existsAll(gets); }
@Override public boolean[] existsAll(List<Get> gets) throws IOException { return delegate.existsAll(gets); }
@Override public boolean[] exists(List<Get> gets) throws IOException { return delegate.existsAll(gets); }
@Override public boolean[] existsAll(List<Get> gets) throws IOException { if (tx == null) { throw new IOException("Transaction not started"); } List<Get> transactionalizedGets = new ArrayList<>(gets.size()); for (Get get : gets) { transactionalizedGets.add(transactionalizeAction(get)); } return hTable.existsAll(transactionalizedGets); }
public boolean[] existsAll(List<Get> list) throws IOException { return getTable().existsAll(list); }
@Override public List<Boolean> existsAll(ByteBuffer table, List<TGet> gets) throws TIOError, TException { Table htable = getTable(table); try { boolean[] exists = htable.existsAll(getsFromThrift(gets)); List<Boolean> result = new ArrayList<>(exists.length); for (boolean exist : exists) { result.add(exist); } return result; } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public List<Boolean> existsAll(ByteBuffer table, List<TGet> gets) throws TIOError, TException { Table htable = getTable(table); try { boolean[] exists = htable.existsAll(getsFromThrift(gets)); List<Boolean> result = new ArrayList<>(exists.length); for (boolean exist : exists) { result.add(exist); } return result; } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
boolean[] results = table.existsAll(gets); assertFalse(results[0]); assertFalse(results[1]); gets.add(new Get(new byte[] { 0x00 })); gets.add(new Get(new byte[] { 0x00, 0x00 })); results = table.existsAll(gets); assertTrue(results[0]); assertFalse(results[1]); gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff })); gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff })); results = table.existsAll(gets); assertFalse(results[0]); assertTrue(results[1]);
boolean[] checks = table.existsAll(gets); for (Boolean check : checks) { Assert.assertFalse(check);
@Test public void testHTableExistsAllBeforeGet() throws Exception { final byte[] ROW2 = Bytes.add(ROW, Bytes.toBytes("2")); Table table = TEST_UTIL.createTable( TableName.valueOf(name.getMethodName()), new byte[][] { FAMILY }); try { Put put = new Put(ROW); put.addColumn(FAMILY, QUALIFIER, VALUE); table.put(put); put = new Put(ROW2); put.addColumn(FAMILY, QUALIFIER, VALUE); table.put(put); Get get = new Get(ROW); Get get2 = new Get(ROW2); ArrayList<Get> getList = new ArrayList(2); getList.add(get); getList.add(get2); boolean[] exists = table.existsAll(getList); assertEquals(true, exists[0]); assertEquals(true, exists[1]); Result[] result = table.get(getList); assertEquals(false, result[0].isEmpty()); assertTrue(Bytes.equals(VALUE, result[0].getValue(FAMILY, QUALIFIER))); assertEquals(false, result[1].isEmpty()); assertTrue(Bytes.equals(VALUE, result[1].getValue(FAMILY, QUALIFIER))); } finally { table.close(); } }