@Override public Object[] scanRowyKeys(FilterList filterList, String tableName, String columnFamilyName, String columnName, final Class rowKeyClazz) throws IOException { Table hTable = gethTable(tableName); return hbaseReader.scanRowKeys(hTable, filterList, columnFamilyName, columnName, rowKeyClazz); }
@Override public Object[] scanRowyKeys(FilterList filterList, String tableName, String columnFamilyName, String columnName, final Class rowKeyClazz) throws IOException { HTableInterface hTable = null; hTable = gethTable(tableName); return hbaseReader.scanRowKeys(hTable, filterList, columnFamilyName, columnName, rowKeyClazz); }
public void deleteRow(Object rowKey, String tableName, String columnFamilyName) throws IOException { hbaseWriter.delete(gethTable(tableName), rowKey, columnFamilyName); }
@Override public void batchProcess(Map<String, List<Row>> batchData) { for (String tableName : batchData.keySet()) { List<Row> actions = batchData.get(tableName); try { Table hTable = gethTable(tableName); hTable.batch(actions, new Object[actions.size()]); } catch (IOException | InterruptedException e) { logger.error("Error while batch processing on HTable: " + tableName); throw new PersistenceException(e); } } } }
@Override public List readAll(final String tableName, Class clazz, EntityMetadata m, final List<Object> rowKey, List<String> relationNames, String... columns) throws IOException { Table hTable = gethTable(tableName); List<HBaseDataWrapper> results = ((HBaseReader) hbaseReader).loadAll(hTable, rowKey, null, columns); return onRead(m, null, hTable, results); }
@Override public void deleteRow(Object rowKey, String colName, String colFamily, String tableName) throws IOException { Table hTable = gethTable(tableName); hbaseWriter.delete(hTable, rowKey, colFamily, colName); closeHTable(hTable); }
@Override public void writeJoinTableData(String tableName, Object rowId, Map<String, Object> columns, String columnFamilyName) throws IOException { HTableInterface hTable = gethTable(tableName); hbaseWriter.writeColumns(hTable, rowId, columns, columnFamilyName); puthTable(hTable); }
@Override public void writeJoinTableData(String tableName, Object rowId, Map<String, Object> columns, String columnFamilyName) throws IOException { Table hTable = gethTable(tableName); hbaseWriter.writeColumns(hTable, rowId, columns, columnFamilyName); closeHTable(hTable); }
/** * Write hbase row in a table. * * @param tableName * the table name * @param hbaseRow * the hbase row * @throws IOException * Signals that an I/O exception has occurred. */ private void writeHbaseRowInATable(String tableName, HBaseRow hbaseRow) throws IOException { Table hTable = gethTable(tableName); ((HBaseWriter) hbaseWriter).writeRow(hTable, hbaseRow); hTable.close(); }
public Object next(EntityMetadata m) { Object entity = null; HBaseData result = ((HBaseReader) hbaseReader).next(); List<HBaseData> results = new ArrayList<HBaseData>(); List output = new ArrayList(); results.add(result); try { output = onRead(m.getSchema(), m.getEntityClazz(), m, output, gethTable(m.getSchema()), entity, m.getRelationNames(), results); } catch (IOException e) { log.error("Error during finding next record, Caused by: .", e); throw new KunderaException(e); } return output != null && !output.isEmpty() ? output.get(0) : output; }
@Override public List readData(String tableName, EntityMetadata m, final Object rowKey, byte[] startRow, byte[] endRow, List<Map<String, Object>> columnsToOutput, FilterList filterList) throws IOException { Table hTable = gethTable(tableName); filterList = getExtPropertyFilters(m, filterList); boolean isFindKeyOnly = HBaseUtils.isFindKeyOnly(m, columnsToOutput); filterList = onFindKeyOnly(filterList, isFindKeyOnly); List<HBaseDataWrapper> results = hbaseReader.loadData(hTable, rowKey, startRow, endRow, null, filterList, !isFindKeyOnly ? columnsToOutput : new ArrayList<Map<String, Object>>()); return onRead(m, columnsToOutput, hTable, results); }
/** * Next. * * @param m * the m * @param columnsToOutput * the columns to output * @return the object */ public Object next(EntityMetadata m, List<Map<String, Object>> columnsToOutput) { Object entity = null; HBaseDataWrapper result = ((HBaseReader) hbaseReader).next(); List<HBaseDataWrapper> results = new ArrayList<HBaseDataWrapper>(); results.add(result); try { List output = onRead(m, columnsToOutput, gethTable(HBaseUtils.getHTableName(m.getSchema(), m.getTableName())), results); return output != null && !output.isEmpty() ? output.get(0) : output; } catch (IOException e) { logger.error("Error during finding next record, Caused by: .", e); throw new KunderaException(e); } }
try hTable = gethTable(tableName); List<HBaseDataWrapper> results = hbaseReader.loadData(hTable, rowKey, null, null, joinTableName, getFilter(joinTableName), null);
@Override public Object generate(TableGeneratorDiscriptor discriptor, ClientBase client, String dataType) { try { HTableInterface hTable = ((HBaseDataHandler) ((HBaseClient) client).handler).gethTable(discriptor .getSchema()); Long latestCount = hTable.incrementColumnValue(discriptor.getPkColumnValue().getBytes(), discriptor .getTable().getBytes(), discriptor.getValueColumnName().getBytes(), 1); if (latestCount == 1) { return (long) discriptor.getInitialValue(); } else if (discriptor.getAllocationSize() == 1) { return latestCount + discriptor.getInitialValue(); } else { return (latestCount - 1) * discriptor.getAllocationSize() + discriptor.getInitialValue(); } } catch (IOException ioex) { log.error("Error while generating id for entity, Caused by: .", ioex); throw new KunderaException(ioex); } } }
@Override public List readAll(final String tableName, Class clazz, EntityMetadata m, final List<Object> rowKey, List<String> relationNames, String... columns) throws IOException { List output = null; Object entity = null; HTableInterface hTable = null; hTable = gethTable(tableName); // Load raw data from HBase MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel( m.getPersistenceUnit()); AbstractManagedType managedType = (AbstractManagedType) metaModel.entity(m.getEntityClazz()); // For secondary tables. List<String> secondaryTables = ((DefaultEntityAnnotationProcessor) managedType.getEntityAnnotation()) .getSecondaryTablesName(); secondaryTables.add(m.getTableName()); List<HBaseData> results = new ArrayList<HBaseData>(); for (String colTableName : secondaryTables) { List table = ((HBaseReader) hbaseReader).loadAll(hTable, rowKey, colTableName, columns); // null check for 'table'. addAll method throws exception if table // is null if (table != null) { results.addAll(table); } } output = onRead(tableName, clazz, m, output, hTable, entity, relationNames, results); return output; }
@Override public Object generate(TableGeneratorDiscriptor discriptor, ClientBase client, String dataType) { String tableName = HBaseUtils.getHTableName(discriptor.getSchema(), discriptor.getPkColumnValue()); try { Table hTable = ((HBaseDataHandler) ((HBaseClient) client).handler).gethTable(tableName); Long latestCount = hTable.incrementColumnValue(HBaseUtils.AUTO_ID_ROW.getBytes(), discriptor .getPkColumnValue().getBytes(), discriptor.getValueColumnName().getBytes(), 1); if (latestCount == 1) { return (long) discriptor.getInitialValue(); } else if (discriptor.getAllocationSize() == 1) { return latestCount + discriptor.getInitialValue(); } else { return (latestCount - 1) * discriptor.getAllocationSize() + discriptor.getInitialValue(); } } catch (IOException ioex) { log.error("Error while generating id for entity, Caused by: .", ioex); throw new KunderaException(ioex); } } }
@Override public List readDataByRange(String tableName, Class clazz, EntityMetadata m, byte[] startRow, byte[] endRow, String[] columns, FilterList f) throws IOException { List output = new ArrayList(); HTableInterface hTable = null; Object entity = null; List<String> relationNames = m.getRelationNames(); Filter filter = getFilter(m.getTableName()); if (filter != null) { if (f == null) { f = new FilterList(); } f.addFilter(filter); } // Load raw data from HBase hTable = gethTable(tableName); List<HBaseData> results = hbaseReader.loadAll(hTable, f, startRow, endRow, m.getTableName(), null, columns); output = onRead(tableName, clazz, m, output, hTable, entity, relationNames, results); return output; }
hTable = gethTable(tableName);
List<HBaseData> results = hbaseReader.loadAll(gethTable(tableName), f, null, null, m.getTableName(), isCollection ? qualifier : null, null); if (results != null)
List<RelationHolder> relations, boolean showQuery) throws IOException HTableInterface hTable = gethTable(tableName);