SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
wip
Chris Lu912d1706e75c
diff --git a/test/random_access/src/test/java/seaewedfs/mmap/MmapFileTest.java b/test/random_access/src/test/java/seaweedfs/file/MmapFileTest.javasimilarity index 98%rename from test/random_access/src/test/java/seaewedfs/mmap/MmapFileTest.javarename to test/random_access/src/test/java/seaweedfs/file/MmapFileTest.javaindex e64fb85f01..1d741ee2f6 100644--- a/test/random_access/src/test/java/seaewedfs/mmap/MmapFileTest.java+++ b/test/random_access/src/test/java/seaweedfs/file/MmapFileTest.java@@ -1,4 +1,4 @@-package seaewedfs.mmap;+package seaweedfs.file;import org.junit.Test;@@ -11,7 +11,7 @@ import java.nio.channels.FileChannel;public class MmapFileTest {- File dir = new File("/Users/chris/tmp/mm/dev");+ static File dir = new File("/Users/chris/tmp/mm/dev");@Testpublic void testMmap() {diff --git a/test/random_access/src/test/java/seaweedfs/file/RandomeAccessFileTest.java b/test/random_access/src/test/java/seaweedfs/file/RandomeAccessFileTest.javanew file mode 100644index 0000000000..cb58475672--- /dev/null+++ b/test/random_access/src/test/java/seaweedfs/file/RandomeAccessFileTest.java@@ -0,0 +1,70 @@+package seaweedfs.file;++import org.junit.Assert;+import org.junit.Test;++import java.io.File;+import java.io.IOException;+import java.io.RandomAccessFile;+import java.nio.ByteBuffer;+import java.util.Random;++public class RandomeAccessFileTest {++ @Test+ public void testRandomWriteAndRead() throws IOException {++ File f = new File(MmapFileTest.dir, "mmap_file.txt");++ RandomAccessFile af = new RandomAccessFile(f, "rw");+ af.setLength(0);+ af.close();++ Random r = new Random();++ int maxLength = 5000;++ byte[] data = new byte[maxLength];+ byte[] readData = new byte[maxLength];++ for (int i = 4096; i < maxLength; i++) {++ RandomAccessFile raf = new RandomAccessFile(f, "rw");+ long fileSize = raf.length();++ raf.readFully(readData, 0, (int)fileSize);++ for (int x=0;x<fileSize;x++){+ Assert.assertEquals(data[x], readData[x]);+ }++ int start = r.nextInt(i);+ int stop = r.nextInt(i);+ if (start > stop) {+ int t = stop;+ stop = start;+ start = t;+ }+ if (stop > fileSize) {+ fileSize = stop;+ raf.setLength(fileSize);+ }++ randomize(r, data, start, stop);+ raf.seek(start);+ raf.write(data, start, stop-start);++ raf.close();+ }++ }++ private static void randomize(Random r, byte[] bytes, int start, int stop) {+ for (int i = start; i < stop; i++) {+ int rnd = r.nextInt();+ bytes[i] = (byte) rnd;+ }+ }+++}