use of io.cdap.cdap.api.dataset.table.TableSplit in project cdap by caskdata.
the class BufferingTable method getSplits.
/**
* Fallback implementation of getSplits, {@link SplitsUtil#primitiveGetSplits(int, byte[], byte[])}.
* Ideally should be overridden by subclasses.
*
* @param numSplits Desired number of splits. If greater than zero, at most this many splits will be returned.
* If less or equal to zero, any number of splits can be returned.
* @param start If non-null, the returned splits will only cover keys that are greater or equal.
* @param stop If non-null, the returned splits will only cover keys that are less.
* @return list of {@link Split}
*/
@Override
public List<Split> getSplits(int numSplits, byte[] start, byte[] stop) {
ensureTransactionIsStarted();
List<KeyRange> keyRanges = SplitsUtil.primitiveGetSplits(numSplits, start, stop);
return Lists.transform(keyRanges, new Function<KeyRange, Split>() {
@Nullable
@Override
public Split apply(@Nullable KeyRange input) {
return new TableSplit(input == null ? null : input.getStart(), input == null ? null : input.getStop());
}
});
}
use of io.cdap.cdap.api.dataset.table.TableSplit in project cdap by caskdata.
the class SplitsTest method testSerde.
@Test
public void testSerde() throws IOException, ClassNotFoundException {
List<TableSplit> splits = Arrays.asList(new TableSplit(Bytes.toBytes("0"), Bytes.toBytes("1")), new TableSplit(Bytes.toBytes("1"), Bytes.toBytes("2")));
List<Split> decoded = Splits.decode(Splits.encode(splits), new ArrayList<Split>(), getClass().getClassLoader());
Assert.assertEquals(splits, decoded);
}
Aggregations