Search in sources :

Example 31 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestStorageManager method testInsertElements1.

@Test(timeout = 60000)
public void testInsertElements1() throws Exception {
    final Tuple tuple = new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes());
    storageManager.put(tuple);
    Assert.assertEquals(tuple, storageManager.get("1").get(0));
}
Also used : Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 32 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestStorageRegistry method testCalculateSize.

/**
 * Calculate the size of a distribution group
 * @throws StorageManagerException
 * @throws InterruptedException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testCalculateSize() throws StorageManagerException, InterruptedException, RejectedException {
    storageRegistry.deleteTable(RELATION_NAME, true);
    Assert.assertFalse(storageRegistry.isStorageManagerActive(RELATION_NAME));
    storageRegistry.createTable(RELATION_NAME, new TupleStoreConfiguration());
    final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(RELATION_NAME);
    for (int i = 0; i < 50000; i++) {
        final Tuple createdTuple = new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, Integer.toString(i).getBytes());
        storageManager.put(createdTuple);
    }
    // Wait for requests to settle
    storageManager.flush();
    final List<TupleStoreName> tablesBeforeDelete = storageRegistry.getAllTables();
    System.out.println(tablesBeforeDelete);
    Assert.assertTrue(tablesBeforeDelete.contains(RELATION_NAME));
    final long size1 = TupleStoreUtil.getSizeOfDistributionGroupAndRegionId(storageRegistry, RELATION_NAME.getDistributionGroup(), 2);
    Assert.assertTrue(size1 > 0);
    storageRegistry.deleteTable(RELATION_NAME, true);
    final List<TupleStoreName> tablesAfterDelete = storageRegistry.getAllTables();
    System.out.println(tablesAfterDelete);
    Assert.assertFalse(tablesAfterDelete.contains(RELATION_NAME));
    final long size2 = TupleStoreUtil.getSizeOfDistributionGroupAndRegionId(storageRegistry, RELATION_NAME.getDistributionGroup(), 2);
    Assert.assertTrue(size2 == 0);
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Tuple(org.bboxdb.storage.entity.Tuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 33 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestTableCompactor method testCompactTestFileOneEmptyfile1.

@Test(timeout = 60000)
public void testCompactTestFileOneEmptyfile1() throws StorageManagerException {
    final List<Tuple> tupleList1 = new ArrayList<Tuple>();
    tupleList1.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes()));
    final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
    final List<Tuple> tupleList2 = new ArrayList<Tuple>();
    final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
    final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, false);
    int counter = 0;
    for (@SuppressWarnings("unused") final Tuple tuple : ssTableIndexReader) {
        counter++;
    }
    Assert.assertEquals(tupleList1.size() + tupleList2.size(), counter);
}
Also used : SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 34 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestTableCompactor method testCompactationMajor1.

/**
 * Test a major compactation
 * @throws StorageManagerException
 */
@Test(timeout = 60000)
public void testCompactationMajor1() throws StorageManagerException {
    final List<Tuple> tupleList1 = new ArrayList<Tuple>();
    tupleList1.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes()));
    final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
    final List<Tuple> tupleList2 = new ArrayList<Tuple>();
    tupleList2.add(new DeletedTuple("2"));
    final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
    final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, true);
    boolean containsDeletedTuple = false;
    int counter = 0;
    for (final Tuple tuple : ssTableIndexReader) {
        counter++;
        if (tuple instanceof DeletedTuple) {
            containsDeletedTuple = true;
        }
    }
    Assert.assertEquals(1, counter);
    Assert.assertFalse(containsDeletedTuple);
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 35 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestTableCompactor method testCompactorRunnable.

/**
 * Test the compactor runnable
 * @throws RejectedException
 * @throws StorageManagerException
 * @throws InterruptedException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testCompactorRunnable() throws StorageManagerException, RejectedException, BBoxDBException, InterruptedException {
    storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
    final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
    Assert.assertTrue(storageManager.getServiceState().isInRunningState());
    // Create file 1
    for (int i = 0; i < 1000; i++) {
        storageManager.put(new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, "abc".getBytes()));
    }
    storageManager.flush();
    // Create file 2
    for (int i = 0; i < 1000; i++) {
        storageManager.put(new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, "abc".getBytes()));
    }
    storageManager.flush();
    final List<DiskStorage> storages = storageRegistry.getAllStorages();
    Assert.assertEquals(1, storages.size());
    final SSTableServiceRunnable ssTableCompactorRunnable = new SSTableServiceRunnable(storages.get(0));
    ssTableCompactorRunnable.forceMajorCompact(storageManager);
    // Test exception handler
    final List<ReadOnlyTupleStore> writtenStorages = storageManager.aquireStorage();
    storageManager.releaseStorage(writtenStorages);
    storageManager.shutdown();
    final List<SSTableFacade> tupleStorages = writtenStorages.stream().filter(r -> r instanceof SSTableFacade).map(r -> (SSTableFacade) r).collect(Collectors.toList());
    Assert.assertFalse(tupleStorages.isEmpty());
    ssTableCompactorRunnable.handleCompactException(tupleStorages);
}
Also used : Arrays(java.util.Arrays) SSTableWriter(org.bboxdb.storage.sstable.SSTableWriter) SSTableReader(org.bboxdb.storage.sstable.reader.SSTableReader) BeforeClass(org.junit.BeforeClass) RejectedException(org.bboxdb.commons.RejectedException) Tuple(org.bboxdb.storage.entity.Tuple) SSTableServiceRunnable(org.bboxdb.storage.sstable.compact.SSTableServiceRunnable) SSTableHelper(org.bboxdb.storage.sstable.SSTableHelper) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) ReadOnlyTupleStore(org.bboxdb.storage.tuplestore.ReadOnlyTupleStore) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Lists(com.google.common.collect.Lists) SSTableCompactor(org.bboxdb.storage.sstable.compact.SSTableCompactor) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) BBoxDBConfigurationManager(org.bboxdb.misc.BBoxDBConfigurationManager) DiskStorage(org.bboxdb.storage.tuplestore.DiskStorage) Before(org.junit.Before) AfterClass(org.junit.AfterClass) Iterator(java.util.Iterator) Test(org.junit.Test) Collectors(java.util.stream.Collectors) File(java.io.File) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) List(java.util.List) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Assert(org.junit.Assert) Collections(java.util.Collections) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) SSTableServiceRunnable(org.bboxdb.storage.sstable.compact.SSTableServiceRunnable) ReadOnlyTupleStore(org.bboxdb.storage.tuplestore.ReadOnlyTupleStore) DiskStorage(org.bboxdb.storage.tuplestore.DiskStorage) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Aggregations

Tuple (org.bboxdb.storage.entity.Tuple)198 Test (org.junit.Test)123 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)104 BoundingBox (org.bboxdb.commons.math.BoundingBox)62 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)58 ArrayList (java.util.ArrayList)41 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)25 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)24 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)18 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)18 ByteBuffer (java.nio.ByteBuffer)17 BBoxDBException (org.bboxdb.misc.BBoxDBException)16 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)15 SSTableKeyIndexReader (org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader)13 IOException (java.io.IOException)11 List (java.util.List)11 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)11 InsertTupleRequest (org.bboxdb.network.packages.request.InsertTupleRequest)11 StorageManagerException (org.bboxdb.storage.StorageManagerException)11 TupleBuilder (org.bboxdb.tools.converter.tuple.TupleBuilder)11