/** * Retrieves data from a table, which matches the primary key values batch. * * @param tableName The name of the table to search on * @param numPartitionsHint The best effort number of splits this should return * @param columns The list of columns to required in results, null if all needs to be returned * @param valuesBatchBeans The values batch containing the key values of primary keys to match * @return An array of {@link RecordBean} objects, which represents individual data sets in their * local location * @throws AnalyticsWebServiceException */ public RecordBean[] getWithKeyValues( String tableName, int numPartitionsHint, String[] columns, ValuesBatchBean[] valuesBatchBeans) throws AnalyticsWebServiceException { try { List<String> columnList = null; if (columns != null && columns.length != 0) { columnList = Arrays.asList(columns); } List<Map<String, Object>> valuesBatch = Utils.getValuesBatch( valuesBatchBeans, analyticsDataAPI.getTableSchema(getUsername(), tableName)); List<Record> records = AnalyticsDataServiceUtils.listRecords( analyticsDataAPI, analyticsDataAPI.getWithKeyValues( getUsername(), tableName, numPartitionsHint, columnList, valuesBatch)); List<RecordBean> recordBeans = Utils.createRecordBeans(records); RecordBean[] resultRecordBeans = new RecordBean[recordBeans.size()]; return recordBeans.toArray(resultRecordBeans); } catch (Exception e) { logger.error( "Unable to get records from table[" + tableName + "] due to " + e.getMessage(), e); throw new AnalyticsWebServiceException( "Unable to get record from table[" + tableName + "] due to " + e.getMessage(), e); } }
/** * Retrieves the table schema for the given table. * * @param tableName The table name * @return The schema of the table * @throws AnalyticsWebServiceException */ public AnalyticsSchemaBean getTableSchema(String tableName) throws AnalyticsWebServiceException { try { return Utils.createTableSchemaBean(analyticsDataAPI.getTableSchema(getUsername(), tableName)); } catch (Exception e) { logger.error("Unable to get table schema[" + tableName + "] due to " + e.getMessage(), e); throw new AnalyticsWebServiceException( "Unable to get table schema for table[" + tableName + "] due to " + e.getMessage(), e); } }