/** {@inheritDoc} */ @Override public Collection<HBaseFijiPartition> getPartitions() throws IOException { try (HTableInterface htable = mHTableFactory.create(mConf, mHBaseTableName)) { return HBaseFijiPartition.getPartitions((HTable) htable); } }
/** {@inheritDoc} */ @Override public <T> FijiResultScanner<T> getFijiResultScanner( final FijiDataRequest dataRequest, final FijiPartition partition ) throws IOException { Preconditions.checkArgument(partition instanceof HBaseFijiPartition, "Can not scan an HBase table with a non-HBase partition."); final HBaseFijiPartition hbasePartition = (HBaseFijiPartition) partition; final FijiScannerOptions options = new FijiScannerOptions(); options.setStartRow(HBaseEntityId.fromHBaseRowKey(hbasePartition.getStartKey())); options.setStopRow(HBaseEntityId.fromHBaseRowKey(hbasePartition.getEndKey())); return getFijiResultScanner(dataRequest, options); }
/** * Get the Cassandra Fiji Partitions for the given cluster. * * @param htable An open connection to the HBase table. * @return The collection of Fiji partitions. * @throws IOException if a remote or network exception occurs. */ public static Collection<HBaseFijiPartition> getPartitions( final HTable htable ) throws IOException { final ImmutableList.Builder<HBaseFijiPartition> partitions = ImmutableList.builder(); NavigableMap<HRegionInfo, ServerName> regionLocations = htable.getRegionLocations(); for (Map.Entry<HRegionInfo, ServerName> regionLocation : regionLocations.entrySet()) { partitions.add( new HBaseFijiPartition( InetAddress.getByName(regionLocation.getValue().getHostname()), regionLocation.getKey().getStartKey(), regionLocation.getKey().getEndKey())); } return partitions.build(); } }