1
0
Fork 0

preparation for skiplists supporting transactions

This commit is contained in:
Oreste Panaia 2013-03-15 18:12:20 +08:00
parent 16aef17808
commit 36733eb19f
13 changed files with 5991 additions and 3 deletions

View File

@ -69,6 +69,8 @@ bin_arangod_SOURCES = \
arangod/RestServer/arango.cpp \
arangod/SkipLists/skiplist.c \
arangod/SkipLists/skiplistIndex.c \
arangod/SkipListsEx/skiplistEx.c \
arangod/SkipListsEx/skiplistExIndex.c \
arangod/V8Server/ApplicationV8.cpp \
arangod/V8Server/v8-actions.cpp \
arangod/V8Server/v8-query.cpp \

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,557 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief skip list which suports transactions implementation
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. O
/// @author Copyright 2006-2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_BASICS_C_SKIPLIST_EX_H
#define TRIAGENS_BASICS_C_SKIPLIST_EX_H 1
#include "BasicsC/common.h"
#include "BasicsC/locks.h"
#include "BasicsC/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
// -----------------------------------------------------------------------------
// --SECTION-- skiplistEx public types
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup SkiplistEx
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief types which enumerate the probability used to determine the height of node
////////////////////////////////////////////////////////////////////////////////
typedef enum {
TRI_SKIPLIST_EX_PROB_HALF,
TRI_SKIPLIST_EX_PROB_THIRD,
TRI_SKIPLIST_EX_PROB_QUARTER
}
TRI_skiplistEx_prob_e;
typedef enum {
TRI_SKIPLIST_EX_COMPARE_STRICTLY_LESS = -1,
TRI_SKIPLIST_EX_COMPARE_STRICTLY_GREATER = 1,
TRI_SKIPLIST_EX_COMPARE_STRICTLY_EQUAL = 0,
TRI_SKIPLIST_EX_COMPARE_SLIGHTLY_LESS = -2,
TRI_SKIPLIST_EX_COMPARE_SLIGHTLY_GREATER = 2
}
TRI_skiplistEx_compare_e;
////////////////////////////////////////////////////////////////////////////////
/// @brief storage structure for a node's nearest neighbours
////////////////////////////////////////////////////////////////////////////////
// .............................................................................
// The nearest neighbour node needs to be modified for handling transactions.
// We introduce a structure for the forward and back links.
// To implement 'lock free', we require an atomic Compare & Save (C&S) function
// to use this correctly on Mac/Windows we need to align pointer/integers
// on 32 or 64 bit boundaries.
// .............................................................................
typedef struct TRI_skiplistEx_nb_s {
void* _prev; // points to the previous nearest neighbour of this node (the left node)
void* _next; // points to the successor of this node (right node)
uint64_t _flag; // the _flag field operates as follows:
// if (_flag & 1) == 1, then the Tower Node (the node which uses this structure) is a Glass Tower Node.
//
} TRI_skiplistEx_nb_t; // nearest neighbour;
////////////////////////////////////////////////////////////////////////////////
/// @brief structure of a skip list node (unique and non-unique)
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_skiplistEx_node_s {
TRI_skiplistEx_nb_t* _column; // these represent the levels and the links within these, an array of these
uint32_t _colLength; // the height of the column
void* _extraData;
void* _element;
uint64_t _delTransID; // the transaction id which removed (deleted) this node
uint64_t _insTransID; // the transaction id which inserted this node
}
TRI_skiplistEx_node_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief The base structure of a skiplist (unique and non-unique)
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_skiplistEx_base_s {
// ...........................................................................
// The maximum height of this skip list. Thus 2^(_maxHeight) elements can be
// stored in the skip list.
// ...........................................................................
uint32_t _maxHeight;
// ...........................................................................
// The size of each element which is to be stored.
// ...........................................................................
uint32_t _elementSize;
// ...........................................................................
// The actual list itself
// ...........................................................................
char* _skiplist;
// ...........................................................................
// The probability which is used to determine the level for insertions
// into the list. Note the following
// ...........................................................................
TRI_skiplistEx_prob_e _prob;
int32_t _numRandom;
uint32_t* _random;
TRI_skiplistEx_node_t _startNode;
TRI_skiplistEx_node_t _endNode;
}
TRI_skiplistEx_base_t;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- unique skiplistEx public types
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup SkiplistEx_unique
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief structure used for a skip list which only accepts unique entries
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_skiplistEx_s {
TRI_skiplistEx_base_t _base;
// ...........................................................................
// callback compare function
// < 0: implies left < right
// == 0: implies left == right
// > 0: implies left > right
// ...........................................................................
int (*compareElementElement) (struct TRI_skiplistEx_s*, void*, void*, int);
int (*compareKeyElement) (struct TRI_skiplistEx_s*, void*, void*, int);
}
TRI_skiplistEx_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief structure used for a skip list which only accepts unique entries and is thread safe
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// structure for a skiplist which allows unique entries -- with locking
// available for its nearest neighbours.
// TODO: implement locking for nearest neighbours rather than for all of index
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_skiplistEx_synced_s {
TRI_skiplistEx_t _base;
TRI_read_write_lock_t _lock;
} TRI_skiplistEx_synced_t;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- unique skiplist constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Skiplist_unique
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief initialises a skip list
////////////////////////////////////////////////////////////////////////////////
int TRI_InitSkipListEx (TRI_skiplistEx_t*,
size_t elementSize,
int (*compareElementElement) (TRI_skiplistEx_t*, void*, void*, int),
int (*compareKeyElement) (TRI_skiplistEx_t*, void*, void*, int),
TRI_skiplistEx_prob_e,
uint32_t,
uint64_t lastKnownTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys a skip list, but does not free the pointer
////////////////////////////////////////////////////////////////////////////////
void TRI_DestroySkipListEx (TRI_skiplistEx_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys a skip list and frees the pointer
////////////////////////////////////////////////////////////////////////////////
void TRI_FreeSkipListEx (TRI_skiplistEx_t*);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- unique skiplist public functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Skiplist_unique
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the end node which belongs to a skiplist
////////////////////////////////////////////////////////////////////////////////
void* TRI_EndNodeSkipListEx (TRI_skiplistEx_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief adds an element to the skip list using element for comparison
////////////////////////////////////////////////////////////////////////////////
int TRI_InsertElementSkipListEx (TRI_skiplistEx_t*, void*, bool, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief adds an element to the skip list using key for comparison
////////////////////////////////////////////////////////////////////////////////
int TRI_InsertKeySkipListEx (TRI_skiplistEx_t*, void*, void*, bool, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief lookups an element given a key, returns greatest left element
////////////////////////////////////////////////////////////////////////////////
void* TRI_LeftLookupByKeySkipListEx (TRI_skiplistEx_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief lookups an element given a key, returns null if not found
////////////////////////////////////////////////////////////////////////////////
void* TRI_LookupByKeySkipListEx (TRI_skiplistEx_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief given a node returns the next node in the skip list, if the end is reached returns the end node
////////////////////////////////////////////////////////////////////////////////
void* TRI_NextNodeSkipListEx (TRI_skiplistEx_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief given a node returns the prev node in the skip list, if the beginning is reached returns the start node
////////////////////////////////////////////////////////////////////////////////
void* TRI_PrevNodeSkipListEx (TRI_skiplistEx_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief removes an element from the skip list using element for comparison
////////////////////////////////////////////////////////////////////////////////
int TRI_RemoveElementSkipListEx (TRI_skiplistEx_t*, void*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief removes an element from the skip list using key for comparison
////////////////////////////////////////////////////////////////////////////////
int TRI_RemoveKeySkipListEx (TRI_skiplistEx_t*, void*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief lookups an element given a key, returns least right element
////////////////////////////////////////////////////////////////////////////////
void* TRI_RightLookupByKeySkipListEx (TRI_skiplistEx_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the start node which belongs to a skiplist
////////////////////////////////////////////////////////////////////////////////
void* TRI_StartNodeSkipListEx (TRI_skiplistEx_t*);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- non-unique skiplist public types
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief structure used for a multi skiplist
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Skiplist_non_unique
/// @{
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_skiplistEx_multi_s {
TRI_skiplistEx_base_t _base;
// ...........................................................................
// callback compare function
// < 0: implies left < right
// == 0: implies left == right
// > 0: implies left > right
// ...........................................................................
int (*compareElementElement) (struct TRI_skiplistEx_multi_s*, void*, void*, int);
int (*compareKeyElement) (struct TRI_skiplistEx_multi_s*, void*, void*, int);
// ...........................................................................
// Returns true if the element is an exact copy, or if the data which the
// element points to is an exact copy
// ...........................................................................
bool (*equalElementElement) (struct TRI_skiplistEx_multi_s*, void*, void*);
} TRI_skiplistEx_multi_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief structure used for a multi skip list and is thread safe
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_skiplistEx_synced_multi_s {
TRI_skiplistEx_t _base;
TRI_read_write_lock_t _lock;
} TRI_skiplistEx_synced_multi_t;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- non-unique skiplist constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Skiplist_non_unique
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief initialises a skip list
////////////////////////////////////////////////////////////////////////////////
int TRI_InitSkipListExMulti (TRI_skiplistEx_multi_t*,
size_t elementSize,
int (*compareElementElement) (TRI_skiplistEx_multi_t*, void*, void*, int),
int (*compareKeyElement) (TRI_skiplistEx_multi_t*, void*, void*, int),
bool (*equalElementElement) (TRI_skiplistEx_multi_t*, void*, void*),
TRI_skiplistEx_prob_e,
uint32_t,
uint64_t lastKnownTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys a multi skip list, but does not free the pointer
////////////////////////////////////////////////////////////////////////////////
void TRI_DestroySkipListExMulti (TRI_skiplistEx_multi_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys a skip list and frees the pointer
////////////////////////////////////////////////////////////////////////////////
void TRI_FreeSkipListExMulti (TRI_skiplistEx_multi_t*);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- non-unique skiplistEx public functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup SkiplistEx_non_unique
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the end node which belongs to a skiplist
////////////////////////////////////////////////////////////////////////////////
void* TRI_EndNodeSkipListExMulti (TRI_skiplistEx_multi_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief adds an element to the skip list using element for comparison
////////////////////////////////////////////////////////////////////////////////
int TRI_InsertElementSkipListExMulti (TRI_skiplistEx_multi_t*, void*, bool, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief adds an element to the skip list using key for comparison
////////////////////////////////////////////////////////////////////////////////
int TRI_InsertKeySkipListExMulti (TRI_skiplistEx_multi_t*, void*, void*, bool, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief lookups an element given a key, returns greatest left element
////////////////////////////////////////////////////////////////////////////////
void* TRI_LeftLookupByKeySkipListExMulti (TRI_skiplistEx_multi_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief lookups an element given a key, returns null if not found
////////////////////////////////////////////////////////////////////////////////
void* TRI_LookupByKeySkipListExMulti (TRI_skiplistEx_multi_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief given a node returns the next node in the skip list, if the end is reached returns the end node
////////////////////////////////////////////////////////////////////////////////
void* TRI_NextNodeSkipListExMulti (TRI_skiplistEx_multi_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief given a node returns the prev node in the skip list, if the beginning is reached returns the start node
////////////////////////////////////////////////////////////////////////////////
void* TRI_PrevNodeSkipListExMulti (TRI_skiplistEx_multi_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief removes an element from the skip list using element for comparison
////////////////////////////////////////////////////////////////////////////////
int TRI_RemoveElementSkipListExMulti (TRI_skiplistEx_multi_t*, void*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief removes an element from the skip list using key for comparison
////////////////////////////////////////////////////////////////////////////////
int TRI_RemoveKeySkipListExMulti (TRI_skiplistEx_multi_t*, void*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief lookups an element given a key, returns least right element
////////////////////////////////////////////////////////////////////////////////
void* TRI_RightLookupByKeySkipListExMulti (TRI_skiplistEx_multi_t*, void*, uint64_t thisTransID);
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the start node which belongs to a skiplist
////////////////////////////////////////////////////////////////////////////////
void* TRI_StartNodeSkipListExMulti (TRI_skiplistEx_multi_t*);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
// End:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,208 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief unique and non-unique skip lists which support transactions
///
/// @file
///
/// DISCLAIMER
///
/// Copyright by triAGENS GmbH - All rights reserved.
///
/// The Programs (which include both the software and documentation)
/// contain proprietary information of triAGENS GmbH; they are
/// provided under a license agreement containing restrictions on use and
/// disclosure and are also protected by copyright, patent and other
/// intellectual and industrial property laws. Reverse engineering,
/// disassembly or decompilation of the Programs, except to the extent
/// required to obtain interoperability with other independently created
/// software or as specified by law, is prohibited.
///
/// The Programs are not intended for use in any nuclear, aviation, mass
/// transit, medical, or other inherently dangerous applications. It shall
/// be the licensee's responsibility to take all appropriate fail-safe,
/// backup, redundancy, and other measures to ensure the safe use of such
/// applications if the Programs are used for such purposes, and triAGENS
/// GmbH disclaims liability for any damages caused by such use of
/// the Programs.
///
/// This software is the confidential and proprietary information of
/// triAGENS GmbH. You shall not disclose such confidential and
/// proprietary information and shall use it only in accordance with the
/// terms of the license agreement you entered into with triAGENS GmbH.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. O
/// @author Copyright 2011, triagens GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_DURHAM_VOC_BASE_SKIPLIST_EX_INDEX_H
#define TRIAGENS_DURHAM_VOC_BASE_SKIPLIST_EX_INDEX_H 1
#include <BasicsC/common.h>
#include "SkipListsEx/skiplistEx.h"
#include "IndexIterators/index-iterator.h"
#include "IndexOperators/index-operator.h"
#include "ShapedJson/shaped-json.h"
#include "VocBase/transaction.h"
#ifdef __cplusplus
extern "C" {
#endif
// -----------------------------------------------------------------------------
// --SECTION-- skiplistExIndex public types
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup skiplistExIndex
/// @{
////////////////////////////////////////////////////////////////////////////////
typedef struct {
union {
TRI_skiplistEx_t* uniqueSkiplistEx;
TRI_skiplistEx_multi_t* nonUniqueSkiplistEx;
} _skiplistEx;
bool _unique;
TRI_transaction_context_t* _transactionContext;
} SkiplistExIndex;
typedef struct {
size_t numFields; // the number of fields
TRI_shaped_json_t* fields; // list of shaped json objects which the collection should know about
void* data; // master document pointer
void* collection; // pointer to the collection;
} SkiplistExIndexElement;
typedef struct {
size_t _numElements;
SkiplistExIndexElement* _elements; // simple list of elements
} SkiplistExIndexElements;
////////////////////////////////////////////////////////////////////////////////
/// @brief Iterator structure for skip list. We require a start and stop node
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_skiplistEx_iterator_interval_s {
void* _leftEndPoint;
void* _rightEndPoint;
} TRI_skiplistEx_iterator_interval_t;
// ............................................................................
// The iterator essentially is reading a sequence of documents (which are
// stored in a corresponding sequence of nodes), we require the transaction
// number to which this iterator belongs to, this will ensure that any
// modifications made after this transaction are not 'iterated over'
// ............................................................................
typedef struct TRI_skiplistEx_iterator_s {
SkiplistExIndex* _index;
TRI_vector_t _intervals;
size_t _currentInterval; // starts with 0
void* _cursor; // initially null
uint64_t _thisTransID; // the transaction id to which this iterator belongs to
bool (*_hasNext) (struct TRI_skiplistEx_iterator_s*);
void* (*_next) (struct TRI_skiplistEx_iterator_s*);
void* (*_nexts) (struct TRI_skiplistEx_iterator_s*, int64_t jumpSize);
bool (*_hasPrev) (struct TRI_skiplistEx_iterator_s*);
void* (*_prev) (struct TRI_skiplistEx_iterator_s*);
void* (*_prevs) (struct TRI_skiplistEx_iterator_s*, int64_t jumpSize);
} TRI_skiplistEx_iterator_t;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- skiplistExIndex public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup skiplistExIndex
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief Free a skiplistEx iterator
////////////////////////////////////////////////////////////////////////////////
void TRI_FreeSkiplistExIterator (TRI_skiplistEx_iterator_t* const);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys a skip list index , but does not free the pointer
////////////////////////////////////////////////////////////////////////////////
void SkiplistExIndex_destroy (SkiplistExIndex*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys a skip list index and frees the pointer
////////////////////////////////////////////////////////////////////////////////
void SkiplistExIndex_free (SkiplistExIndex*);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
int SkiplistExIndex_assignMethod (void*, TRI_index_method_assignment_type_e);
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Unique skiplist indexes
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SkiplistExIndex* SkiplistExIndex_new (TRI_transaction_context_t*);
int SkiplistExIndex_add (SkiplistExIndex*, SkiplistExIndexElement*, uint64_t);
TRI_skiplistEx_iterator_t* SkiplistExIndex_find (SkiplistExIndex*, TRI_vector_t*, TRI_index_operator_t*, uint64_t);
int SkiplistExIndex_insert (SkiplistExIndex*, SkiplistExIndexElement*, uint64_t);
int SkiplistExIndex_remove (SkiplistExIndex*, SkiplistExIndexElement*, uint64_t);
bool SkiplistExIndex_update (SkiplistExIndex*, const SkiplistExIndexElement*, const SkiplistExIndexElement*, uint64_t);
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Multi-skiplist non-unique skiplist indexes
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SkiplistExIndex* MultiSkiplistExIndex_new (TRI_transaction_context_t*);
int MultiSkiplistExIndex_add (SkiplistExIndex*, SkiplistExIndexElement*, uint64_t);
TRI_skiplistEx_iterator_t* MultiSkiplistExIndex_find (SkiplistExIndex*, TRI_vector_t*, TRI_index_operator_t*, uint64_t);
int MultiSkiplistExIndex_insert (SkiplistExIndex*, SkiplistExIndexElement*, uint64_t);
int MultiSkiplistExIndex_remove (SkiplistExIndex*, SkiplistExIndexElement*, uint64_t);
bool MultiSkiplistExIndex_update (SkiplistExIndex*, SkiplistExIndexElement*, SkiplistExIndexElement*, uint64_t);
#ifdef __cplusplus
}
#endif
#endif
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
// End:

View File

@ -186,6 +186,9 @@ TRI_transaction_list_t;
typedef struct TRI_transaction_context_s {
TRI_transaction_id_t _id; // last transaction id assigned
TRI_read_write_lock_t _rwLock; // lock used to either simulatensously read this structure,
// or uniquely modify this structure
#if 0
TRI_mutex_t _lock; // lock used to serialize starting/stopping transactions
TRI_mutex_t _collectionLock; // lock used when accessing _collections
@ -193,7 +196,7 @@ typedef struct TRI_transaction_context_s {
TRI_transaction_list_t _writeTransactions; // global list of currently ongoing write transactions
TRI_associative_pointer_t _collections; // list of collections (TRI_transaction_collection_global_t)
#endif
struct TRI_vocbase_s* _vocbase; // pointer to vocbase
struct TRI_vocbase_s* _vocbase; // pointer to vocbase
}
TRI_transaction_context_t;

View File

@ -176,8 +176,8 @@ namespace triagens {
for (size_t i = 1; i < N + 1; ++i) {
T = T + StatisticsNonces[l2age][i];
coeff = coeff * (N - i + 1) / i;
S0 = S0 * pow(StatisticsNonces[l2age][i] / coeff, (4 * N + 2 - 6 * i) / (N * N - N));
x = x * pow(StatisticsNonces[l2age][i] / coeff, (12 * i - 6 * N - 6) / (N * N * N - N));
S0 = S0 * pow((double)(StatisticsNonces[l2age][i] / coeff), (double)((4 * N + 2 - 6 * i) / (N * N - N)));
x = x * pow((double)(StatisticsNonces[l2age][i] / coeff), (double)((12 * i - 6 * N - 6) / (N * N * N - N)));
}
Statistics current;

View File

@ -551,6 +551,60 @@ void TRI_UnlockCondition (TRI_condition_t* cond) {
}
}
// -----------------------------------------------------------------------------
// COMPARE & SWAP operations below for MAC and GNUC
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief atomically compares and swaps 32bit integers
////////////////////////////////////////////////////////////////////////////////
bool TRI_CompareAndSwapInteger32 (volatile long* theValue, int32_t oldValue, int32_t newValue) {
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
return OSAtomicCompareAndSwap32(oldValue, newValue, theValue);
#elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
return __sync_val_compare_and_swap(theValue, oldValue, newValue);
#else
#error No TRI_CompareAndSwapInteger32 implementation defined
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @brief atomically compares and swaps 64bit integers
////////////////////////////////////////////////////////////////////////////////
bool TRI_CompareAndSwapInteger64 (volatile long* theValue, int64_t oldValue, int64_t newValue) {
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
return OSAtomicCompareAndSwap64(oldValue, newValue, theValue);
#elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
return __sync_val_compare_and_swap(theValue, oldValue, newValue);
#else
#error No TRI_CompareAndSwapInteger64 implementation defined
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @brief atomically compares and swaps pointers
////////////////////////////////////////////////////////////////////////////////
bool TRI_CompareAndSwapPointer(void* volatile* theValue, void* oldValue, void* newValue) {
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
return OSAtomicCompareAndSwapPtr(oldValue, newValue, theValue);
#elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
return __sync_val_compare_and_swap(theValue, oldValue, newValue);
#else
#error No TRI_CompareAndSwapPointer implementation defined
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////

View File

@ -899,6 +899,40 @@ void TRI_UnlockCondition (TRI_condition_t* cond) {
}
}
// -----------------------------------------------------------------------------
// COMPARE & SWAP operations below for windows
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief atomically compares and swaps 32bit integers
////////////////////////////////////////////////////////////////////////////////
bool TRI_CompareAndSwapInteger32 (volatile long* theValue, int32_t oldValue, int32_t newValue) {
return ( InterlockedCompareExchange(theValue, newValue, oldValue) == oldValue );
}
////////////////////////////////////////////////////////////////////////////////
/// @brief atomically compares and swaps 64bit integers
////////////////////////////////////////////////////////////////////////////////
bool TRI_CompareAndSwapInteger64 (volatile long* theValue, int64_t oldValue, int64_t newValue) {
return ( InterlockedCompareExchange64(theValue, newValue, oldValue) == oldValue );
}
////////////////////////////////////////////////////////////////////////////////
/// @brief atomically compares and swaps pointers
////////////////////////////////////////////////////////////////////////////////
bool TRI_CompareAndSwapPointer(void* volatile* theValue, void* oldValue, void* newValue) {
return ( InterlcokedCompareExchangEPointer(theValue, newValue, oldValue) == oldValue );
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////

View File

@ -373,6 +373,68 @@ void TRI_UnlockCondition (TRI_condition_t* cond);
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup CAS operations
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief performs an atomic compare and swap operation on a 32bit integer.
////////////////////////////////////////////////////////////////////////////////
// .............................................................................
// The position of 'theValue' must be aligned on a 32 bit boundary. The function
// performs the following atomically: compares the value stored in the position
// pointed to by <theValue> with the value of <oldValue>. if the value stored
// in position <theValue> is EQUAL to the value of <oldValue>, then the
// <newValue> is stored in the position pointed to by <theValue> (true is
// returned), otherwise no operation is performed (false is returned).
// .............................................................................
bool TRI_CompareAndSwapInteger32 (volatile long* theValue, int32_t oldValue, int32_t newValue);
////////////////////////////////////////////////////////////////////////////////
/// @brief performs an atomic compare and swap operation on a 64bit integer.
////////////////////////////////////////////////////////////////////////////////
// .............................................................................
// The position of 'theValue' must be aligned on a 64 bit boundary. This function is
// simply the 64bit equivalent of the function above.
// .............................................................................
bool TRI_CompareAndSwapInteger64 (volatile long* theValue, int64_t oldValue, int64_t newValue);
////////////////////////////////////////////////////////////////////////////////
/// @brief performs an atomic compare and swap operation on a pointer.
////////////////////////////////////////////////////////////////////////////////
// .............................................................................
// On a 32bit machine, the position of 'theValue' must be aligned on a 32 bit
// boundary. On a 64bit machine the alignment must be on a 64bit boundary.
// The function performs the following atomically: compares the value stored in
// the position pointed to by <theValue> with the value of <oldValue>. if the
// value stored in position <theValue> is EQUAL to the value of <oldValue>,
// then the <newValue> is stored in the position pointed to by <theValue>
// (true is returned), otherwise no operation is performed (false is returned).
// .............................................................................
bool TRI_CompareAndSwapPointer(void* volatile* theValue, void* oldValue, void* newValue);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif

View File

@ -126,6 +126,10 @@
#define TRI_HAVE_GETLINE 1
#endif
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
#define TRI_HAVE_GETLINE 1
#endif
#if __WORDSIZE == 64
#define TRI_SIZEOF_SIZE_T 8
#define TRI_ALIGNOF_VOIDP 8

View File

@ -41,6 +41,9 @@ esac
TRI_BITS="$tr_BITS"
AC_SUBST(TRI_BITS)
CFLAGS="${CFLAGS} -DTRI_BITS=${TRI_BITS}"
CXXFLAGS="${CXXFLAGS} -DTRI_BITS=${TRI_BITS}"
dnl ----------------------------------------------------------------------------
dnl use automake to generate Makfile.in
dnl ----------------------------------------------------------------------------