示例#1
0
TRI_general_cursor_t* TRI_CreateGeneralCursor (TRI_general_cursor_result_t* result, 
                                               const bool doCount,
                                               const TRI_general_cursor_length_t batchSize) {
  TRI_general_cursor_t* cursor;

  cursor = (TRI_general_cursor_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_general_cursor_t), false);
  if (!cursor) {
    return NULL;
  }
  
  cursor->_result = result; 
  cursor->_currentRow = 0;
  cursor->_length = result->getLength(result);

  cursor->_hasCount = doCount;
  cursor->_batchSize = batchSize;
  cursor->_deleted = false;
  
  cursor->next = NextGeneralCursor;
  cursor->hasNext = HasNextGeneralCursor;
  cursor->hasCount = HasCountGeneralCursor;
  cursor->getBatchSize = GetBatchSizeGeneralCursor;
  cursor->free = TRI_FreeGeneralCursor;
  
  TRI_InitMutex(&cursor->_lock);
  
  LOG_TRACE("created general cursor");

  return cursor;
}
示例#2
0
TRI_shape_collection_t* TRI_CreateShapeCollection (TRI_vocbase_t* vocbase,
                                                   char const* path,
                                                   TRI_col_info_t* parameter) {
  TRI_shape_collection_t* shape;
  TRI_collection_t* collection;

  shape = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_shape_collection_t), false);

  if (shape == NULL) {
    return NULL;
  }

  parameter->_type = TRI_COL_TYPE_SHAPE;
  parameter->_cid  = TRI_NewTickVocBase();
  parameter->_waitForSync = (vocbase->_forceSyncShapes || parameter->_waitForSync);

  collection = TRI_CreateCollection(vocbase, &shape->base, path, parameter);

  if (collection == NULL) {
    TRI_Free(TRI_UNKNOWN_MEM_ZONE, shape);
    return NULL;
  }

  TRI_InitMutex(&shape->_lock);

  return shape;
}
示例#3
0
TRI_shadow_store_t* TRI_CreateShadowStore (void (*destroy) (void*)) {
  TRI_shadow_store_t* store;

  store = (TRI_shadow_store_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_shadow_store_t), false);

  if (store != NULL) {
    TRI_InitAssociativePointer(&store->_ids,
                               TRI_UNKNOWN_MEM_ZONE,
                               HashKeyId,
                               HashElementId,
                               EqualKeyId,
                               NULL);

    TRI_InitAssociativePointer(&store->_pointers,
                               TRI_UNKNOWN_MEM_ZONE,
                               HashKeyData,
                               HashElementData,
                               EqualKeyData,
                               NULL);

    store->destroyShadow = destroy;

    TRI_InitMutex(&store->_lock);
  }

  return store;
}
示例#4
0
void TRI_InitializeProcess (int argc, char* argv[]) {
  TRI_PhysicalMemory = GetPhysicalMemory();

  if (ProcessName != nullptr) {
    return;
  }

  ProcessName = TRI_DuplicateString(argv[0]);
  ARGC = argc;
  ARGV = argv;

  TRI_InitVectorPointer(&ExternalProcesses, TRI_CORE_MEM_ZONE);
  TRI_InitMutex(&ExternalProcessesLock);
}
示例#5
0
int TRI_InitShaper (TRI_shaper_t* shaper, TRI_memory_zone_t* zone) {
  int res;

  shaper->_memoryZone = zone;

  res = TRI_InitAssociativeSynced(&shaper->_attributePathsByName,
                                  zone,
                                  HashNameKeyAttributePath,
                                  HashNameElementAttributePath,
                                  EqualNameKeyAttributePath,
                                  0);

  if (res != TRI_ERROR_NO_ERROR) {
    return res;
  }

  res = TRI_InitAssociativeSynced(&shaper->_attributePathsByPid,
                                  zone,
                                  HashPidKeyAttributePath,
                                  HashPidElementAttributePath,
                                  EqualPidKeyAttributePath,
                                  0);

  if (res != TRI_ERROR_NO_ERROR) {
    TRI_DestroyAssociativeSynced(&shaper->_attributePathsByName);

    return res;
  }

  TRI_InitMutex(&shaper->_attributePathLock);

  shaper->_nextPid = 1;

  shaper->lookupAttributePathByPid = LookupPidAttributePath;
  shaper->findOrCreateAttributePathByName = FindOrCreateAttributePathByName;
  shaper->lookupAttributePathByName = LookupAttributePathByName;

  return TRI_ERROR_NO_ERROR;
}
示例#6
0
void TRI_InitShaper (TRI_shaper_t* shaper, TRI_memory_zone_t* zone) {
  shaper->_memoryZone = zone;

  TRI_InitAssociativeSynced(&shaper->_attributePathsByName,
                            zone,
                            HashNameKeyAttributePath,
                            HashNameElementAttributePath,
                            EqualNameKeyAttributePath,
                            0);

  TRI_InitAssociativeSynced(&shaper->_attributePathsByPid,
                            zone,
                            HashPidKeyAttributePath,
                            HashPidElementAttributePath,
                            EqualPidKeyAttributePath,
                            0);

  TRI_InitMutex(&shaper->_attributePathLock);

  shaper->_nextPid = 1;

  shaper->lookupAttributePathByPid = LookupPidAttributePath;
  shaper->findAttributePathByName = FindNameAttributePath;
}
示例#7
0
TRI_shape_collection_t* TRI_OpenShapeCollection (TRI_vocbase_t* vocbase,
                                                 char const* path) {
  TRI_shape_collection_t* shape;
  TRI_collection_t* collection;

  assert(path != NULL);

  shape = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_shape_collection_t), false);

  if (shape == NULL) {
    return NULL;
  }

  collection = TRI_OpenCollection(vocbase, &shape->base, path);

  if (collection == NULL) {
    TRI_Free(TRI_UNKNOWN_MEM_ZONE, shape);
    return NULL;
  }

  TRI_InitMutex(&shape->_lock);

  return shape;
}