13
13
import tech .ydb .core .Status ;
14
14
import tech .ydb .core .grpc .GrpcTransport ;
15
15
import tech .ydb .proto .ValueProtos ;
16
- import tech .ydb .proto .scheme .SchemeOperationProtos ;
17
16
import tech .ydb .scheme .SchemeClient ;
17
+ import tech .ydb .scheme .description .EntryType ;
18
18
import tech .ydb .scheme .description .ListDirectoryResult ;
19
19
import tech .ydb .table .Session ;
20
20
import tech .ydb .table .description .TableDescription ;
@@ -265,7 +265,7 @@ public List<String> getTableNames(boolean recursive) {
265
265
266
266
public List <String > getDirectoryNames () {
267
267
return listDirectory (tablespace ).stream ()
268
- .filter (e -> e .getType () == SchemeOperationProtos . Entry . Type .DIRECTORY )
268
+ .filter (e -> e .getType () == EntryType .DIRECTORY )
269
269
.map (DirectoryEntity ::getName )
270
270
.collect (toList ());
271
271
}
@@ -301,9 +301,9 @@ private List<DirectoryEntity> tables(String canonicalPath, String subDir, boolea
301
301
String tableDir = YdbPaths .join (canonicalPath , subDir );
302
302
List <DirectoryEntity > result = new ArrayList <>();
303
303
for (DirectoryEntity entity : listDirectory (tableDir )) {
304
- if (recursive && entity .getType () == SchemeOperationProtos . Entry . Type .DIRECTORY ) {
304
+ if (recursive && entity .getType () == EntryType .DIRECTORY ) {
305
305
result .addAll (tables (canonicalPath , YdbPaths .join (subDir , entity .getName ()), true ));
306
- } else if (entity .getType () == SchemeOperationProtos . Entry . Type .TABLE ) {
306
+ } else if (entity .getType () == EntryType .TABLE ) {
307
307
result .add (entity .withName (YdbPaths .join (subDir , entity .getName ())));
308
308
}
309
309
}
@@ -422,25 +422,16 @@ protected void copyTable(String source, String destination) {
422
422
423
423
@ SneakyThrows
424
424
private List <DirectoryEntity > listDirectory (String directory ) {
425
- ListDirectoryResult result = schemeClient .listDirectory (directory ).join ()
426
- .getValue ();
425
+ ListDirectoryResult result = schemeClient .listDirectory (directory ).join ().getValue ();
427
426
428
- List <String > errors = new ArrayList <>();
429
- List <DirectoryEntity > tables = result .getChildren ().stream ()
427
+ return result .getEntryChildren ().stream ()
430
428
.filter (entry -> switch (entry .getType ()) {
431
429
case DIRECTORY , TABLE -> true ;
432
- case COLUMN_STORE , COORDINATION_NODE -> false ;
433
- default -> {
434
- errors .add (String .format ("Unexpected entry type (%s:%s) in directory %s" , entry .getType (), entry .getName (), directory ));
435
- yield false ;
436
- }
430
+ // Just ignore directory entries unsupported by YOJ
431
+ default -> false ;
437
432
})
438
433
.map (tEntry -> new DirectoryEntity (tEntry .getType (), tEntry .getName ()))
439
- .collect (toList ());
440
- if (!errors .isEmpty ()) {
441
- throw new IllegalStateException (String .join (String .format ("%n" ), errors ));
442
- }
443
- return tables ;
434
+ .toList ();
444
435
}
445
436
446
437
protected void mkdirs (String dir ) {
@@ -458,7 +449,7 @@ protected boolean hasPath(String path) {
458
449
459
450
@ Value
460
451
private static class DirectoryEntity {
461
- SchemeOperationProtos . Entry . Type type ;
452
+ EntryType type ;
462
453
@ With
463
454
String name ;
464
455
}
0 commit comments