gzip compressoin test
This commit is contained in:
@@ -323,15 +323,13 @@ public class DataFile implements Closeable
|
|||||||
compressedData = data;
|
compressedData = data;
|
||||||
stream.writeInt(data.length);
|
stream.writeInt(data.length);
|
||||||
break;
|
break;
|
||||||
|
case 1:
|
||||||
|
compressedData = (byte[]) null;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException();
|
compressedData = GZip.compress(data);
|
||||||
// case 1:
|
stream.writeInt(compressedData.length);
|
||||||
// compressedData = (byte[]) null;
|
stream.writeInt(data.length);
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// compressedData = GZipCompressor.compress(data);
|
|
||||||
// stream.writeInt(compressedData.length);
|
|
||||||
// stream.writeInt(data.length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.writeBytes(compressedData);
|
stream.writeBytes(compressedData);
|
||||||
|
|||||||
@@ -50,4 +50,18 @@ public class DataFileTest
|
|||||||
Assert.assertArrayEquals(b, buf);
|
Assert.assertArrayEquals(b, buf);
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGZipCompression() throws IOException
|
||||||
|
{
|
||||||
|
try (Store store = new Store(folder.getRoot()))
|
||||||
|
{
|
||||||
|
DataFile df = new DataFile(store, folder.newFile());
|
||||||
|
DataFileWriteResult res = df.write(41, 4, ByteBuffer.wrap("test".getBytes()), 2, 0);
|
||||||
|
DataFileReadResult res2 = df.read(41, 4, res.sector, res.compressedLength);
|
||||||
|
byte[] buf = res2.data;
|
||||||
|
String str = new String(buf);
|
||||||
|
Assert.assertEquals("test", str);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user