void downlist(IX_DESC *name) /* list keys in decending order */ { ENTRY ee; int count = 0; last_key(name); while (prev_key(&ee, name) == IX_OK) { printf("%s\n",ee.key); ++count; } printf("down list total key is %d.\n", count); /*printf("\nPress any key to continue \n");*/ /*getchar();*/ }
/* get next, previous entries */ int next_key(ENTRY *pe, IX_DESC *pix) { RECPOS address; if(block_ptr->bend == 0) { return IX_FAIL; } pci = pix; retrieve_block(pci->level, CB(pci->level)); address = ENT_ADR(block_ptr, CO(pci->level))->idxptr; while (address != NULLREC) { retrieve_block(++(pci->level), address); CO(pci->level) = -1; address = block_ptr->p0; } next_entry(CO(pci->level)); if (CO(pci->level) == block_ptr->bend) { do { if(pci->level == 0) { last_key(pci); return (EOIX); } --(pci->level); retrieve_block(pci->level, CB(pci->level)); next_entry(CO(pci->level)); } while (CO(pci->level) == block_ptr->bend); } copy_entry(pe, ENT_ADR(block_ptr, CO(pci->level))); return ( IX_OK ); }
void Receiver_exec_i::read_all (void) { ::Reader_Test::ReaderTestConnector::Reader_var reader = this->ciao_context_->get_connection_info_out_data(); try { ReaderTestSeq readertest_info_seq; ::CCM_DDS::ReadInfoSeq readinfo_seq; reader->read_all (readertest_info_seq, readinfo_seq); CORBA::ULong const nr_samples = this->keys_ * this->iterations_; if (readertest_info_seq.length () != nr_samples) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: READ ALL: ") ACE_TEXT ("Didn't receive the expected number of ") ACE_TEXT ("samples : expected <%u> - received <%u>\n"), nr_samples, readertest_info_seq.length ())); } if (readertest_info_seq.length () > 0) { CORBA::UShort nr_keys_changed = 1; CORBA::String_var last_key (readertest_info_seq[0].key.in ()); CORBA::UShort iterations = 0; for (CORBA::ULong it = 0; it < readertest_info_seq.length (); ++it) { if (ACE_OS::strcmp (last_key, readertest_info_seq[it].key.in ()) != 0) { ACE_OS::strcpy (last_key, readertest_info_seq[it].key.in ()); ++nr_keys_changed; } // check readinfo struct. if (::DDS::HANDLE_NIL == readinfo_seq[it].instance_handle) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: READ ALL: ") ACE_TEXT ("received instance handle should be valid ") ACE_TEXT ("for keyed data: ") ACE_TEXT ("key <%C> - iteration <%u>\n"), readertest_info_seq[it].key.in (), readertest_info_seq[it].iteration)); } if (readinfo_seq[it].source_timestamp.sec == 0 && readinfo_seq[it].source_timestamp.nanosec == 0) { ACE_ERROR ((LM_ERROR, "ERROR: READ ALL: " "source timestamp seems to be invalid (nil) " "key <%C> - iteration <%d>\n", readertest_info_seq[it].key.in (), readertest_info_seq[it].iteration)); } ++iterations; } if (nr_keys_changed != this->keys_) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: READ ALL: ") ACE_TEXT ("Didn't receive the expected number of ") ACE_TEXT ("instances : expected <%u> - received <%u>\n"), this->keys_, nr_keys_changed)); } if (iterations != (this->keys_ * this->iterations_)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: READ ALL: ") ACE_TEXT ("Didn't receive the expected number of ") ACE_TEXT ("samples : expected <%u> - received <%u>\n"), nr_samples, iterations)); } } } catch (const CCM_DDS::NonExistent& ex) { for (CORBA::ULong i = 0; i < ex.indexes.length (); ++i) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("READ ALL: ") ACE_TEXT ("caught expected exception: index <%u>\n"), ex.indexes[i])); } } catch (const CCM_DDS::InternalError& ex) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: READ ALL: ") ACE_TEXT ("caught InternalError exception: retval <%u>\n"), ex.error_code)); } catch (const ::CORBA::Exception& ex) { ex._tao_print_exception ("ERROR: READ ALL: "); ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: Receiver_exec_i::read_all : Exception caught\n"))); } }