@@ -64,13 +64,13 @@ a protected directory, result in such an exception being raised.
64
64
65
65
### ` boolean isDirectory(Path p) `
66
66
67
- def isDirectory (FS, p)= p in directories(FS)
67
+ def isDir (FS, p) = p in directories(FS)
68
68
69
69
70
70
### ` boolean isFile(Path p) `
71
71
72
72
73
- def isFile(FS, p) = p in files (FS)
73
+ def isFile(FS, p) = p in filenames (FS)
74
74
75
75
76
76
### ` FileStatus getFileStatus(Path p) `
@@ -250,7 +250,7 @@ process.
250
250
changes are made to the filesystem, the result of ` listStatus(parent(P)) ` SHOULD
251
251
include the value of ` getFileStatus(P) ` .
252
252
253
- * After an entry at path ` P ` is created , and before any other
253
+ * After an entry at path ` P ` is deleted , and before any other
254
254
changes are made to the filesystem, the result of ` listStatus(parent(P)) ` SHOULD
255
255
NOT include the value of ` getFileStatus(P) ` .
256
256
@@ -305,7 +305,7 @@ that they must all be listed, and, at the time of listing, exist.
305
305
All paths must exist. There is no requirement for uniqueness.
306
306
307
307
forall p in paths :
308
- exists(fs , p) else raise FileNotFoundException
308
+ exists(FS , p) else raise FileNotFoundException
309
309
310
310
#### Postconditions
311
311
@@ -381,7 +381,7 @@ being completely performed.
381
381
382
382
Path ` path ` must exist:
383
383
384
- exists(FS, path) : raise FileNotFoundException
384
+ if not exists(FS, path) : raise FileNotFoundException
385
385
386
386
#### Postconditions
387
387
@@ -432,7 +432,7 @@ of data which must be collected in a single RPC call.
432
432
433
433
#### Preconditions
434
434
435
- exists(FS, path) else raise FileNotFoundException
435
+ if not exists(FS, path) : raise FileNotFoundException
436
436
437
437
### Postconditions
438
438
@@ -463,7 +463,7 @@ and 1 for file count.
463
463
464
464
#### Preconditions
465
465
466
- exists(FS, path) else raise FileNotFoundException
466
+ if not exists(FS, path) : raise FileNotFoundException
467
467
468
468
#### Postconditions
469
469
@@ -567,7 +567,7 @@ when writing objects to a path in the filesystem.
567
567
#### Postconditions
568
568
569
569
570
- result = integer >= 0
570
+ result = integer >= 0
571
571
572
572
The outcome of this operation is usually identical to ` getDefaultBlockSize() ` ,
573
573
with no checks for the existence of the given path.
@@ -591,12 +591,12 @@ on the filesystem.
591
591
592
592
#### Preconditions
593
593
594
- if not exists(FS, p) : raise FileNotFoundException
594
+ if not exists(FS, p) : raise FileNotFoundException
595
595
596
596
597
597
#### Postconditions
598
598
599
- if len(FS, P) > 0: getFileStatus(P).getBlockSize() > 0
599
+ if len(FS, P) > 0 : getFileStatus(P).getBlockSize() > 0
600
600
result == getFileStatus(P).getBlockSize()
601
601
602
602
1 . The outcome of this operation MUST be identical to the value of
@@ -654,12 +654,12 @@ No ancestor may be a file
654
654
655
655
forall d = ancestors(FS, p) :
656
656
if exists(FS, d) and not isDir(FS, d) :
657
- raise [ ParentNotDirectoryException, FileAlreadyExistsException, IOException]
657
+ raise { ParentNotDirectoryException, FileAlreadyExistsException, IOException}
658
658
659
659
#### Postconditions
660
660
661
661
662
- FS' where FS'.Directories' = FS.Directories + [p] + ancestors(FS, p)
662
+ FS' where FS'.Directories = FS.Directories + [p] + ancestors(FS, p)
663
663
result = True
664
664
665
665
@@ -688,7 +688,7 @@ The return value is always true—even if a new directory is not created
688
688
689
689
The file must not exist for a no-overwrite create:
690
690
691
- if not overwrite and isFile(FS, p) : raise FileAlreadyExistsException
691
+ if not overwrite and isFile(FS, p) : raise FileAlreadyExistsException
692
692
693
693
Writing to or overwriting a directory must fail.
694
694
@@ -698,7 +698,7 @@ No ancestor may be a file
698
698
699
699
forall d = ancestors(FS, p) :
700
700
if exists(FS, d) and not isDir(FS, d) :
701
- raise [ ParentNotDirectoryException, FileAlreadyExistsException, IOException]
701
+ raise { ParentNotDirectoryException, FileAlreadyExistsException, IOException}
702
702
703
703
FileSystems may reject the request for other
704
704
reasons, such as the FS being read-only (HDFS),
@@ -712,8 +712,8 @@ For instance, HDFS may raise an `InvalidPathException`.
712
712
#### Postconditions
713
713
714
714
FS' where :
715
- FS'.Files' [p] == []
716
- ancestors(p) is- subset-of FS'.Directories'
715
+ FS'.Files[p] == []
716
+ ancestors(p) subset-of FS'.Directories
717
717
718
718
result = FSDataOutputStream
719
719
@@ -734,7 +734,7 @@ The behavior of the returned stream is covered in [Output](outputstream.html).
734
734
clients creating files with ` overwrite==true ` to fail if the file is created
735
735
by another client between the two tests.
736
736
737
- * The S3A and potentially other Object Stores connectors not currently change the ` FS ` state
737
+ * The S3A and potentially other Object Stores connectors currently don't change the ` FS ` state
738
738
until the output stream ` close() ` operation is completed.
739
739
This is a significant difference between the behavior of object stores
740
740
and that of filesystems, as it allows > ; 1 client to create a file with ` overwrite=false ` ,
@@ -762,15 +762,15 @@ The behavior of the returned stream is covered in [Output](outputstream.html).
762
762
#### Implementation Notes
763
763
764
764
` createFile(p) ` returns a ` FSDataOutputStreamBuilder ` only and does not make
765
- change on filesystem immediately. When ` build() ` is invoked on the ` FSDataOutputStreamBuilder ` ,
765
+ changes on the filesystem immediately. When ` build() ` is invoked on the ` FSDataOutputStreamBuilder ` ,
766
766
the builder parameters are verified and [ ` create(Path p) ` ] ( #FileSystem.create )
767
767
is invoked on the underlying filesystem. ` build() ` has the same preconditions
768
768
and postconditions as [ ` create(Path p) ` ] ( #FileSystem.create ) .
769
769
770
770
* Similar to [ ` create(Path p) ` ] ( #FileSystem.create ) , files are overwritten
771
- by default, unless specify ` builder.overwrite(false) ` .
771
+ by default, unless specified by ` builder.overwrite(false) ` .
772
772
* Unlike [ ` create(Path p) ` ] ( #FileSystem.create ) , missing parent directories are
773
- not created by default, unless specify ` builder.recursive() ` .
773
+ not created by default, unless specified by ` builder.recursive() ` .
774
774
775
775
### <a name =' FileSystem.append ' ></a > ` FSDataOutputStream append(Path p, int bufferSize, Progressable progress) `
776
776
@@ -780,14 +780,14 @@ Implementations without a compliant call SHOULD throw `UnsupportedOperationExcep
780
780
781
781
if not exists(FS, p) : raise FileNotFoundException
782
782
783
- if not isFile(FS, p) : raise [ FileAlreadyExistsException, FileNotFoundException, IOException]
783
+ if not isFile(FS, p) : raise { FileAlreadyExistsException, FileNotFoundException, IOException}
784
784
785
785
#### Postconditions
786
786
787
787
FS' = FS
788
788
result = FSDataOutputStream
789
789
790
- Return: ` FSDataOutputStream ` , which can update the entry ` FS.Files[p] `
790
+ Return: ` FSDataOutputStream ` , which can update the entry ` FS' .Files[p] `
791
791
by appending data to the existing list.
792
792
793
793
The behavior of the returned stream is covered in [ Output] ( outputstream.html ) .
@@ -813,7 +813,7 @@ Implementations without a compliant call SHOULD throw `UnsupportedOperationExcep
813
813
814
814
#### Preconditions
815
815
816
- if not isFile(FS, p)) : raise [ FileNotFoundException, IOException]
816
+ if not isFile(FS, p)) : raise { FileNotFoundException, IOException}
817
817
818
818
This is a critical precondition. Implementations of some FileSystems (e.g.
819
819
Object stores) could shortcut one round trip by postponing their HTTP GET
@@ -842,7 +842,7 @@ The result MUST be the same for local and remote callers of the operation.
842
842
symbolic links
843
843
844
844
1 . HDFS throws ` IOException("Cannot open filename " + src) ` if the path
845
- exists in the metadata, but no copies of any its blocks can be located;
845
+ exists in the metadata, but no copies of its blocks can be located;
846
846
-` FileNotFoundException ` would seem more accurate and useful.
847
847
848
848
### ` FSDataInputStreamBuilder openFile(Path path) `
@@ -861,7 +861,7 @@ Implementations without a compliant call MUST throw `UnsupportedOperationExcepti
861
861
862
862
let stat = getFileStatus(Path p)
863
863
let FS' where:
864
- (FS.Directories' , FS.Files', FS.Symlinks' )
864
+ (FS' .Directories, FS.Files', FS' .Symlinks)
865
865
p' in paths(FS') where:
866
866
exists(FS, stat.path) implies exists(FS', p')
867
867
@@ -931,16 +931,16 @@ metadata in the `PathHandle` to detect references from other namespaces.
931
931
932
932
### ` FSDataInputStream open(PathHandle handle, int bufferSize) `
933
933
934
- Implementaions without a compliant call MUST throw ` UnsupportedOperationException `
934
+ Implementations without a compliant call MUST throw ` UnsupportedOperationException `
935
935
936
936
#### Preconditions
937
937
938
938
let fd = getPathHandle(FileStatus stat)
939
939
if stat.isdir : raise IOException
940
940
let FS' where:
941
- (FS.Directories' , FS.Files', FS.Symlinks' )
942
- p' in FS.Files' where:
943
- FS.Files' [p'] = fd
941
+ (FS' .Directories, FS.Files', FS' .Symlinks)
942
+ p' in FS' .Files where:
943
+ FS' .Files[p'] = fd
944
944
if not exists(FS', p') : raise InvalidPathHandleException
945
945
946
946
The implementation MUST resolve the referent of the ` PathHandle ` following
@@ -951,7 +951,7 @@ encoded in the `PathHandle`.
951
951
952
952
#### Postconditions
953
953
954
- result = FSDataInputStream(0, FS.Files' [p'])
954
+ result = FSDataInputStream(0, FS' .Files[p'])
955
955
956
956
The stream returned is subject to the constraints of a stream returned by
957
957
` open(Path) ` . Constraints checked on open MAY hold to hold for the stream, but
@@ -1006,7 +1006,7 @@ A directory with children and `recursive == False` cannot be deleted
1006
1006
1007
1007
If the file does not exist the filesystem state does not change
1008
1008
1009
- if not exists(FS, p):
1009
+ if not exists(FS, p) :
1010
1010
FS' = FS
1011
1011
result = False
1012
1012
@@ -1089,7 +1089,7 @@ Some of the object store based filesystem implementations always return
1089
1089
false when deleting the root, leaving the state of the store unchanged.
1090
1090
1091
1091
if isRoot(p) :
1092
- FS ' = FS
1092
+ FS' = FS
1093
1093
result = False
1094
1094
1095
1095
This is irrespective of the recursive flag status or the state of the directory.
@@ -1152,7 +1152,7 @@ has been calculated.
1152
1152
1153
1153
Source ` src ` must exist:
1154
1154
1155
- exists(FS, src) else raise FileNotFoundException
1155
+ if not exists(FS, src) : raise FileNotFoundException
1156
1156
1157
1157
` dest ` cannot be a descendant of ` src ` :
1158
1158
@@ -1162,7 +1162,7 @@ This implicitly covers the special case of `isRoot(FS, src)`.
1162
1162
1163
1163
` dest ` must be root, or have a parent that exists:
1164
1164
1165
- isRoot(FS, dest) or exists(FS, parent(dest)) else raise IOException
1165
+ if not ( isRoot(FS, dest) or exists(FS, parent(dest))) : raise IOException
1166
1166
1167
1167
The parent path of a destination must not be a file:
1168
1168
@@ -1240,7 +1240,8 @@ There is no consistent behavior here.
1240
1240
1241
1241
The outcome is no change to FileSystem state, with a return value of false.
1242
1242
1243
- FS' = FS; result = False
1243
+ FS' = FS
1244
+ result = False
1244
1245
1245
1246
* Local Filesystem*
1246
1247
@@ -1319,28 +1320,31 @@ Implementations without a compliant call SHOULD throw `UnsupportedOperationExcep
1319
1320
1320
1321
All sources MUST be in the same directory:
1321
1322
1322
- for s in sources: if parent(S) != parent(p) raise IllegalArgumentException
1323
+ for s in sources:
1324
+ if parent(s) != parent(p) : raise IllegalArgumentException
1323
1325
1324
1326
All block sizes must match that of the target:
1325
1327
1326
- for s in sources: getBlockSize(FS, S) == getBlockSize(FS, p)
1328
+ for s in sources:
1329
+ getBlockSize(FS, s) == getBlockSize(FS, p)
1327
1330
1328
1331
No duplicate paths:
1329
1332
1330
- not (exists p1, p2 in (sources + [p]) where p1 == p2)
1333
+ let input = sources + [p]
1334
+ not (exists i, j: i != j and input[i] == input[j])
1331
1335
1332
1336
HDFS: All source files except the final one MUST be a complete block:
1333
1337
1334
1338
for s in (sources[0:length(sources)-1] + [p]):
1335
- (length(FS, s) mod getBlockSize(FS, p)) == 0
1339
+ (length(FS, s) mod getBlockSize(FS, p)) == 0
1336
1340
1337
1341
1338
1342
#### Postconditions
1339
1343
1340
1344
1341
1345
FS' where:
1342
- (data(FS', T ) = data(FS, T ) + data(FS, sources[0]) + ... + data(FS, srcs [length(srcs )-1]))
1343
- and for s in srcs : not exists(FS', S )
1346
+ (data(FS', p ) = data(FS, p ) + data(FS, sources[0]) + ... + data(FS, sources [length(sources )-1]))
1347
+ for s in sources : not exists(FS', s )
1344
1348
1345
1349
1346
1350
HDFS's restrictions may be an implementation detail of how it implements
@@ -1360,7 +1364,7 @@ Implementations without a compliant call SHOULD throw `UnsupportedOperationExcep
1360
1364
1361
1365
if not exists(FS, p) : raise FileNotFoundException
1362
1366
1363
- if isDir(FS, p) : raise [ FileNotFoundException, IOException]
1367
+ if isDir(FS, p) : raise { FileNotFoundException, IOException}
1364
1368
1365
1369
if newLength < 0 || newLength > len(FS.Files[p]) : raise HadoopIllegalArgumentException
1366
1370
@@ -1369,8 +1373,7 @@ Truncate cannot be performed on a file, which is open for writing or appending.
1369
1373
1370
1374
#### Postconditions
1371
1375
1372
- FS' where:
1373
- len(FS.Files[p]) = newLength
1376
+ len(FS'.Files[p]) = newLength
1374
1377
1375
1378
Return: ` true ` , if truncation is finished and the file can be immediately
1376
1379
opened for appending, or ` false ` otherwise.
@@ -1399,7 +1402,7 @@ Source and destination must be different
1399
1402
if src = dest : raise FileExistsException
1400
1403
```
1401
1404
1402
- Destination and source must not be descendants one another
1405
+ Destination and source must not be descendants of one another
1403
1406
``` python
1404
1407
if isDescendant(src, dest) or isDescendant(dest, src) : raise IOException
1405
1408
```
@@ -1429,7 +1432,7 @@ Given a base path on the source `base` and a child path `child` where `base` is
1429
1432
1430
1433
``` python
1431
1434
def final_name (base , child , dest ):
1432
- is base = child:
1435
+ if base = = child:
1433
1436
return dest
1434
1437
else :
1435
1438
return dest + childElements(base, child)
@@ -1557,7 +1560,7 @@ while (iterator.hasNext()) {
1557
1560
1558
1561
As raising exceptions is an expensive operation in JVMs, the `while (hasNext())`
1559
1562
loop option is more efficient. (see also [Concurrency and the Remote Iterator](# RemoteIteratorConcurrency)
1560
- for a dicussion on this topic).
1563
+ for a discussion on this topic).
1561
1564
1562
1565
Implementors of the interface MUST support both forms of iterations; authors
1563
1566
of tests SHOULD verify that both iteration mechanisms work.
0 commit comments