/** * Converts multiple {@link TPut}s (Thrift) into a list of {@link Put}s (HBase). * * @param in list of <code>TPut</code>s to convert * * @return list of converted <code>Put</code>s * * @see #putFromThrift(TPut) */ public static List<Put> putsFromThrift(List<TPut> in) { List<Put> out = new ArrayList<>(in.size()); for (TPut put : in) { out.add(putFromThrift(put)); } return out; }
@Override public void put(ByteBuffer table, TPut put) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { htable.put(putFromThrift(put)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public boolean checkAndPut(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value, TPut put) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { Table.CheckAndMutateBuilder builder = htable.checkAndMutate(byteBufferToByteArray(row), byteBufferToByteArray(family)).qualifier(byteBufferToByteArray(qualifier)); if (value == null) { return builder.ifNotExists().thenPut(putFromThrift(put)); } else { return builder.ifEquals(byteBufferToByteArray(value)).thenPut(putFromThrift(put)); } } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
/** * Creates a {@link RowMutations} (HBase) from a {@link TRowMutations} (Thrift) * * @param in the <code>TRowMutations</code> to convert * * @return converted <code>RowMutations</code> */ public static RowMutations rowMutationsFromThrift(TRowMutations in) throws IOException { List<TMutation> mutations = in.getMutations(); RowMutations out = new RowMutations(in.getRow(), mutations.size()); for (TMutation mutation : mutations) { if (mutation.isSetPut()) { out.add(putFromThrift(mutation.getPut())); } if (mutation.isSetDeleteSingle()) { out.add(deleteFromThrift(mutation.getDeleteSingle())); } } return out; }
TPut tPut = new TPut(wrap(rowName) , columnValues); tPut.setAttributes(attributes); Put put = putFromThrift(tPut); assertArrayEquals(put.getAttribute("attribute1"), attributeValue);
Put put = putFromThrift(tPut); assertEquals(Durability.SKIP_WAL, put.getDurability()); put = putFromThrift(tPut); assertEquals(Durability.ASYNC_WAL, put.getDurability()); put = putFromThrift(tPut); assertEquals(Durability.SYNC_WAL, put.getDurability()); put = putFromThrift(tPut); assertEquals(Durability.FSYNC_WAL, put.getDurability());
/** * Converts multiple {@link TPut}s (Thrift) into a list of {@link Put}s (HBase). * * @param in list of <code>TPut</code>s to convert * * @return list of converted <code>Put</code>s * * @see #putFromThrift(TPut) */ public static List<Put> putsFromThrift(List<TPut> in) { List<Put> out = new ArrayList<Put>(in.size()); for (TPut put : in) { out.add(putFromThrift(put)); } return out; }
/** * Converts multiple {@link TPut}s (Thrift) into a list of {@link Put}s (HBase). * * @param in list of <code>TPut</code>s to convert * * @return list of converted <code>Put</code>s * * @see #putFromThrift(TPut) */ public static List<Put> putsFromThrift(List<TPut> in) { List<Put> out = new ArrayList<>(in.size()); for (TPut put : in) { out.add(putFromThrift(put)); } return out; }
/** * Converts multiple {@link TPut}s (Thrift) into a list of {@link Put}s (HBase). * * @param in list of <code>TPut</code>s to convert * * @return list of converted <code>Put</code>s * * @see #putFromThrift(TPut) */ public static List<Put> putsFromThrift(List<TPut> in) { List<Put> out = new ArrayList<>(in.size()); for (TPut put : in) { out.add(putFromThrift(put)); } return out; }
@Override public boolean checkAndPut(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value, TPut put) throws TIOError, TException { HTableInterface htable = getTable(table.array()); try { return htable.checkAndPut(row.array(), family.array(), qualifier.array(), (value == null) ? null : value.array(), putFromThrift(put)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public void put(ByteBuffer table, TPut put) throws TIOError, TException { HTableInterface htable = getTable(table.array()); try { htable.put(putFromThrift(put)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public void put(ByteBuffer table, TPut put) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { htable.put(putFromThrift(put)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public void put(ByteBuffer table, TPut put) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { htable.put(putFromThrift(put)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public boolean checkAndPut(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value, TPut put) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { Table.CheckAndMutateBuilder builder = htable.checkAndMutate(byteBufferToByteArray(row), byteBufferToByteArray(family)).qualifier(byteBufferToByteArray(qualifier)); if (value == null) { return builder.ifNotExists().thenPut(putFromThrift(put)); } else { return builder.ifEquals(byteBufferToByteArray(value)).thenPut(putFromThrift(put)); } } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public boolean checkAndPut(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value, TPut put) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { Table.CheckAndMutateBuilder builder = htable.checkAndMutate(byteBufferToByteArray(row), byteBufferToByteArray(family)).qualifier(byteBufferToByteArray(qualifier)); if (value == null) { return builder.ifNotExists().thenPut(putFromThrift(put)); } else { return builder.ifEquals(byteBufferToByteArray(value)).thenPut(putFromThrift(put)); } } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
/** * Creates a {@link RowMutations} (HBase) from a {@link TRowMutations} (Thrift) * * @param in the <code>TRowMutations</code> to convert * * @return converted <code>RowMutations</code> */ public static RowMutations rowMutationsFromThrift(TRowMutations in) throws IOException { List<TMutation> mutations = in.getMutations(); RowMutations out = new RowMutations(in.getRow(), mutations.size()); for (TMutation mutation : mutations) { if (mutation.isSetPut()) { out.add(putFromThrift(mutation.getPut())); } if (mutation.isSetDeleteSingle()) { out.add(deleteFromThrift(mutation.getDeleteSingle())); } } return out; }
/** * Creates a {@link RowMutations} (HBase) from a {@link TRowMutations} (Thrift) * * @param in the <code>TRowMutations</code> to convert * * @return converted <code>RowMutations</code> */ public static RowMutations rowMutationsFromThrift(TRowMutations in) throws IOException { List<TMutation> mutations = in.getMutations(); RowMutations out = new RowMutations(in.getRow(), mutations.size()); for (TMutation mutation : mutations) { if (mutation.isSetPut()) { out.add(putFromThrift(mutation.getPut())); } if (mutation.isSetDeleteSingle()) { out.add(deleteFromThrift(mutation.getDeleteSingle())); } } return out; }
TPut tPut = new TPut(wrap(rowName) , columnValues); tPut.setAttributes(attributes); Put put = putFromThrift(tPut); assertArrayEquals(put.getAttribute("attribute1"), attributeValue);
TPut tPut = new TPut(wrap(rowName) , columnValues); tPut.setAttributes(attributes); Put put = putFromThrift(tPut); assertArrayEquals(put.getAttribute("attribute1"), attributeValue);
Put put = putFromThrift(tPut); assertEquals(Durability.SKIP_WAL, put.getDurability()); put = putFromThrift(tPut); assertEquals(Durability.ASYNC_WAL, put.getDurability()); put = putFromThrift(tPut); assertEquals(Durability.SYNC_WAL, put.getDurability()); put = putFromThrift(tPut); assertEquals(Durability.FSYNC_WAL, put.getDurability());