HOT_FUNC_HPHP
bool ZendArray::addLvalImpl(int64 h, Variant **pDest,
                            bool doFind /* = true */) {
  ASSERT(pDest != NULL);
  Bucket *p;
  if (doFind) {
    p = findForInsert(h);
    if (p) {
      *pDest = &p->data;
      return false;
    }
  }
  p = NEW(Bucket)();
  p->setIntKey(h);
  if (pDest) {
    *pDest = &p->data;
  }
  uint nIndex = (h & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);
  if (h >= m_nNextFreeElement && m_nNextFreeElement >= 0) {
    m_nNextFreeElement = h + 1;
  }
  if (++m_size > tableSize()) {
    resize();
  }
  return true;
}
//------------------------------------------------------------------------------
//  setDataTable() -- for Table
//------------------------------------------------------------------------------
bool Table::setDataTable(const List* const sdtobj)
{
    bool ok = true;
    if (sdtobj != nullptr) {
        // First determine the size of the table -- ALL breakpoint data MUST
        // have been set first (order in input file) to determine the size
        // of the data table
        unsigned int ts = tableSize();
        if (ts > 0) {
            // Allocate table space and load the table
            LCreal* p = new LCreal[ts];
            ok = loadData(*sdtobj, p);
            if (ok) {
                // Loading completed, so
                // free up any old data and set to the new.
                if (dtable != nullptr) delete[] dtable;
                dtable = p;
                nd = ts;
            }
            else {
                // Something was wrong!
                delete[] p;
                std::cerr << "Table::setDataTable: Something is wrong!  Data table aborted." << std::endl;
                ok = false;
            }
        } valid = isValid();
    }
    return ok;
}
Exemple #3
0
unsigned int ofxLua::tableSize(const string& tableName) {
	unsigned int size = 0;
	pushTable(tableName);
	size = tableSize();
	popTable();
	return size;
}
void ZendArray::rehash() {
  memset(m_arBuckets, 0, tableSize() * sizeof(Bucket*));
  for (Bucket *p = m_pListHead; p; p = p->pListNext) {
    uint nIndex = (p->hashKey() & m_nTableMask);
    CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
    SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  }
}
HOT_FUNC_HPHP
void ZendArray::resize() {
  uint newSize = tableSize() << 1;
  // No need to use calloc() or memset(), as rehash() is going to clear
  // m_arBuckets any way.
  if (m_arBuckets == m_inlineBuckets) {
    m_arBuckets = (Bucket**)malloc(newSize * sizeof(Bucket*));
  } else {
    m_arBuckets = (Bucket **)realloc(m_arBuckets, newSize * sizeof(Bucket*));
  }
  m_nTableMask = newSize - 1;
  rehash();
}
Exemple #6
0
static void link_enums(void)
{
    int i;

    for (i=0; i < tableSize(all_enums); ++i)
    {
        int j;
        enum_index_st * t = all_enums[i];
        for (j=0; t[j].n != -1; ++j)
        {
            if (!t[j].e)
            {
                enum_index_st * e =
                    bsearch(t + j,
                            all_enum, tableSize(all_enum), sizeof(*all_enum),
                            cmp_key);
                assert(e != NULL);
                t[j].e = e->e;
            }
        }
    }
}
Exemple #7
0
static const char * gl_lookup_enum_by_nr(
    int nr, enum_index_st * table, size_t size)
{
    enum_index_st e, *f;

    e.n = nr;
    e.e = NULL;

    if (!(f = bsearch(&e, table, size, sizeof(*table), cmp_key)))
        f = bsearch(&e, all_enums, tableSize(all_enums), sizeof(*all_enums),
                    cmp_key);

    return f ? f->e : NULL;
}
bool ZendArray::nextInsertWithRef(CVarRef data) {
  int64 h = m_nNextFreeElement;
  Bucket * p = NEW(Bucket)(withRefBind(data));
  p->setIntKey(h);
  uint nIndex = (h & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);
  m_nNextFreeElement = h + 1;
  if (++m_size > tableSize()) {
    resize();
  }
  return true;
}
Exemple #9
0
void testJoining(struct htmlPage *rootPage)
/* Simulate pressing buttons to get a reasonable join on a
 * couple of uniProt tables. */
{
struct htmlPage *allPage, *page;
char *org = NULL, *db = NULL, *group = "allTables", *track="uniProt";
int expectedCount = tableSize("uniProt", "taxon");

allPage = quickSubmit(rootPage, org, db, group, "uniProt", 
	"uniProt.taxon", "taxonJoin1", NULL, NULL);
if (allPage != NULL)
    {
    if (allPage->forms == NULL)
        {
	errAbort("uniProt page with no form");
	}
    else
	{
	int count = testAllFields(allPage, allPage->forms, org, db,
	    group, track, "uniProt.taxon");
	if (count != expectedCount)
	    qaStatusSoftError(tablesTestList->status, 
		    "Got %d rows in uniProt.taxon, expected %d", count, 
		    expectedCount);
	htmlPageSetVar(allPage, NULL, hgtaOutputType, "selectedFields");
	page = quickSubmit(allPage, org, db, group, track, 
	    "uniProt.taxon", "taxonJoin2", hgtaDoTopSubmit, "submit");
	htmlPageSetVar(page, NULL, "hgta_fs.linked.uniProt.commonName", "on");
	serialSubmit(&page, org, db, group, track, NULL, "taxonJoin3",
	    hgtaDoSelectFieldsMore, "submit");
	if (page != NULL)
	    {
	    htmlPageSetVar(page, NULL, "hgta_fs.check.uniProt.taxon.binomial", "on");
	    htmlPageSetVar(page, NULL, "hgta_fs.check.uniProt.commonName.val", "on");
	    serialSubmit(&page, org, db, group, track, NULL, "taxonJoin4",
		hgtaDoPrintSelectedFields, "submit");
	    if (page != NULL)
		{
		checkExpectedSimpleRows(page, expectedCount);
		verifyJoinedFormat(page->htmlText);
		htmlPageFree(&page);
		}
	    }
	}
    }

htmlPageFree(&allPage);
verbose(1, "Tested joining on uniProt.taxon & commonName\n");
}
Exemple #10
0
void ZendArray::init(uint nSize) {
  uint size = MinSize;
  if (nSize >= 0x80000000) {
    size = 0x80000000; // prevent overflow
  } else {
    while (size < nSize) size <<= 1;
  }
  m_nTableMask = size - 1;
  if (size <= MinSize) {
    m_arBuckets = m_inlineBuckets;
    memset(m_inlineBuckets, 0, MinSize * sizeof(Bucket*));
  } else {
    m_arBuckets = (Bucket **)calloc(tableSize(), sizeof(Bucket*));
  }
}
Exemple #11
0
    /**
     * Initialize the table to be empty.
     * @param n initial table size.
     */
    void initialize(size_t n) {
        tableSize_ = tableSize(n);
        maxSize_ = tableSize_ * MAX_FILL / 100;
        size_ = 0;
        collisions_ = 0;

        if (tableSize_ <= tableCapacity_) {
            for (size_t i = 0; i < tableSize_; ++i) {
                table[i] = Entry();
            }
        }
        else {
            tableCapacity_ = tableSize_;
            delete[] table;
            table = new Entry[tableCapacity_]();
        }
    }
Exemple #12
0
HOT_FUNC_HPHP
bool ZendArray::addValWithRef(StringData *key, CVarRef data) {
  int64 h = key->hash();
  Bucket *p = findForInsert(key->data(), key->size(), h);
  if (p) {
    return false;
  }
  p = NEW(Bucket)(withRefBind(data));
  p->setStrKey(key, h);
  uint nIndex = (h & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);
  if (++m_size > tableSize()) {
    resize();
  }
  return true;
}
Exemple #13
0
bool ZendArray::nextInsertRef(CVarRef data) {
  if (m_nNextFreeElement < 0) {
    raise_warning("Cannot add element to the array as the next element is "
                  "already occupied");
    return false;
  }
  int64 h = m_nNextFreeElement;
  Bucket * p = NEW(Bucket)(strongBind(data));
  p->setIntKey(h);
  uint nIndex = (h & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);
  m_nNextFreeElement = h + 1;
  if (++m_size > tableSize()) {
    resize();
  }
  return true;
}
Exemple #14
0
HOT_FUNC_HPHP
ArrayData *ZendArray::add(CStrRef k, CVarRef v, bool copy) {
  ASSERT(!exists(k));
  if (UNLIKELY(copy)) {
    ZendArray *result = copyImpl();
    result->add(k, v, false);
    return result;
  }
  int64 h = k->hash();
  Bucket *p = NEW(Bucket)(v);
  p->setStrKey(k.get(), h);
  uint nIndex = (h & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);
  if (++m_size > tableSize()) {
    resize();
  }
  return NULL;
}
Exemple #15
0
HOT_FUNC_HPHP
bool ZendArray::addValWithRef(int64 h, CVarRef data) {
  Bucket *p = findForInsert(h);
  if (p) {
    return false;
  }
  p = NEW(Bucket)(withRefBind(data));
  p->setIntKey(h);
  uint nIndex = (h & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);
  if (h >= m_nNextFreeElement && m_nNextFreeElement >= 0) {
    m_nNextFreeElement = h + 1;
  }
  if (++m_size > tableSize()) {
    resize();
  }
  return true;
}
Exemple #16
0
bool ZendArray::updateRef(StringData *key, CVarRef data) {
  int64 h = key->hash();
  Bucket *p = findForInsert(key->data(), key->size(), h);
  if (p) {
    p->data.assignRefHelper(data);
    return true;
  }

  p = NEW(Bucket)(strongBind(data));
  p->setStrKey(key, h);

  uint nIndex = (h & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);

  if (++m_size > tableSize()) {
    resize();
  }
  return true;
}
/**
 * postSort() runs after sorting has been performed. For ZendArray, postSort()
 * handles rewiring the linked list according to the results of the sort. Also,
 * if resetKeys is true, postSort() will renumber the keys 0 thru n-1.
 */
void ZendArray::postSort(Bucket** buffer, bool resetKeys) {
  uint last = m_size-1;
  m_pListHead = buffer[0];
  m_pListTail = buffer[last];
  m_pos = (ssize_t)m_pListHead;
  Bucket* b = buffer[0];
  b->pListLast = NULL;
  if (resetKeys) {
    memset(m_arBuckets, 0, tableSize() * sizeof(Bucket*));
    for (uint i = 0; i < last; ++i) {
      Bucket* bNext = buffer[i+1];
      b->pListNext = bNext;
      bNext->pListLast = b;
      if (b->hasStrKey() && b->skey->decRefCount() == 0) {
        DELETE(StringData)(b->skey);
      }
      b->setIntKey(i);
      uint nIndex = (i & m_nTableMask);
      CONNECT_TO_BUCKET_LIST(b, m_arBuckets[nIndex]);
      SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, b);
      b = bNext;
    }
    if (b->hasStrKey() && b->skey->decRefCount() == 0) {
      DELETE(StringData)(b->skey);
    }
    b->setIntKey(last);
    uint nIndex = (last & m_nTableMask);
    CONNECT_TO_BUCKET_LIST(b, m_arBuckets[nIndex]);
    SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, b);
    m_nNextFreeElement = m_size;
  } else {
    for (uint i = 0; i < last; ++i) {
      Bucket* bNext = buffer[i+1];
      b->pListNext = bNext;
      bNext->pListLast = b;
      b = bNext;
    }
  }
  b->pListNext = NULL;
}
Exemple #18
0
HOT_FUNC_HPHP
ArrayData *ZendArray::add(int64 k, CVarRef v, bool copy) {
  ASSERT(!exists(k));
  if (UNLIKELY(copy)) {
    ZendArray *result = copyImpl();
    result->add(k, v, false);
    return result;
  }
  Bucket *p = NEW(Bucket)(v);
  p->setIntKey(k);
  uint nIndex = (k & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);
  if (k >= m_nNextFreeElement && m_nNextFreeElement >= 0) {
    m_nNextFreeElement = k + 1;
  }
  if (++m_size > tableSize()) {
    resize();
  }
  return NULL;
}
Exemple #19
0
bool ZendArray::updateRef(int64 h, CVarRef data) {
  Bucket *p = findForInsert(h);
  if (p) {
    p->data.assignRefHelper(data);
    return true;
  }

  p = NEW(Bucket)(strongBind(data));
  p->setIntKey(h);

  uint nIndex = (h & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);

  if (h >= m_nNextFreeElement && m_nNextFreeElement >= 0) {
    m_nNextFreeElement = h + 1;
  }
  if (++m_size > tableSize()) {
    resize();
  }
  return true;
}
Exemple #20
0
HOT_FUNC_HPHP
bool ZendArray::addLvalImpl(StringData *key, int64 h, Variant **pDest,
                            bool doFind /* = true */) {
  ASSERT(key != NULL && pDest != NULL);
  Bucket *p;
  if (doFind) {
    p = findForInsert(key->data(), key->size(), h);
    if (p) {
      *pDest = &p->data;
      return false;
    }
  }
  p = NEW(Bucket)();
  p->setStrKey(key, h);
  *pDest = &p->data;
  uint nIndex = (h & m_nTableMask);
  CONNECT_TO_BUCKET_LIST(p, m_arBuckets[nIndex]);
  SET_ARRAY_BUCKET_HEAD(m_arBuckets, nIndex, p);
  CONNECT_TO_GLOBAL_DLLIST(p);
  if (++m_size > tableSize()) {
    resize();
  }
  return true;
}
Exemple #21
0
TEST_F(TpccTableLoadTests, table_load_with_header_file_test_warehouse) {
  ASSERT_EQ(2u,tableSize("warehouse"));
}
Exemple #22
0
TEST_F(TpccTableLoadTests, table_load_with_header_file_test_orders) {
  ASSERT_EQ(45u,tableSize("orders"));
}
Exemple #23
0
TEST_F(TpccTableLoadTests, table_load_with_header_file_test_stock) {
  ASSERT_EQ(30u,tableSize("stock"));
}
Exemple #24
0
TEST_F(TpccTableLoadTests, table_load_with_header_file_test_item) {
  ASSERT_EQ(15u,tableSize("item"));
}
Exemple #25
0
TEST_F(TpccTableLoadTests, table_load_with_header_file_test_order_line) {
  ASSERT_EQ(225u,tableSize("order_line"));
}
Exemple #26
0
TEST_F(TpccTableLoadTests, table_load_with_header_file_test_history) {
  ASSERT_EQ(45u,tableSize("history"));
}
Exemple #27
0
TEST_F(TpccTableLoadTests, table_load_with_header_file_test_district) {
  ASSERT_EQ(20u,tableSize("district"));
}
Exemple #28
0
TEST_F(TpccTableLoadTests, table_load_with_header_file_test_customer) {
  ASSERT_EQ(45u,tableSize("customer"));
}
// -----------------------------------------------------------------------------
// CSatTimer::Tick
// Static callback method for CPeriodic timer.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt CSatTimer::Tick
        (
        TAny* aSatTimer
        )
    {
    // Logging omitted to avoid excessive log output

    // This is a static method, we need a pointer to parent class in
    // order to utilize it's method and members
    CSatTimer* satTimer = static_cast<CSatTimer*>( aSatTimer );

    // Invert boolean value of half second boolean
    satTimer->iHalfSecondTick = !satTimer->iHalfSecondTick;

    // Update second counter and check timers only when there are active
    // timers and whole second has passed since last update.
    TInt tableSize( satTimer->iTimerTable->Count() );
    if ( KZero != tableSize && !satTimer->iHalfSecondTick )
        {
        satTimer->iSecondsPassed++;

        TFLOGSTRING2("TSY: CSatTimer::Tick, seconds %d",
            satTimer->iSecondsPassed );
        OstTrace1( TRACE_INTERNALS,  CSATTIMER_TICK_TD, "CSatTimer::Tick, seconds %u", satTimer->iSecondsPassed );

        for( TInt i = tableSize - 1; KZero <= i; i-- )
            {
            // Get reference to a timer in TimerTable
            TTimer& timer = ( *satTimer->iTimerTable )[i];

            // Send timer expiration envelope if:
            // 1) Enough time has passed
            // 2) Timer is active
            // 3) Proactive command is not ongoing
            if ( timer.TimeStamp() <= satTimer->iSecondsPassed
                 && TTimer::ETicking == timer.State() )
                {
                // Deactive timer to avoid multiple envelopes
                timer.SetState( TTimer::EBeingSent);

                // Elapsed time
                TInt time( satTimer->iSecondsPassed - timer.StartTime() );

                satTimer->iSatMessaging->TimerExpiration( timer.Id(), time );
                }
            }
        }


    // Handle the stored envelopes. Look for envelopes activated for resending.
    // Resend the oldest envelope if delay criteria has been met.
    tableSize = satTimer->iEnvelopeTable->Count();
    TBool done( EFalse );

    if ( KZero != tableSize )
        {
        for ( TInt i = 0 ; i < tableSize && done == EFalse ; i++ )
            {
            TSatEnvelope& current = ( *satTimer->iEnvelopeTable )[i];

            if ( current.iActive )
                {
                // Active envelope found. Decrease delay and send envelope
                // if zero.
                current.iDelay--;

                if ( KZero >= current.iDelay )
                    {
                    TFLOGSTRING2("TSY: CSatTimer::Tick: \
                        Resending type %x envelope", current.iType );
                    OstTraceExt1( TRACE_INTERNALS,  DUP1_CSATTIMER_TICK_TD, "CSatTimer::Tick Resending type %hhu envelope", current.iType );

                    // Deactivate envelope just in case. Get new transaction
                    // if for envelope and resend it. Finally remove the
                    // envelope from table.
                    current.iActive = EFalse;

                    satTimer->iSatMessHandler->UiccCatReqEnvelope(
                        current.iTId, current.iEnvelope, EFalse );

                    satTimer->RemoveEnvelope( current.iTId );
                    tableSize = satTimer->iEnvelopeTable->Count();

                    // Exit resending loop, only one resent envelope per tick
                    done = ETrue;
                    }
                } // If active
            } // For-loop
Exemple #30
0
static inline const char * gl_lookup_error_by_nr(int error)
{
    const int size = tableSize(_ErrorCode_enum_);
    return gl_lookup_enum_by_nr(error, _ErrorCode_enum_, size);
}