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);
}
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());
}
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());
}
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);
}
Aggregations