uint16_t DataPage::getRecordOffsetAt(size_type index) const { RAISE_INTERNAL_ERROR_IF_ARG(index >= getNumberOfRecords()); const size_type keyOffsetPosition = HEADER_DATA_END_OFFSET + (index * sizeof(uint16_t)); return get16(keyOffsetPosition); }
size_type DataPage::freeSpace() const { const size_type recordPointerArraySize = getNumberOfRecords() * sizeof(uint16_t); const size_type bytesfree = getEndOfFreeArea() - (HEADER_DATA_END_OFFSET + recordPointerArraySize); RAISE_DATABASE_CORRUPTED_IF(bytesfree > size(), "free area %u > page size %u on %s", bytesfree, size(), getId().toString()); return bytesfree; }
/** * @param variable * @return */ long CDFFileReader::getNumberOfRecords(const std::string& variable) { //std::cout << "reading " << variable << std::endl; //get variable number long variableNum = CDFgetVarNum(current_file_id, (char *) variable.c_str()); return getNumberOfRecords(variableNum); }
void DataPage::setRecordOffsetAt(size_type index, size_type offset) { RAISE_INTERNAL_ERROR_IF_ARG(index > getNumberOfRecords()); RAISE_INTERNAL_ERROR_IF_ARG(offset > size()); const size_type keyOffsetPosition = HEADER_DATA_END_OFFSET + (index * sizeof(uint16_t)); const uint16_t sixteenBitOffset = static_cast<uint16_t>(offset); put16(keyOffsetPosition, sixteenBitOffset); }
void TraceDataByRank::getData(Time timeStart, Time timeRange, double pixelLength) { // get the start location FileOffset startLoc = findTimeInInterval(timeStart, minloc, maxloc); // get the end location Time endTime = timeStart + timeRange; FileOffset endLoc = min( findTimeInInterval(endTime, minloc, maxloc) + SIZE_OF_TRACE_RECORD, maxloc); // get the number of records data to display Long numRec = 1 + getNumberOfRecords(startLoc, endLoc); // -------------------------------------------------------------------------------------------------- // if the data-to-display is fit in the display zone, we don't need to use recursive binary search // we just simply display everything from the file // -------------------------------------------------------------------------------------------------- if (numRec <= numPixelsH) { // display all the records for (FileOffset i = startLoc; i <= endLoc;) { listCPID->push_back(getData(i)); // one record of data contains of an integer (cpid) and a long (time) i = i + SIZE_OF_TRACE_RECORD; } } else { // the data is too big: try to fit the "big" data into the display //fills in the rest of the data for this process timeline sampleTimeLine(startLoc, endLoc, 0, numPixelsH, 0, pixelLength, timeStart); } // -------------------------------------------------------------------------------------------------- // get the last data if necessary: the rightmost time is still less then the upper limit // I think we can add the rightmost data into the list of samples // -------------------------------------------------------------------------------------------------- if (endLoc < maxloc) { TimeCPID dataLast = getData(endLoc); addSample(listCPID->size(), dataLast); } // -------------------------------------------------------------------------------------------------- // get the first data if necessary: the leftmost time is still bigger than the lower limit // similarly, we add to the list // -------------------------------------------------------------------------------------------------- if (startLoc > minloc) { TimeCPID dataFirst = getData(startLoc - SIZE_OF_TRACE_RECORD); addSample(0, dataFirst); } postProcess(); }
bool rspfShapeDatabase::getNextRecord(rspfShapeDatabaseRecord& result) { if(isOpen() && ((theRecordNumber+1) < getNumberOfRecords())) { ++theRecordNumber; return getRecord(result); } return false; }
bool rspfShapeDatabase::getRecord(rspfShapeDatabaseRecord& result, int recordNumber) { if(isOpen()) { if(recordNumber < getNumberOfRecords()) { theRecordNumber = recordNumber; return getRecord(result); } } return false; }
int ScripMasterDataRequest::serialize(char *buf) { int bytes = 0; UNSIGNED_INTEGER tmp = 0; UNSIGNED_SHORT tmpShort = 0; UNSIGNED_CHARACTER tmpChar = 0; UNSIGNED_LONG tmpLong = 0; bytes = sizeof(UNSIGNED_SHORT); // Leave 2 bytes for packet size // Put category of command SERIALIZE_8(tmpChar, (UNSIGNED_CHARACTER)(CMD::CommandCategory_SEND_SCRIP_MASTER_DATA), buf, bytes); //Command Category // Put fields of this class SERIALIZE_8(tmpChar, getScripMasterDataRequestType(), buf, bytes); SERIALIZE_32(tmp, getClientId(), buf, bytes); SERIALIZE_64(tmpLong, getRecordNumber(), buf, bytes); SERIALIZE_64(tmpLong, getSecurityId(), buf, bytes); SERIALIZE_64(tmpLong, getSymbolId(), buf, bytes); SERIALIZE_16(tmpShort, getExchangeId(), buf, bytes); memcpy(buf + bytes, getSymbol(), SYMBOL_SIZE); bytes += SYMBOL_SIZE; memcpy(buf + bytes, getSeries(), SERIES_SIZE); bytes += SERIES_SIZE; memcpy(buf + bytes, getMarketName(), SERIES_SIZE); bytes += MARKET_NAME_SIZE; SERIALIZE_8(tmpChar, getOptionType(), buf, bytes); SERIALIZE_8(tmpChar, getOptionMode(), buf, bytes); SERIALIZE_8(tmpChar, getSecurityType(), buf, bytes); SERIALIZE_64(tmpLong, getStrikePrice(), buf, bytes); SERIALIZE_32(tmp, getExpiryYearMon(), buf, bytes); SERIALIZE_32(tmp, getExpiryDate(), buf, bytes); SERIALIZE_32(tmp, getNumberOfRecords(), buf, bytes); memcpy(buf + bytes, getSymbolAlias(), SYMBOL_ALIAS_SIZE); bytes += SYMBOL_ALIAS_SIZE; UNSIGNED_SHORT dummyBytes = 0; // Put size as the first field after deducting 2 bytes reserved for size SERIALIZE_16(tmpShort, (UNSIGNED_SHORT)(bytes-sizeof(UNSIGNED_SHORT)), buf, dummyBytes); return bytes; }
size_type DataPage::deleteSingleRecord(const DataPageCursor& cursor) { const uint16_t numberOfRecords = getNumberOfRecords(); RAISE_INTERNAL_ERROR_IF_ARG(numberOfRecords == 0); RAISE_INTERNAL_ERROR_IF_ARG(! cursor.isValid()); const size_type recordInlineSize = (cursor.isInlineValue())? cursor.recordOverheadSize() + static_cast<size_type>(cursor.inlineValue().size()) // inline value - overhead + value size : cursor.recordOverheadSize() + (2 * sizeof(uint32_t)); // big value - overhead + data size (4) + page pointer (4) if (cursor.index() < numberOfRecords - 1) { // Generic case: existing records and record pointers must be moved. const size_type endOfFreeArea = getEndOfFreeArea(); const size_type movedBytes = getRecordOffsetAt(cursor.index()) - endOfFreeArea; const size_type newEndOfFreeArea = endOfFreeArea + recordInlineSize; // Move rest of the data to fill the hole. moveBytes(newEndOfFreeArea, endOfFreeArea, movedBytes); // Adjust record pointers. for (uint16_t i = cursor.index() + 1; i < numberOfRecords; ++i) { const size_type newOffset = getRecordOffsetAt(i) + recordInlineSize; setRecordOffsetAt(i - 1, newOffset); } setEndOfFreeArea(newEndOfFreeArea); } else { // Special case: adjust the end of free area when deleting the last item. const uint32_t newEndOfFreeArea = (numberOfRecords == 1)? size() : getRecordOffsetAt(cursor.index() - 1); setEndOfFreeArea(newEndOfFreeArea); } setNumberOfRecords(numberOfRecords - 1); return recordInlineSize; }
void ScripMasterDataRequest::dump() { std::cout << "ScripMasterDataRequest dump : " << std::endl; std::cout << getScripMasterDataRequestType() << std::endl; std::cout << getClientId() << std::endl; std::cout << getRecordNumber() << std::endl; std::cout << getSecurityId() << std::endl; std::cout << getSymbolId() << std::endl; std::cout << getExchangeId() << std::endl; std::cout << getSymbol() << std::endl; std::cout << getSeries() << std::endl; std::cout << getMarketName() << std::endl; std::cout << getOptionType() << std::endl; std::cout << getOptionMode() << std::endl; std::cout << getSecurityType() << std::endl; std::cout << getStrikePrice() << std::endl; std::cout << getExpiryYearMon() << std::endl; std::cout << getExpiryDate() << std::endl; std::cout << getNumberOfRecords() << std::endl; std::cout << getSymbolAlias() << std::endl; std::cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" << std::endl; }
void DataPage::addRecordOffset(size_type keyOffset) { const uint16_t numberOfRecords = getNumberOfRecords(); setRecordOffsetAt(numberOfRecords, keyOffset); setNumberOfRecords(numberOfRecords + 1); }
/** * @param variable_id * @return */ long HDF5FileReader::getNumberOfRecords(long variable) { return getNumberOfRecords(this->variableGroup->getObjnameByIdx(variable)); }