mirror of https://gitee.com/bigwinds/arangodb
handle OOM
This commit is contained in:
parent
a35de51042
commit
40b7f372f9
|
@ -774,9 +774,29 @@ TRI_index_t* TRI_CreateEdgeIndex (struct TRI_primary_collection_s* primary) {
|
|||
TRI_edge_index_t* edgeIndex;
|
||||
TRI_index_t* idx;
|
||||
char* id;
|
||||
int res;
|
||||
|
||||
// create index
|
||||
edgeIndex = TRI_Allocate(TRI_CORE_MEM_ZONE, sizeof(TRI_edge_index_t), false);
|
||||
|
||||
if (edgeIndex == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = TRI_InitMultiPointer(&edgeIndex->_edges,
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
HashElementEdge,
|
||||
HashElementEdge,
|
||||
IsEqualKeyEdge,
|
||||
IsEqualElementEdge);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, edgeIndex);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
idx = &edgeIndex->base;
|
||||
|
||||
TRI_InitVectorString(&idx->_fields, TRI_CORE_MEM_ZONE);
|
||||
|
@ -790,13 +810,6 @@ TRI_index_t* TRI_CreateEdgeIndex (struct TRI_primary_collection_s* primary) {
|
|||
idx->insert = InsertEdge;
|
||||
idx->remove = RemoveEdge;
|
||||
|
||||
TRI_InitMultiPointer(&edgeIndex->_edges,
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
HashElementEdge,
|
||||
HashElementEdge,
|
||||
IsEqualKeyEdge,
|
||||
IsEqualElementEdge);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
|
|
@ -559,6 +559,8 @@ static TRI_voc_size_t Count (TRI_primary_collection_t* primary) {
|
|||
|
||||
int TRI_InitPrimaryCollection (TRI_primary_collection_t* primary,
|
||||
TRI_shaper_t* shaper) {
|
||||
int res;
|
||||
|
||||
primary->_shaper = shaper;
|
||||
primary->_capConstraint = NULL;
|
||||
primary->_keyGenerator = NULL;
|
||||
|
@ -568,22 +570,32 @@ int TRI_InitPrimaryCollection (TRI_primary_collection_t* primary,
|
|||
primary->size = Count;
|
||||
|
||||
|
||||
res = TRI_InitAssociativePointer(&primary->_datafileInfo,
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
HashKeyDatafile,
|
||||
HashElementDatafile,
|
||||
IsEqualKeyElementDatafile,
|
||||
NULL);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = TRI_InitAssociativePointer(&primary->_primaryIndex,
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
HashKeyHeader,
|
||||
HashElementDocument,
|
||||
IsEqualKeyDocument,
|
||||
NULL);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_DestroyAssociativePointer(&primary->_datafileInfo);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
TRI_InitBarrierList(&primary->_barrierList, primary);
|
||||
|
||||
TRI_InitAssociativePointer(&primary->_datafileInfo,
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
HashKeyDatafile,
|
||||
HashElementDatafile,
|
||||
IsEqualKeyElementDatafile,
|
||||
NULL);
|
||||
|
||||
TRI_InitAssociativePointer(&primary->_primaryIndex,
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
HashKeyHeader,
|
||||
HashElementDocument,
|
||||
IsEqualKeyDocument,
|
||||
NULL);
|
||||
|
||||
TRI_InitReadWriteLock(&primary->_lock);
|
||||
TRI_InitReadWriteLock(&primary->_compactionLock);
|
||||
|
||||
|
@ -603,6 +615,7 @@ void TRI_DestroyPrimaryCollection (TRI_primary_collection_t* primary) {
|
|||
|
||||
TRI_DestroyReadWriteLock(&primary->_compactionLock);
|
||||
TRI_DestroyReadWriteLock(&primary->_lock);
|
||||
|
||||
TRI_DestroyAssociativePointer(&primary->_primaryIndex);
|
||||
|
||||
if (primary->_shaper != NULL) {
|
||||
|
|
Loading…
Reference in New Issue