Skip to content

Commit

Permalink
Merge pull request #187 from malin1993ml/master
Browse files Browse the repository at this point in the history
Fix multimap
  • Loading branch information
apavlo committed Mar 1, 2015
2 parents 4ac8b28 + 2724866 commit c158a6b
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 105 deletions.
6 changes: 3 additions & 3 deletions src/ee/anticache/AntiCacheEvictionManager.cpp
Expand Up @@ -637,7 +637,7 @@ bool AntiCacheEvictionManager::evictBlockToDisk(PersistentTable *table, const lo
const void* evicted_tuple_address = static_cast<EvictedTable*>(evictedTable)->insertEvictedTuple(evicted_tuple);
VOLT_TRACE("block address is %p", evicted_tuple_address);
// Change all of the indexes to point to our new evicted tuple
table->setEntryToNewAddressForAllIndexes(&tuple, evicted_tuple_address);
table->setEntryToNewAddressForAllIndexes(&tuple, evicted_tuple_address, tuple.address());

block.addTuple(tuple);

Expand Down Expand Up @@ -921,7 +921,7 @@ bool AntiCacheEvictionManager::evictBlockToDiskInBatch(PersistentTable *table, P
const void* evicted_tuple_address = static_cast<EvictedTable*>(evictedTable)->insertEvictedTuple(evicted_tuple);

// Change all of the indexes to point to our new evicted tuple
table->setEntryToNewAddressForAllIndexes(&tuple, evicted_tuple_address);
table->setEntryToNewAddressForAllIndexes(&tuple, evicted_tuple_address, tuple.address());

block.addTuple(tuple);

Expand Down Expand Up @@ -965,7 +965,7 @@ bool AntiCacheEvictionManager::evictBlockToDiskInBatch(PersistentTable *table, P
const void* evicted_tuple_address = static_cast<EvictedTable*>(child_evictedTable)->insertEvictedTuple(child_evicted_tuple);

// Change all of the indexes to point to our new evicted tuple
childTable->setEntryToNewAddressForAllIndexes(&childTuple, evicted_tuple_address);
childTable->setEntryToNewAddressForAllIndexes(&childTuple, evicted_tuple_address, childTuple.address());

//VOLT_INFO("tuple foreign key id %d", ValuePeeker::peekAsInteger(childTuple.getNValue(foreignKeyIndexColumn)));
VOLT_INFO("EvictedTuple: %s", childTuple.debug(childTable->name()).c_str());
Expand Down
6 changes: 3 additions & 3 deletions src/ee/indexes/BinaryTreeMultiMapIndex.h
Expand Up @@ -116,7 +116,7 @@ class BinaryTreeMultiMapIndex : public TableIndex
return (deleted && inserted);
}

bool setEntryToNewAddress(const TableTuple *tuple, const void* address) {
bool setEntryToNewAddress(const TableTuple *tuple, const void* address, const void *oldAddress) {
m_tmp1.setFromTuple(tuple, column_indices_, m_keySchema);
++m_updates;

Expand All @@ -128,15 +128,15 @@ class BinaryTreeMultiMapIndex : public TableIndex
{
// VOLT_INFO("iteration %d", i++);

// if (key_iter.first->second == tuple->address()) {
if (key_iter.first->second == oldAddress) {
m_entries->erase(key_iter.first);

//std::pair<typename MapType::iterator, bool> retval = m_entries->insert(std::pair<KeyType, const void*>(m_tmp1, address));
//return retval.second;

m_entries->insert(std::pair<KeyType, const void*>(m_tmp1, address));
return true;
// }
}
}

VOLT_INFO("Tuple not found.");
Expand Down
2 changes: 1 addition & 1 deletion src/ee/indexes/BinaryTreeUniqueIndex.h
Expand Up @@ -109,7 +109,7 @@ class BinaryTreeUniqueIndex : public TableIndex
return (deleted && inserted);
}

bool setEntryToNewAddress(const TableTuple *tuple, const void* address) {
bool setEntryToNewAddress(const TableTuple *tuple, const void* address, const void *oldAddress) {
// set the key from the tuple
m_tmp1.setFromTuple(tuple, column_indices_, m_keySchema);
++m_updates;
Expand Down
15 changes: 8 additions & 7 deletions src/ee/indexes/HashTableMultiMapIndex.h
Expand Up @@ -102,7 +102,7 @@ class HashTableMultiMapIndex : public TableIndex {
return (deleted && inserted);
}

bool setEntryToNewAddress(const TableTuple *tuple, const void* address) {
bool setEntryToNewAddress(const TableTuple *tuple, const void* address, const void *oldAddress) {
m_tmp1.setFromTuple(tuple, column_indices_, m_keySchema);
++m_updates;

Expand All @@ -114,12 +114,13 @@ class HashTableMultiMapIndex : public TableIndex {

// VOLT_INFO("iteration %d", i++);

// if (key_iter.first->second == tuple->address()) {
// XXX key_iter.first->second = address;
m_entries->erase(key_iter.first);
m_entries->insert(std::pair<KeyType, const void*>(m_tmp1, address));
return true;
// }
if (key_iter.first->second == oldAddress) {
// XXX key_iter.first->second = address;
m_entries->erase(key_iter.first);
m_entries->insert(std::pair<KeyType, const void*>(m_tmp1, address));
return true;
}

}

VOLT_INFO("Tuple not found.");
Expand Down
2 changes: 1 addition & 1 deletion src/ee/indexes/HashTableUniqueIndex.h
Expand Up @@ -99,7 +99,7 @@ class HashTableUniqueIndex : public TableIndex {
return (deleted && inserted);
}

bool setEntryToNewAddress(const TableTuple *tuple, const void* address) {
bool setEntryToNewAddress(const TableTuple *tuple, const void* address, const void *oldAddress) {
// set the key from the tuple
m_tmp1.setFromTuple(tuple, column_indices_, m_keySchema);
++m_updates;
Expand Down
2 changes: 1 addition & 1 deletion src/ee/indexes/arrayuniqueindex.cpp
Expand Up @@ -83,7 +83,7 @@ bool ArrayUniqueIndex::replaceEntry(const TableTuple *oldTupleValue, const Table
return true;
}

bool ArrayUniqueIndex::setEntryToNewAddress(const TableTuple *tuple, const void* address)
bool ArrayUniqueIndex::setEntryToNewAddress(const TableTuple *tuple, const void* address, const void* oldAddress)
{
int32_t key = ValuePeeker::peekAsInteger(tuple->getNValue(column_indices_[0]));

Expand Down
2 changes: 1 addition & 1 deletion src/ee/indexes/arrayuniqueindex.h
Expand Up @@ -47,7 +47,7 @@ class ArrayUniqueIndex : public TableIndex {
bool addEntry(const TableTuple *tuples);
bool deleteEntry(const TableTuple *tuple);
bool replaceEntry(const TableTuple *oldTupleValue, const TableTuple* newTupleValue);
bool setEntryToNewAddress(const TableTuple *tuple, const void* address);
bool setEntryToNewAddress(const TableTuple *tuple, const void* address, const void* oldAddress);
bool exists(const TableTuple* values);
bool moveToKey(const TableTuple *searchKey);
bool moveToTuple(const TableTuple *searchTuple);
Expand Down
2 changes: 1 addition & 1 deletion src/ee/indexes/tableindex.h
Expand Up @@ -146,7 +146,7 @@ class TableIndex
virtual bool replaceEntry(const TableTuple *oldTupleValue,
const TableTuple *newTupleValue) = 0;

virtual bool setEntryToNewAddress(const TableTuple *tuple, const void* address) = 0;
virtual bool setEntryToNewAddress(const TableTuple *tuple, const void* address, const void* oldAddress) = 0;


/**
Expand Down
6 changes: 3 additions & 3 deletions src/ee/storage/persistenttable.cpp
Expand Up @@ -409,7 +409,7 @@ int64_t PersistentTable::unevictTuple(ReferenceSerializeInput * in, int j, int m
m_tmpTarget1.setDeletedFalse();
// update the indexes to point to this newly unevicted tuple
VOLT_DEBUG("BEFORE: tuple.isEvicted() = %d", m_tmpTarget1.isEvicted());
setEntryToNewAddressForAllIndexes(&m_tmpTarget1, m_tmpTarget1.address());
setEntryToNewAddressForAllIndexes(&m_tmpTarget1, m_tmpTarget1.address(), m_tmpTarget2.address());
updateStringMemory((int)m_tmpTarget1.getNonInlinedMemorySize());

//deleteFromAllIndexes(&m_tmpTarget1);
Expand Down Expand Up @@ -918,12 +918,12 @@ void PersistentTable::updateFromAllIndexes(TableTuple &targetTuple, const TableT
}
}

void PersistentTable::setEntryToNewAddressForAllIndexes(const TableTuple *tuple, const void* address) {
void PersistentTable::setEntryToNewAddressForAllIndexes(const TableTuple *tuple, const void* address, const void* oldAddress) {
for (int i = m_indexCount - 1; i >= 0; --i) {
VOLT_TRACE("Updating tuple address in index %s.%s [%s]",
name().c_str(), m_indexes[i]->getName().c_str(), m_indexes[i]->getTypeName().c_str());
VOLT_TRACE("address is %p", address);
if (!m_indexes[i]->setEntryToNewAddress(tuple, address)) {
if (!m_indexes[i]->setEntryToNewAddress(tuple, address, oldAddress)) {
VOLT_ERROR("ERROR: Failed to update tuple to new address!");
throwFatalException("Failed to update tuple to new address in index %s.%s [%s]",
name().c_str(), m_indexes[i]->getName().c_str(),
Expand Down
2 changes: 1 addition & 1 deletion src/ee/storage/persistenttable.h
Expand Up @@ -315,7 +315,7 @@ void clearUnevictedBlocks(int i);

void updateStringMemory(int tupleStringMemorySize);

void setEntryToNewAddressForAllIndexes(const TableTuple *tuple, const void* address);
void setEntryToNewAddressForAllIndexes(const TableTuple *tuple, const void* address, const void* oldAddress);

protected:
virtual void allocateNextBlock();
Expand Down

0 comments on commit c158a6b

Please sign in to comment.