Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public List<BlockData> listBlock(Container container, long startLocalID, int
result = new ArrayList<>();
String startKey = (startLocalID == -1) ? cData.startKeyEmpty()
: cData.getBlockKey(startLocalID);
List<? extends Table.KeyValue<String, BlockData>> range =
List<Table.KeyValue<String, BlockData>> range =
db.getStore().getBlockDataTable()
.getSequentialRangeKVs(startKey, count,
cData.containerPrefix(), cData.getUnprefixedKeyFilter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ public ContainerBackgroundTaskResult deleteViaSchema1(

// # of blocks to delete is throttled
KeyPrefixFilter filter = containerData.getDeletingBlockKeyFilter();
List<? extends Table.KeyValue<String, BlockData>> toDeleteBlocks =
blockDataTable
List<Table.KeyValue<String, BlockData>> toDeleteBlocks = blockDataTable
.getSequentialRangeKVs(containerData.startKeyEmpty(),
(int) blocksToDelete, containerData.containerPrefix(),
filter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ public VALUE getReadCopy(KEY key) throws IOException {
}

@Override
public List<? extends KeyValue<KEY, VALUE>> getRangeKVs(
public List<KeyValue<KEY, VALUE>> getRangeKVs(
KEY startKey, int count, KEY prefix,
MetadataKeyFilters.MetadataKeyFilter... filters)
throws IOException, IllegalArgumentException {
return table.getRangeKVs(startKey, count, prefix, filters);
}

@Override
public List<? extends KeyValue<KEY, VALUE>> getSequentialRangeKVs(
public List<KeyValue<KEY, VALUE>> getSequentialRangeKVs(
KEY startKey, int count, KEY prefix,
MetadataKeyFilters.MetadataKeyFilter... filters)
throws IOException, IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ChunkInfoList getReadCopy(String key) throws IOException {
}

@Override
public List<? extends KeyValue<String, ChunkInfoList>> getRangeKVs(
public List<KeyValue<String, ChunkInfoList>> getRangeKVs(
String startKey, int count, String prefix,
MetadataKeyFilters.MetadataKeyFilter... filters)
throws IOException, IllegalArgumentException {
Expand All @@ -112,7 +112,7 @@ public List<? extends KeyValue<String, ChunkInfoList>> getRangeKVs(
}

@Override
public List<? extends KeyValue<String, ChunkInfoList>> getSequentialRangeKVs(
public List<KeyValue<String, ChunkInfoList>> getSequentialRangeKVs(
String startKey, int count, String prefix,
MetadataKeyFilters.MetadataKeyFilter... filters)
throws IOException, IllegalArgumentException {
Expand Down Expand Up @@ -143,7 +143,7 @@ private static String unprefix(String key) {
}

private static List<KeyValue<String, ChunkInfoList>> unprefix(
List<? extends KeyValue<String, ChunkInfoList>> kvs) {
List<KeyValue<String, ChunkInfoList>> kvs) {

return kvs.stream()
.map(kv -> Table.newKeyValue(unprefix(kv.getKey()), kv.getValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void testBlockIteration(String schemaVersion) throws Exception {
refCountedDB.getStore().getDeletedBlocksTable();

// Test rangeKVs.
List<? extends Table.KeyValue<String, ChunkInfoList>> deletedBlocks =
List<Table.KeyValue<String, ChunkInfoList>> deletedBlocks =
deletedBlocksTable.getRangeKVs(cData.startKeyEmpty(), 100,
cData.containerPrefix());

Expand Down Expand Up @@ -357,7 +357,7 @@ public void testReadDeletedBlockChunkInfo(String schemaVersion)
KeyValueContainerData cData = newKvData();
try (DBHandle refCountedDB = BlockUtils.getDB(cData, conf)) {
// Read blocks that were already deleted before the upgrade.
List<? extends Table.KeyValue<String, ChunkInfoList>> deletedBlocks =
List<Table.KeyValue<String, ChunkInfoList>> deletedBlocks =
refCountedDB.getStore().getDeletedBlocksTable()
.getRangeKVs(cData.startKeyEmpty(), 100,
cData.containerPrefix());
Expand Down Expand Up @@ -416,7 +416,7 @@ public void testReadBlockData(String schemaVersion) throws Exception {
}

// Test decoding keys from the database.
List<? extends Table.KeyValue<String, BlockData>> blockKeyValues =
List<Table.KeyValue<String, BlockData>> blockKeyValues =
blockDataTable.getRangeKVs(cData.startKeyEmpty(), 100,
cData.containerPrefix(), cData.getUnprefixedKeyFilter());

Expand Down Expand Up @@ -462,7 +462,7 @@ public void testReadDeletingBlockData(String schemaVersion) throws Exception {
}

// Test decoding keys from the database.
List<? extends Table.KeyValue<String, BlockData>> blockKeyValues =
List<Table.KeyValue<String, BlockData>> blockKeyValues =
blockDataTable.getRangeKVs(cData.startKeyEmpty(), 100,
cData.containerPrefix(), cData.getDeletingBlockKeyFilter());

Expand Down Expand Up @@ -535,7 +535,7 @@ public void testReadDeletedBlocks(String schemaVersion) throws Exception {
}

// Test decoding keys from the database.
List<? extends Table.KeyValue<String, ChunkInfoList>> chunkInfoKeyValues =
List<Table.KeyValue<String, ChunkInfoList>> chunkInfoKeyValues =
deletedBlocksTable.getRangeKVs(cData.startKeyEmpty(), 100,
cData.containerPrefix());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ default TableCacheMetrics createCacheMetrics() throws IOException {
* @throws IOException if there are I/O errors.
* @throws IllegalArgumentException if count is less than 0.
*/
List<? extends KeyValue<KEY, VALUE>> getRangeKVs(KEY startKey,
List<KeyValue<KEY, VALUE>> getRangeKVs(KEY startKey,
int count, KEY prefix,
MetadataKeyFilters.MetadataKeyFilter... filters)
throws IOException, IllegalArgumentException;
Expand All @@ -295,7 +295,7 @@ List<? extends KeyValue<KEY, VALUE>> getRangeKVs(KEY startKey,
* @throws IOException
* @throws IllegalArgumentException
*/
List<? extends KeyValue<KEY, VALUE>> getSequentialRangeKVs(KEY startKey,
List<KeyValue<KEY, VALUE>> getSequentialRangeKVs(KEY startKey,
int count, KEY prefix,
MetadataKeyFilters.MetadataKeyFilter... filters)
throws IOException, IllegalArgumentException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public void deleteRange(KEY beginKey, KEY endKey) throws IOException {
}

@Override
public Table.KeyValueIterator<KEY, VALUE> iterator(KEY prefix, KeyValueIterator.Type type) throws IOException {
public KeyValueIterator<KEY, VALUE> iterator(KEY prefix, KeyValueIterator.Type type) throws IOException {
if (supportCodecBuffer) {
final CodecBuffer prefixBuffer = encodeKeyCodecBuffer(prefix);
try {
Expand Down Expand Up @@ -469,7 +469,7 @@ public List<KeyValue<KEY, VALUE>> getRangeKVs(
final byte[] startKeyBytes = encodeKey(startKey);
final byte[] prefixBytes = encodeKey(prefix);

List<? extends KeyValue<byte[], byte[]>> rangeKVBytes =
List<KeyValue<byte[], byte[]>> rangeKVBytes =
rawTable.getRangeKVs(startKeyBytes, count, prefixBytes, filters);
return convert(rangeKVBytes);
}
Expand All @@ -485,14 +485,13 @@ public List<KeyValue<KEY, VALUE>> getSequentialRangeKVs(
final byte[] startKeyBytes = encodeKey(startKey);
final byte[] prefixBytes = encodeKey(prefix);

List<? extends KeyValue<byte[], byte[]>> rangeKVBytes =
List<KeyValue<byte[], byte[]>> rangeKVBytes =
rawTable.getSequentialRangeKVs(startKeyBytes, count,
prefixBytes, filters);
return convert(rangeKVBytes);
}

private List<KeyValue<KEY, VALUE>> convert(List<? extends KeyValue<byte[], byte[]>> rangeKVBytes)
throws CodecException {
private List<KeyValue<KEY, VALUE>> convert(List<KeyValue<byte[], byte[]>> rangeKVBytes) throws CodecException {
final List<KeyValue<KEY, VALUE>> rangeKVs = new ArrayList<>();
for (KeyValue<byte[], byte[]> kv : rangeKVBytes) {
rangeKVs.add(Table.newKeyValue(decodeKey(kv.getKey()), decodeValue(kv.getValue())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
import java.util.Map;
import java.util.TreeMap;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.hdds.utils.db.TableIterator;

/**
* Generic Table Iterator implementation that can be used for unit tests to reduce redundant mocking in tests.
*/
public class MapBackedTableIterator<V> implements TableIterator<String, Table.KeyValue<String, V>> {
public class MapBackedTableIterator<V> implements Table.KeyValueIterator<String, V> {

private Iterator<Table.KeyValue<String, V>> itr;
private final String prefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.hdds.utils.db.Table.KeyValue;
import org.apache.hadoop.hdds.utils.db.TableConfig;
import org.apache.hadoop.hdds.utils.db.TableIterator;
import org.apache.hadoop.hdds.utils.db.managed.ManagedColumnFamilyOptions;
import org.apache.hadoop.hdds.utils.db.managed.ManagedDBOptions;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -190,7 +189,7 @@ public void compareDB(File db1, File db2, int columnFamilyUsed)
final String name = families.get(i);
final Table<byte[], byte[]> table1 = rdbStore1.getTable(name);
final Table<byte[], byte[]> table2 = rdbStore2.getTable(name);
try (TableIterator<byte[], ? extends KeyValue<byte[], byte[]>> iterator
try (Table.KeyValueIterator<byte[], byte[]> iterator
= table1.iterator()) {
while (iterator.hasNext()) {
KeyValue<byte[], byte[]> keyValue = iterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ public long getEstimatedKeyCount() {
}

@Override
public List<? extends KeyValue<KEY, VALUE>> getRangeKVs(KEY startKey, int count, KEY prefix,
public List<KeyValue<KEY, VALUE>> getRangeKVs(KEY startKey, int count, KEY prefix,
MetadataKeyFilters.MetadataKeyFilter... filters)
throws IOException, IllegalArgumentException {
throw new UnsupportedOperationException();
}

@Override
public List<? extends KeyValue<KEY, VALUE>> getSequentialRangeKVs(KEY startKey, int count, KEY prefix,
public List<KeyValue<KEY, VALUE>> getSequentialRangeKVs(KEY startKey, int count, KEY prefix,
MetadataKeyFilters.MetadataKeyFilter... filters) {
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public void putGetTypedTableCodec() throws Exception {
@Test
public void forEachAndIterator() throws Exception {
final int iterCount = 100;
try (Table testTable = rdbStore.getTable("Sixth")) {
try (Table<byte[], byte[]> testTable = rdbStore.getTable("Sixth")) {
for (int x = 0; x < iterCount; x++) {
byte[] key =
RandomStringUtils.secure().next(10).getBytes(StandardCharsets.UTF_8);
Expand All @@ -332,9 +332,9 @@ public void forEachAndIterator() throws Exception {
testTable.put(key, value);
}
int localCount = 0;
try (TableIterator<byte[], Table.KeyValue> iter = testTable.iterator()) {
try (Table.KeyValueIterator<byte[], byte[]> iter = testTable.iterator()) {
while (iter.hasNext()) {
Table.KeyValue keyValue = iter.next();
iter.next();
localCount++;
}

Expand Down Expand Up @@ -491,7 +491,7 @@ public void testIteratorRemoveFromDB() throws Exception {
// Remove without next removes first entry.
try (Table<byte[], byte[]> testTable = rdbStore.getTable("Fifth")) {
writeToTable(testTable, 3);
try (TableIterator<?, ? extends Table.KeyValue<?, ?>> iterator =
try (Table.KeyValueIterator<?, ?> iterator =
testTable.iterator()) {
iterator.removeFromDB();
}
Expand All @@ -503,7 +503,7 @@ public void testIteratorRemoveFromDB() throws Exception {
// Remove after seekToLast removes lastEntry
try (Table<byte[], byte[]> testTable = rdbStore.getTable("Sixth")) {
writeToTable(testTable, 3);
try (TableIterator<?, ? extends Table.KeyValue<?, ?>> iterator =
try (Table.KeyValueIterator<?, ?> iterator =
testTable.iterator()) {
iterator.seekToLast();
iterator.removeFromDB();
Expand All @@ -516,7 +516,7 @@ public void testIteratorRemoveFromDB() throws Exception {
// Remove after seek deletes that entry.
try (Table<byte[], byte[]> testTable = rdbStore.getTable("Sixth")) {
writeToTable(testTable, 3);
try (TableIterator<byte[], ? extends Table.KeyValue<?, ?>> iterator =
try (Table.KeyValueIterator<byte[], byte[]> iterator =
testTable.iterator()) {
iterator.seek(bytesOf[3]);
iterator.removeFromDB();
Expand All @@ -529,7 +529,7 @@ public void testIteratorRemoveFromDB() throws Exception {
// Remove after next() deletes entry that was returned by next.
try (Table<byte[], byte[]> testTable = rdbStore.getTable("Sixth")) {
writeToTable(testTable, 3);
try (TableIterator<byte[], ? extends Table.KeyValue<?, ?>> iterator =
try (Table.KeyValueIterator<byte[], byte[]> iterator =
testTable.iterator()) {
iterator.seek(bytesOf[2]);
iterator.next();
Expand Down Expand Up @@ -564,8 +564,7 @@ public void testPrefixedIterator() throws Exception {
// iterator should seek to right pos in the middle
byte[] samplePrefix = testPrefixes.get(2).getBytes(
StandardCharsets.UTF_8);
try (TableIterator<byte[],
? extends Table.KeyValue<byte[], byte[]>> iter = testTable.iterator(
try (Table.KeyValueIterator<byte[], byte[]> iter = testTable.iterator(
samplePrefix)) {
int keyCount = 0;
while (iter.hasNext()) {
Expand Down Expand Up @@ -656,7 +655,7 @@ public void testPrefixedRangeKVs() throws Exception {

// test start at first
byte[] startKey = samplePrefix;
List<? extends Table.KeyValue<byte[], byte[]>> rangeKVs = testTable
List<Table.KeyValue<byte[], byte[]>> rangeKVs = testTable
.getRangeKVs(startKey, 3, samplePrefix);
assertEquals(3, rangeKVs.size());

Expand Down Expand Up @@ -710,8 +709,7 @@ public void testDumpAndLoadBasic() throws Exception {
testTable2.loadFromFile(dumpFile);

// check loaded keys
try (TableIterator<byte[],
? extends Table.KeyValue<byte[], byte[]>> iter = testTable2.iterator(
try (Table.KeyValueIterator<byte[], byte[]> iter = testTable2.iterator(
samplePrefix)) {
int keyCount = 0;
while (iter.hasNext()) {
Expand Down Expand Up @@ -751,8 +749,7 @@ public void testDumpAndLoadEmpty() throws Exception {
testTable2.loadFromFile(dumpFile);

// check loaded keys
try (TableIterator<byte[],
? extends Table.KeyValue<byte[], byte[]>> iter = testTable2.iterator(
try (Table.KeyValueIterator<byte[], byte[]> iter = testTable2.iterator(
samplePrefix)) {
int keyCount = 0;
while (iter.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import java.util.Set;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.StringUtils;
import org.apache.hadoop.hdds.utils.db.Table.KeyValue;
import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
import org.apache.hadoop.hdds.utils.db.cache.TableCache.CacheType;
Expand Down Expand Up @@ -227,7 +226,7 @@ public void forEachAndIterator() throws Exception {
}
int localCount = 0;

try (TableIterator<String, ? extends KeyValue<String, String>> iter =
try (Table.KeyValueIterator<String, String> iter =
testTable.iterator()) {
while (iter.hasNext()) {
Table.KeyValue keyValue = iter.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public List<X509Certificate> listCertificate(NodeType role,
.collect(Collectors.toList());
}

private List<? extends Table.KeyValue<BigInteger, X509Certificate>>
private List<Table.KeyValue<BigInteger, X509Certificate>>
getValidCertTableList(NodeType role, BigInteger startSerialID, int count)
throws IOException {
// Implemented for role SCM and CertType VALID_CERTS.
Expand Down
Loading