@After public void tearDownAfterClass() throws Exception { remoteTable.close(); }
@After public void after() throws Exception { remoteTable.close(); }
@After public void tearDownAfterClass() throws Exception { remoteTable.close(); }
@After public void after() throws Exception { remoteTable.close(); }
@Override public void addOrUpdateRows(String tableName, List<Row> rows) { RemoteHTable table = new RemoteHTable(client, tableName); List<Put> puts = convertRowsToPuts(rows); try { table.batch(puts); } catch (IOException e) { throw new ModifyTableException(e); } finally { try { table.close(); } catch (IOException e) { LOGGER.warn(EXCEPTION_MESSAGE, e); } } }
private Result[] getRawRows(String tableName, Row startRow, int numberOfRows) { Result[] result = new Result[] {}; RemoteHTable table = null; synchronized (mutex) { table = new RemoteHTable(client, tableName); } try { Scan s=startRow==null?new Scan():new Scan(startRow.getId()); ResultScanner resultScanner = table.getScanner(s); result = resultScanner.next(numberOfRows); } catch (IOException e) { throw new ReadTableException("Exception during fetching rows", e); } finally { try { table.close(); } catch (IOException e) { LOGGER.warn(EXCEPTION_DURING_CLOSING_H_BASE_TABLE, e); } } return result; }
@Override public void addOrUpdateRows(String tableName, List<Row> rows) { RemoteHTable table = null; synchronized (mutex) { table = new RemoteHTable(client, tableName); } try { table.put(convertRowsToPuts(rows)); } catch (IOException e) { throw new ModifyTableException(e); } finally { try { table.close(); } catch (IOException e) { LOGGER.warn(EXCEPTION_DURING_CLOSING_H_BASE_TABLE, e); } } }
public static void deleteRowFromHBase(String remoteHost, int remotePort, String remoteTable, List<String> rowsToDelete) throws IOException { RemoteHTable table = new RemoteHTable( new Client( new Cluster().add(remoteHost, remotePort)), remoteTable); List<byte[]> rowBytes = new ArrayList<byte[]>(); for (String s : rowsToDelete) { rowBytes.add(Bytes.toBytes(s)); } for (byte[] b : rowBytes) { table.delete(new Delete(b)); } table.close(); } }
@Override public void addOrUpdateRow(String tableName, Row row) { Put p = Row2HBasePut.translate(row); RemoteHTable table = null; synchronized (mutex) { table = new RemoteHTable(client, tableName); } try { table.put(p); } catch (IOException e) { throw new ModifyTableException(e); } finally { try { table.close(); } catch (IOException e) { LOGGER.warn(EXCEPTION_DURING_CLOSING_H_BASE_TABLE, e); } } }
scanner.close(); table.close(); return rowAuthorsMap;
public static void deleteRowFromHBase(String remoteHost, int remotePort, String remoteTable, String rowToDelete) throws IOException { RemoteHTable table = new RemoteHTable( new Client( new Cluster().add(remoteHost, remotePort)), remoteTable); byte[] row3 = Bytes.toBytes(rowToDelete); table.delete(new Delete(row3)); table.close(); }
@Override public void deleteRow(String tableName, Row row) { final RemoteHTable table; synchronized (mutex) { table = new RemoteHTable(client, tableName); } try { table.delete(new Delete(row.getId())); } catch (IOException e) { throw new ModifyTableException(EXCEPTION_DURING_DELETING_ROW, e); } finally { try { table.close(); } catch (IOException e) { throw new ModifyTableException(EXCEPTION_DURING_CLOSING_TABLE, e); } } }
scanner.close(); table.close(); return rowAuthorsMap;
public static void main(String[] args) throws IOException { RemoteHTable table = new RemoteHTable( new Client( new Cluster().add("localhost", 8080)), "test"); Person john = Person.newBuilder().setId(1234).setName("John Doe").setEmail("jdoe@example.com").addPhone( Person.PhoneNumber.newBuilder().setNumber("555-4321").setType(Person.PhoneType.HOME)).build(); byte[] row = Bytes.toBytes("row3"); table.delete(new Delete(row)); Put put = new Put(row); byte[] family = Bytes.toBytes("data"); byte[] qualifier = Bytes.toBytes("3"); byte[] value = john.toByteArray(); put.add(family, qualifier, value); table.put(put); table.close(); } }
scanner.close(); table.close();
public static void importBwmetaAndSendToHBase(String zipDirPath, String collectionName, String remoteHost, int remotePort, String remoteTable) throws IOException { RemoteHTable table = new RemoteHTable(new Client(new Cluster().add(remoteHost, remotePort)), remoteTable); ZipDirToDocumentDTOIterator zdtp = new ZipDirToDocumentDTOIterator(zipDirPath, collectionName); for (DocumentDTO doc : zdtp) { try { table.put(DocumentDTO2HBasePut.translate(doc)); } catch (IOException e) { LOGGER.error(ERROR_STRING, e); } } table.close(); } }
public static void importBwmetaAndSendToHBase(String zipDirPath, String remoteHost, int remotePort, String remoteTable, String collectionName) throws IOException { RemoteHTable table = new RemoteHTable( new Client( new Cluster().add(remoteHost, remotePort)), remoteTable); Iterable<DocumentDTO> zdtp = new PdfZipDirToDocumentDTOIterable(zipDirPath, collectionName); for (DocumentDTO doc : zdtp) { try { table.put(DocumentDTO2HBasePut.translate(doc)); } catch (IOException e) { LOGGER.error(ERROR_STRING, e); } } table.close(); } }
public static void importBwmetaAndSendToHBase(String dirPath, String remoteHost, int remotePort, String remoteTable, String collectionName) throws IOException { RemoteHTable table = new RemoteHTable( new Client( new Cluster().add(remoteHost, remotePort)), remoteTable); Iterable<DocumentDTO> zdtp; if (collectionName != null) { zdtp = new OAIPMHDirToDocumentDTOIterator(dirPath, collectionName); } else { zdtp = new OAIPMHDirToDocumentDTOIterator(dirPath); } for (DocumentDTO doc : zdtp) { try { table.put(DocumentDTO2HBasePut.translate(doc)); } catch (IOException e) { LOGGER.error(ERROR_STRING, e); } } table.close(); } }