keith-turner commented on code in PR #4816:
URL: https://github.com/apache/accumulo/pull/4816#discussion_r1727754720
##########
core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java:
##########
@@ -88,6 +95,7 @@ class RFileScanner extends ScannerOptions implements Scanner {
private long readaheadThreshold = 3;
private AccumuloConfiguration tableConf;
private CryptoService cryptoService;
+ private final TableId dummyTableId;
Review Comment:
This could be static
##########
core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java:
##########
@@ -335,6 +357,57 @@ public boolean isSamplingEnabled() {
public SamplerConfiguration getSamplerConfiguration() {
return RFileScanner.this.getSamplerConfiguration();
}
+
+ @Override
+ public TableId getTableId() {
+ return dummyTableId;
+ }
+
+ @Override
+ @Deprecated(since = "2.0.0")
+ public AccumuloConfiguration getConfig() {
+ return tableConf;
+ }
+
+ @Override
+ @Deprecated(since = "2.1.0")
+ public ServiceEnvironment getServiceEnv() {
+ return serviceEnvironment.get();
+ }
+
+ private ServiceEnvironment createServiceEnv() {
+ return new ServiceEnvironment() {
+ @Override
+ public <T> T instantiate(TableId tableId, String className, Class<T>
base)
+ throws ReflectiveOperationException {
+ return instantiate(className, base);
+ }
+
+ @Override
+ public <T> T instantiate(String className, Class<T> base)
+ throws ReflectiveOperationException {
+ return
this.getClass().getClassLoader().loadClass(className).asSubclass(base)
+ .getDeclaredConstructor().newInstance();
+ }
+
+ @Override
+ public String getTableName(TableId tableId) {
+ throw new UnsupportedOperationException(errorMsg);
Review Comment:
```suggestion
if(!tableId.equals(dummyTableId)){
throw new UnsupportedOperationException(errorMsg);
} else {
return "RFileScannerFakeTableName";
}
```
##########
test/src/main/java/org/apache/accumulo/test/IteratorEnvIT.java:
##########
@@ -222,6 +243,49 @@ private void testScan(String tableName,
}
}
+ private void testRFileScan(Class<? extends
SortedKeyValueIterator<Key,Value>> iteratorClass)
+ throws Exception {
+ LocalFileSystem fs = FileSystem.getLocal(new Configuration());
+ String rFilePath = createRFile(fs);
+ IteratorSetting is = new IteratorSetting(1, iteratorClass);
+
+ try (Scanner scanner =
RFile.newScanner().from(rFilePath).withFileSystem(fs)
+ .withTableProperties(getTableConfig().getProperties()).build()) {
+ scanner.addScanIterator(is);
+ var unused = scanner.iterator();
+ }
+ }
+
+ public void testOfflineScan(String tableName,
+ Class<? extends SortedKeyValueIterator<Key,Value>> iteratorClass) throws
Exception {
+ writeData(tableName);
+ TableId tableId = getServerContext().getTableId(tableName);
+ getServerContext().tableOperations().offline(tableName, true);
+ IteratorSetting is = new IteratorSetting(1, iteratorClass);
+ is.addOption("expected.table.id",
+ getServerContext().tableOperations().tableIdMap().get(tableName));
+
+ try (OfflineScanner scanner =
+ new OfflineScanner(getServerContext(), tableId, new Authorizations()))
{
+ scanner.addScanIterator(is);
+ var unused = scanner.iterator();
+ }
+ }
+
+ public void testClientSideScan(String tableName,
+ Class<? extends SortedKeyValueIterator<Key,Value>> iteratorClass) throws
Exception {
+ writeData(tableName);
+ IteratorSetting is = new IteratorSetting(1, iteratorClass);
+ is.addOption("expected.table.id",
+ getServerContext().tableOperations().tableIdMap().get(tableName));
+
+ try (Scanner scanner = client.createScanner(tableName);
+ var clientIterScanner = new ClientSideIteratorScanner(scanner)) {
+ clientIterScanner.addScanIterator(is);
+ var unused = clientIterScanner.iterator();
Review Comment:
This may be a preexisting problem with this test, not sure. It seems like
there is no positive confirmation that the init code was actually called. If
there was a bug and the init method on the iterator was never called then the
checks that happen in init would never be done. Once possible way to solve
this is to filter data based on config passed to init. Then if we read the
data and see it was filtered we know the init method was called. If this is a
preexisting problem with the test we can open a follow on issue if that seems
cleaner.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]