Search in sources :

Example 1 with ShardDeleteDelta

use of com.facebook.presto.raptor.metadata.ShardDeleteDelta in project presto by prestodb.

the class TestOrcStorageManager method testWriteDeltaDeleteAll.

@Test
public void testWriteDeltaDeleteAll() {
    // delete every row
    BitSet rowsToDelete = new BitSet();
    rowsToDelete.set(0);
    rowsToDelete.set(1);
    rowsToDelete.set(2);
    Collection<Slice> fragments = deltaDelete(rowsToDelete, false);
    Slice shardDelta = Iterables.getOnlyElement(fragments);
    ShardDeleteDelta shardDeltas = jsonCodec(ShardDeleteDelta.class).fromJson(shardDelta.getBytes());
    assertEquals(shardDeltas.getDeltaInfoPair().getNewDeltaDeleteShard(), Optional.empty());
    // verify recorded shard
    List<RecordedShard> recordedShards = shardRecorder.getShards();
    assertEquals(recordedShards.size(), 1);
}
Also used : ShardDeleteDelta(com.facebook.presto.raptor.metadata.ShardDeleteDelta) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Slice(io.airlift.slice.Slice) BitSet(java.util.BitSet) RecordedShard(com.facebook.presto.raptor.storage.InMemoryShardRecorder.RecordedShard) Test(org.testng.annotations.Test)

Example 2 with ShardDeleteDelta

use of com.facebook.presto.raptor.metadata.ShardDeleteDelta in project presto by prestodb.

the class TestOrcStorageManager method testWriteDeltaDelete.

@Test
public void testWriteDeltaDelete() throws Exception {
    FileSystem fileSystem = new LocalOrcDataEnvironment().getFileSystem(DEFAULT_RAPTOR_CONTEXT);
    // delete one row
    BitSet rowsToDelete = new BitSet();
    rowsToDelete.set(0);
    Collection<Slice> fragments = deltaDelete(rowsToDelete, false);
    Slice shardDelta = Iterables.getOnlyElement(fragments);
    ShardDeleteDelta shardDeltas = jsonCodec(ShardDeleteDelta.class).fromJson(shardDelta.getBytes());
    ShardInfo shardInfo = shardDeltas.getDeltaInfoPair().getNewDeltaDeleteShard().get();
    // Check that output file (new delta file) has one row
    assertEquals(shardInfo.getRowCount(), 1);
    assertTrue(checkContent(fileSystem, shardInfo.getShardUuid(), rowsToDelete));
    // Check that storage file is same as backup file
    File storageFile = new File(storageService.getStorageFile(shardInfo.getShardUuid()).toString());
    File backupFile = fileBackupStore.getBackupFile(shardInfo.getShardUuid());
    assertFileEquals(storageFile, backupFile);
    // Verify recorded shard
    List<RecordedShard> recordedShards = shardRecorder.getShards();
    // original file + delta file
    assertEquals(recordedShards.size(), 2);
    assertEquals(recordedShards.get(1).getTransactionId(), TRANSACTION_ID);
    assertEquals(recordedShards.get(1).getShardUuid(), shardInfo.getShardUuid());
}
Also used : ShardDeleteDelta(com.facebook.presto.raptor.metadata.ShardDeleteDelta) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Slice(io.airlift.slice.Slice) FileSystem(org.apache.hadoop.fs.FileSystem) RaptorLocalFileSystem(com.facebook.presto.raptor.filesystem.RaptorLocalFileSystem) BitSet(java.util.BitSet) LocalOrcDataEnvironment(com.facebook.presto.raptor.filesystem.LocalOrcDataEnvironment) RecordedShard(com.facebook.presto.raptor.storage.InMemoryShardRecorder.RecordedShard) FileAssert.assertFile(org.testng.FileAssert.assertFile) File(java.io.File) ShardInfo(com.facebook.presto.raptor.metadata.ShardInfo) Test(org.testng.annotations.Test)

Example 3 with ShardDeleteDelta

use of com.facebook.presto.raptor.metadata.ShardDeleteDelta in project presto by prestodb.

the class TestOrcStorageManager method testWriteDeltaDeleteMerge.

@Test
public // rowsToDelete and rowsDeleted must be mutually exclusive
void testWriteDeltaDeleteMerge() throws Exception {
    FileSystem fileSystem = new LocalOrcDataEnvironment().getFileSystem(DEFAULT_RAPTOR_CONTEXT);
    BitSet rowsToDelete = new BitSet();
    rowsToDelete.set(0);
    Collection<Slice> fragments = deltaDelete(rowsToDelete, true);
    Slice shardDelta = Iterables.getOnlyElement(fragments);
    ShardDeleteDelta shardDeltas = jsonCodec(ShardDeleteDelta.class).fromJson(shardDelta.getBytes());
    ShardInfo shardInfo = shardDeltas.getDeltaInfoPair().getNewDeltaDeleteShard().get();
    // Check that output file (new delta file) has merged 2 rows
    assertEquals(shardInfo.getRowCount(), 2);
    assertTrue(checkContent(fileSystem, shardInfo.getShardUuid(), rowsToDelete));
    // Check that storage file is same as backup file
    File storageFile = new File(storageService.getStorageFile(shardInfo.getShardUuid()).toString());
    File backupFile = fileBackupStore.getBackupFile(shardInfo.getShardUuid());
    assertFileEquals(storageFile, backupFile);
    // Verify recorded shard
    List<RecordedShard> recordedShards = shardRecorder.getShards();
    // original file + old delta + new delta
    assertEquals(recordedShards.size(), 3);
    assertEquals(recordedShards.get(2).getTransactionId(), TRANSACTION_ID);
    assertEquals(recordedShards.get(2).getShardUuid(), shardInfo.getShardUuid());
}
Also used : ShardDeleteDelta(com.facebook.presto.raptor.metadata.ShardDeleteDelta) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Slice(io.airlift.slice.Slice) FileSystem(org.apache.hadoop.fs.FileSystem) RaptorLocalFileSystem(com.facebook.presto.raptor.filesystem.RaptorLocalFileSystem) BitSet(java.util.BitSet) LocalOrcDataEnvironment(com.facebook.presto.raptor.filesystem.LocalOrcDataEnvironment) RecordedShard(com.facebook.presto.raptor.storage.InMemoryShardRecorder.RecordedShard) FileAssert.assertFile(org.testng.FileAssert.assertFile) File(java.io.File) ShardInfo(com.facebook.presto.raptor.metadata.ShardInfo) Test(org.testng.annotations.Test)

Example 4 with ShardDeleteDelta

use of com.facebook.presto.raptor.metadata.ShardDeleteDelta in project presto by prestodb.

the class TestOrcStorageManager method testWriteDeltaDeleteMergeAll.

@Test
public void testWriteDeltaDeleteMergeAll() {
    // delete every row
    BitSet rowsToDelete = new BitSet();
    rowsToDelete.set(0);
    rowsToDelete.set(1);
    Collection<Slice> fragments = deltaDelete(rowsToDelete, true);
    Slice shardDelta = Iterables.getOnlyElement(fragments);
    ShardDeleteDelta shardDeltas = jsonCodec(ShardDeleteDelta.class).fromJson(shardDelta.getBytes());
    assertEquals(shardDeltas.getDeltaInfoPair().getNewDeltaDeleteShard(), Optional.empty());
    // verify recorded shard
    List<RecordedShard> recordedShards = shardRecorder.getShards();
    // original file + old delta
    assertEquals(recordedShards.size(), 2);
}
Also used : ShardDeleteDelta(com.facebook.presto.raptor.metadata.ShardDeleteDelta) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Slice(io.airlift.slice.Slice) BitSet(java.util.BitSet) RecordedShard(com.facebook.presto.raptor.storage.InMemoryShardRecorder.RecordedShard) Test(org.testng.annotations.Test)

Aggregations

ShardDeleteDelta (com.facebook.presto.raptor.metadata.ShardDeleteDelta)4 RecordedShard (com.facebook.presto.raptor.storage.InMemoryShardRecorder.RecordedShard)4 Slice (io.airlift.slice.Slice)4 Slices.utf8Slice (io.airlift.slice.Slices.utf8Slice)4 BitSet (java.util.BitSet)4 Test (org.testng.annotations.Test)4 LocalOrcDataEnvironment (com.facebook.presto.raptor.filesystem.LocalOrcDataEnvironment)2 RaptorLocalFileSystem (com.facebook.presto.raptor.filesystem.RaptorLocalFileSystem)2 ShardInfo (com.facebook.presto.raptor.metadata.ShardInfo)2 File (java.io.File)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 FileAssert.assertFile (org.testng.FileAssert.assertFile)2