BlockInputStreams StorageSystemFunctions::read( const Names & column_names, ASTPtr query, const Context & context, const Settings & settings, QueryProcessingStage::Enum & processed_stage, const size_t max_block_size, const unsigned threads) { check(column_names); processed_stage = QueryProcessingStage::FetchColumns; ColumnWithTypeAndName column_name{ std::make_shared<ColumnString>(), std::make_shared<DataTypeString>(), "name" }; ColumnWithTypeAndName column_is_aggregate{ std::make_shared<ColumnUInt8>(), std::make_shared<DataTypeUInt8>(), "is_aggregate" }; const auto & functions = FunctionFactory::instance().functions; for (const auto & it : functions) { column_name.column->insert(it.first); column_is_aggregate.column->insert(UInt64(0)); } const auto & aggregate_functions = context.getAggregateFunctionFactory().aggregate_functions; for (const auto & it : aggregate_functions) { column_name.column->insert(it.first); column_is_aggregate.column->insert(UInt64(1)); } return BlockInputStreams{ std::make_shared<OneBlockInputStream>(Block{ column_name, column_is_aggregate }) }; }
WorldInfo World::GetInfo () const noexcept { Word num=lock.Execute([&] () { return world.size(); }); return WorldInfo{ Word(maintenances), UInt64(maintenance_time), Word(loaded), UInt64(load_time), Word(unloaded), Word(saved), UInt64(save_time), Word(generated), UInt64(generate_time), Word(populated), UInt64(populate_time), num, num*( sizeof(ColumnContainer::Blocks)+ sizeof(ColumnContainer::Biomes)+ sizeof(ColumnContainer::Populated) ) }; }
static OSStatus MemoryInputCallback (void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { UInt64 now = CAHostTimeBase::GetTheCurrentTime(); OSStatus result = 0; ReadBuffer *readBuffer = (ReadBuffer*)inRefCon; if (inTimeStamp->mSampleTime >= readBuffer->totalInputFrames) { #if VERBOSE printf ("reading: %.0f past input: %.0f\n", inTimeStamp->mSampleTime, (double)readBuffer->totalInputFrames); #endif result = kEndOfInput; readBuffer->lastInputFrames = 0; goto end; } // can get pulled multiple times readBuffer->lastInputFrames += inNumberFrames; if (UInt64(inTimeStamp->mSampleTime + inNumberFrames) > readBuffer->totalInputFrames) { // first set this to zero as we're only going to read a partial number of frames AudioBuffer *buf = ioData->mBuffers; for (UInt32 i = ioData->mNumberBuffers; i--; ++buf) memset((Byte *)buf->mData, 0, buf->mDataByteSize); inNumberFrames = UInt32 (readBuffer->totalInputFrames - UInt64(inTimeStamp->mSampleTime)); } // copy data from the source to the ioData buffers { AudioBuffer *buf = ioData->mBuffers; AudioBuffer *rBuf = readBuffer->readData->ABL()->mBuffers; for (UInt32 i = ioData->mNumberBuffers; i--; ++buf, ++rBuf) { AudioBuffer readB = *rBuf; readB.mData = static_cast<Float32*>(rBuf->mData) + UInt32(inTimeStamp->mSampleTime); memcpy (buf->mData, readB.mData, (inNumberFrames * sizeof(Float32))); } } end: sLastReadTime += (CAHostTimeBase::GetTheCurrentTime() - now); return result; }
namespace Json { const Value Value::null; const Int Value::minInt = Int( ~(UInt(-1)/2) ); const Int Value::maxInt = Int( UInt(-1)/2 ); const UInt Value::maxUInt = UInt(-1); const Int64 Value::minInt64 = Int64( ~(UInt64(-1)/2) ); const Int64 Value::maxInt64 = Int64( UInt64(-1)/2 ); const UInt64 Value::maxUInt64 = UInt64(-1); const LargestInt Value::minLargestInt = LargestInt( ~(LargestUInt(-1)/2) ); const LargestInt Value::maxLargestInt = LargestInt( LargestUInt(-1)/2 ); const LargestUInt Value::maxLargestUInt = LargestUInt(-1); /// Unknown size marker static const unsigned int unknown = (unsigned)-1; /** Duplicates the specified string value. * @param value Pointer to the string to duplicate. Must be zero-terminated if * length is "unknown". * @param length Length of the value. if equals to unknown, then it will be * computed using strlen(value). * @return Pointer on the duplicate instance of string. */ static inline char * duplicateStringValue( const char *value, unsigned int length = unknown ) { if ( length == unknown ) length = (unsigned int)strlen(value); char *newString = static_cast<char *>( malloc( length + 1 ) ); //JSON_ASSERT_MESSAGE( newString != 0, "Failed to allocate string value buffer" ); memcpy( newString, value, length ); newString[length] = 0; return newString; } /** Free the string duplicated by duplicateStringValue(). */ static inline void releaseStringValue( char *value ) { if ( value ) free( value ); } } // namespace Json
Value::UInt64 Value::asUInt64() const { switch ( type_ ) { case nullValue: return false; case intValue: return value_.int_; case uintValue: return value_.uint_; case realValue: JSON_ASSERT_MESSAGE( value_.real_ >= 0 && value_.real_ <= maxUInt64, "Real out of signed integer 64 range" ); return UInt64( value_.real_ ); case int64Value: JSON_ASSERT_MESSAGE( value_.int64_ >= 0, "Negative integer 64 can not be converted to unsigned integer 64" ); return value_.int64_; case uint64Value: return value_.uint64_; case booleanValue: return value_.bool_; case stringValue: return value_.string_ && value_.string_[0] != 0; case arrayValue: case objectValue: return value_.map_->size() != 0; default: JSON_ASSERT_UNREACHABLE; } return false; // unreachable; }
void runTests(bool write,BinaryDataHandler &pMem) { runTest (write,pMem, std::string("Hallo") ); runTest1 (write,pMem, Time(222.22) ); runTest (write,pMem, Color3f(1.1,2.2,3.3) ); runTest (write,pMem, Color4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Color3ub(1,2,3) ); runTest (write,pMem, Color4ub(1,2,3,4) ); runTest (write,pMem, DynamicVolume(DynamicVolume::BOX_VOLUME) ); runTest (write,pMem, DynamicVolume(DynamicVolume::SPHERE_VOLUME) ); runTest1 (write,pMem, BitVector(0xabcd) ); runTest (write,pMem, Plane(Vec3f(1.0,0),0.222) ); runTest (write,pMem, Matrix(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) ); runTest (write,pMem, Quaternion(Vec3f(1,2,3),22) ); runTest2<bool>(write,pMem, true ); runTest (write,pMem, Int8(-22) ); runTest (write,pMem, UInt8(11) ); runTest (write,pMem, Int16(-10233) ); runTest (write,pMem, UInt16(20233) ); runTest (write,pMem, Int32(-222320233) ); runTest (write,pMem, UInt32(522320233) ); runTest<Int64> (write,pMem, Int64(-522323334) ); runTest (write,pMem, UInt64(44523423) ); runTest (write,pMem, Real32(22.333224) ); runTest (write,pMem, Real64(52.334534533224) ); runTest (write,pMem, Vec2f(1.1,2.2) ); runTest (write,pMem, Vec3f(1.1,2.2,3.3) ); runTest (write,pMem, Vec4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt2f(1.1,2.2) ); runTest (write,pMem, Pnt2d(1.1,2.2) ); runTest (write,pMem, Pnt3f(1.1,2.2,3.3) ); runTest (write,pMem, Pnt3d(1.1,2.2,3.3) ); runTest (write,pMem, Pnt4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt4d(1.1,2.2,3.3,4.4) ); }
uint64 TSysTm::GetCurLocMSecs(){ SYSTEMTIME SysTm; FILETIME FileTm; GetLocalTime(&SysTm); IAssert(SystemTimeToFileTime(&SysTm, &FileTm)); TUInt64 UInt64(uint(FileTm.dwHighDateTime), uint(FileTm.dwLowDateTime)); return UInt64.Val/uint64(10000); }
// Input IO Proc // Receiving input for 1 buffer + safety offset into the past OSStatus AudioThruEngine::InputIOProc ( AudioDeviceID inDevice, const AudioTimeStamp* inNow, const AudioBufferList* inInputData, const AudioTimeStamp* inInputTime, AudioBufferList* outOutputData, const AudioTimeStamp* inOutputTime, void* inClientData) { AudioThruEngine *This = (AudioThruEngine *)inClientData; switch (This->mInputProcState) { case kStarting: This->mInputProcState = kRunning; break; case kStopRequested: AudioDeviceStop(inDevice, InputIOProc); This->mInputProcState = kOff; return noErr; default: break; } This->mLastInputSampleCount = inInputTime->mSampleTime; This->mInputBuffer->Store((const Byte *)inInputData->mBuffers[0].mData, This->mInputDevice.mBufferSizeFrames, UInt64(inInputTime->mSampleTime)); // This->ApplyLoad(This->mInputLoad); return noErr; }
void StorageSystemFunctions::fillData(MutableColumns & res_columns, const Context &, const SelectQueryInfo &) const { const auto & functions_factory = FunctionFactory::instance(); const auto & function_names = functions_factory.getAllRegisteredNames(); for (const auto & name : function_names) { fillRow(res_columns, name, UInt64(0), functions_factory); } const auto & aggregate_functions_factory = AggregateFunctionFactory::instance(); const auto & aggregate_function_names = aggregate_functions_factory.getAllRegisteredNames(); for (const auto & name : aggregate_function_names) { fillRow(res_columns, name, UInt64(1), aggregate_functions_factory); } }
Void WINAPI LoadUCI( tTVPGraphicLoadMode mode, tjs_int32 keyidx, tTJSBinaryStream *src, #if !defined(FATE_STAY_NIGHT) tTVPMetaInfoPushCallback metainfopushcallback, #endif tTVPGraphicScanLineCallback scanlinecallback ) { void *formatdata, *callbackdata; tTVPGraphicSizeCallback sizecallback; BOOL bFindMeta; Int32 y, w, header, strideOut, alphatype; PByte pbBuffer; PVOID lpBuffer; UCIInfo uci; INLINE_ASM { mov formatdata, eax; mov callbackdata, edx; mov sizecallback, ecx; } UInt64 (TJS_INTF_METHOD *F_GetSize)(tTJSBinaryStream *src) = (UInt64 (TJS_INTF_METHOD *)(tTJSBinaryStream*))FUNC_GET_SIZE; ReadBuffer(src, &header, 4); if ((header & 0xFFFFFF) != TAG3('UCI')) { SetPosition(src, GetPosition(src) - 4); if (FTVPLoadBMP == NULL) return; INLINE_ASM { mov eax, formatdata; mov edx, callbackdata; mov ecx, sizecallback; push scanlinecallback; } IF_EXIST(metainfopushcallback) { INLINE_ASM push metainfopushcallback; } INLINE_ASM { push src; push keyidx; push mode; call FTVPLoadBMP; } return; }
Value::Int64 Value::asInt64() const { switch ( type_ ) { case nullValue: return 0; case intValue: return value_.int_; case uintValue: JSON_ASSERT_MESSAGE( value_.uint_ <= UInt64(maxInt64), "unsigned integer out of Int64 range" ); return value_.uint_; case realValue: JSON_ASSERT_MESSAGE( value_.real_ >= minInt64 && value_.real_ <= maxInt64, "Real out of Int64 range" ); return Int( value_.real_ ); case booleanValue: return value_.bool_ ? 1 : 0; case stringValue: case arrayValue: case objectValue: JSON_ASSERT_MESSAGE( false, "Type is not convertible to Int64" ); default: JSON_ASSERT_UNREACHABLE; } return 0; // unreachable; }
UInt64 Message::getContentLength() const { const std::string& contentLength = get(CONTENT_LENGTH, EMPTY); if (!contentLength.empty()) { return util::strtoi<UInt64>(contentLength); } else return UInt64(UNKNOWN_CONTENT_LENGTH); }
STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) { UInt32 realProcessedSize = 0; while(_currentIndex < _extractStatuses->Size()) { if (_fileIsOpen) { UInt32 index = _startIndex + _currentIndex; const CFileItem &fileInfo = _archiveDatabase->Files[index]; UInt64 fileSize = fileInfo.UnPackSize; UInt32 numBytesToWrite = (UInt32)MyMin(fileSize - _filePos, UInt64(size - realProcessedSize)); UInt32 processedSizeLocal; RINOK(_outStreamWithHash->Write((const Byte *)data + realProcessedSize, numBytesToWrite, &processedSizeLocal)); _filePos += processedSizeLocal; realProcessedSize += processedSizeLocal; if (_filePos == fileSize) { bool digestsAreEqual; if (fileInfo.IsFileCRCDefined && _checkCrc) digestsAreEqual = fileInfo.FileCRC == _outStreamWithHashSpec->GetCRC(); else digestsAreEqual = true; RINOK(_extractCallback->SetOperationResult( digestsAreEqual ? NArchive::NExtract::NOperationResult::kOK : NArchive::NExtract::NOperationResult::kCRCError)); _outStreamWithHashSpec->ReleaseStream(); _fileIsOpen = false; _currentIndex++; } if (realProcessedSize == size) { if (processedSize != NULL) *processedSize = realProcessedSize; return WriteEmptyFiles(); } } else { RINOK(OpenFile()); _fileIsOpen = true; _filePos = 0; } } if (processedSize != NULL) *processedSize = size; return S_OK; }
Value::UInt64 Value::asUInt64() const { switch (type_) { case intValue: JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range"); return UInt64(value_.int_); case uintValue: return UInt64(value_.uint_); case realValue: JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64), "double out of UInt64 range"); return UInt64(value_.real_); case nullValue: return 0; case booleanValue: return value_.bool_ ? 1 : 0; default: break; } JSON_FAIL_MESSAGE("Value is not convertible to UInt64."); }
void AUTimestampGenerator::AddOutputTime(const AudioTimeStamp &inTimeStamp, Float64 expectedDeltaFrames, double outputSampleRate, double rateScalarAdj) { mState.mRateScalarAdj = rateScalarAdj; mState.mLastOutputTime = mState.mCurrentOutputTime; mState.mInputSampleTimeForOutputPull = mState.mNextInputSampleTime; mState.mCurrentOutputTime = inTimeStamp; if (mState.mBypassed) return; if (mState.mHostTimeDiscontinuityCorrection && !(mState.mCurrentOutputTime.mFlags & kAudioTimeStampHostTimeValid) && (mState.mLastOutputTime.mFlags & kAudioTimeStampHostTimeValid)) { // no host time here but we had one last time, interpolate one double rateScalar = (mState.mCurrentOutputTime.mFlags & kAudioTimeStampRateScalarValid) ? mState.mCurrentOutputTime.mRateScalar : 1.0; Float64 deltaSamples = mState.mCurrentOutputTime.mSampleTime - mState.mLastOutputTime.mSampleTime; mState.mCurrentOutputTime.mHostTime = mState.mLastOutputTime.mHostTime + UInt64(CAHostTimeBase::GetFrequency() * deltaSamples * rateScalar / outputSampleRate); mState.mCurrentOutputTime.mFlags |= kAudioTimeStampHostTimeValid; #if DEBUG if (mVerbosity > 1) printf("synthesized host time: %.3f (%.3f + %.f smp @ %.f Hz, rs %.3f\n", DebugHostTime(mState.mCurrentOutputTime), DebugHostTime(mState.mLastOutputTime), deltaSamples, outputSampleRate, rateScalar); #endif } // copy rate scalar if (rateScalarAdj != 1.0) { if (mState.mCurrentOutputTime.mFlags & kAudioTimeStampRateScalarValid) mState.mCurrentOutputTime.mRateScalar *= rateScalarAdj; else { mState.mCurrentOutputTime.mRateScalar = rateScalarAdj; mState.mCurrentOutputTime.mFlags |= kAudioTimeStampRateScalarValid; } } if (mFirstTime) { mFirstTime = false; mState.mDiscontinuous = false; mState.mDiscontinuityDeltaSamples = 0.; if (!mState.mStartInputAtZero) { mState.mNextInputSampleTime = mState.mCurrentOutputTime.mSampleTime; mState.mInputSampleTimeForOutputPull = mState.mNextInputSampleTime; } } else { mState.mDiscontinuous = fnotequal(mState.mCurrentOutputTime.mSampleTime, mState.mNextOutputSampleTime); mState.mDiscontinuityDeltaSamples = mState.mCurrentOutputTime.mSampleTime - mState.mNextOutputSampleTime; // time should never go backwards... if (mState.mDiscontinuityDeltaSamples < 0.) mState.mDiscontinuityDeltaSamples = 0.; #if DEBUG if (mVerbosity > 1) if (mState.mDiscontinuous) printf("%-20.20s: *** DISCONTINUOUS, got " TSGFMT ", expected " TSGFMT "\n", mDebugName, (SInt64)mState.mCurrentOutputTime.mSampleTime, (SInt64)mState.mNextOutputSampleTime); #endif } mState.mNextOutputSampleTime = mState.mCurrentOutputTime.mSampleTime + expectedDeltaFrames; }
LONG InStream::GetSize(UInt64 *size) { if (ioDevice_->isSequential()) { *size = 0UL; return E_FAIL; } else { *size = UInt64(ioDevice_->size()); return S_OK; } }
void AudioThruEngine::ApplyLoad(double load) { double loadNanos = (load * mBufferSize / mSampleRate) /* seconds */ * 1000000000.; UInt64 now = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); UInt64 waitUntil = UInt64(now + loadNanos); while (now < waitUntil) { now = AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()); } }
LONG InStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) { if (newPosition) *newPosition = UInt64(ioDevice_->pos()); if (!ioDevice_->isReadable() || ioDevice_->isSequential()) return E_FAIL; qint64 pos = ioDevice_->pos(); if (SEEK_SET == seekOrigin) pos = offset; else if (SEEK_CUR == seekOrigin) pos += offset; else if (SEEK_END == seekOrigin) pos = ioDevice_->size() - offset; if (ioDevice_->seek(pos)) { if (newPosition) *newPosition = UInt64(ioDevice_->pos()); return S_OK; } else { return E_FAIL; } }
uint64 TSysTm::GetPerfTimerFq(){ uint MsFq; uint LsFq; LARGE_INTEGER LargeInt; if (QueryPerformanceFrequency(&LargeInt)){ MsFq=LargeInt.u.HighPart; LsFq=LargeInt.u.LowPart; } else { MsFq=0; LsFq=1; } TUInt64 UInt64(MsFq, LsFq); return UInt64.Val; }
FrameHandlerBase::FrameHandlerBase(void) : Inherited(), _sfFrameCount (UInt64(0)), _sfStartTime (Time(-1.0)), _sfLastTime (Time(0.0)), _sfCurrTime (Time(0.0)), _sfTimeStamp (Time(0.0)), _sfTimeScale (Time(1.0)), _sfConstantTimeStep (Time(0.0)), _sfConstantTime (bool(false)), _sfPaused (bool(false)) { }
uint64 TSysTm::GetPerfTimerTicks(){ uint MsVal; uint LsVal; LARGE_INTEGER LargeInt; if (QueryPerformanceCounter(&LargeInt)){ MsVal=LargeInt.u.HighPart; LsVal=LargeInt.u.LowPart; } else { MsVal=0; LsVal=int(time(NULL)); } TUInt64 UInt64(MsVal, LsVal); return UInt64.Val; }
UInt64 Timer::GetTicksNanos() { // Choreographer vsync timestamp is based on. struct timespec tp; const int status = clock_gettime(CLOCK_MONOTONIC, &tp); if (status != 0) { OVR_DEBUG_LOG(("clock_gettime status=%i", status )); } const UInt64 result = (UInt64)tp.tv_sec * (UInt64)(1000 * 1000 * 1000) + UInt64(tp.tv_nsec); return result; }
dmz::UInt64 dmz::ReaderZip::get_file_size () const { UInt64 result (0); unz_file_info info; if (_state.zip_error ( unzGetCurrentFileInfo (_state.zf, &info, 0, 0, 0, 0, 0, 0))) { result = UInt64 (info.uncompressed_size); } return result; }
/*! \brief Determines the size of a file. \details Defined in dmzSystemFile.h. \param[in] Path String containing path to the file. \return Returns the size of the file in bytes. */ dmz::UInt64 dmz::get_file_size (const String &Path) { UInt64 result (0); struct stat s; if (!stat (Path.get_buffer (), &s)) { result = UInt64 (s.st_size > 0 ? s.st_size : 0); } return result; }
uint64 TSysTm::GetMSecsFromTm(const TTm& Tm){ SYSTEMTIME SysTm; FILETIME FileTm; SysTm.wYear=WORD(Tm.GetYear()); SysTm.wMonth=WORD(Tm.GetMonth()); SysTm.wDayOfWeek=WORD(Tm.GetDayOfWeek()); SysTm.wDay=WORD(Tm.GetDay()); SysTm.wHour=WORD(Tm.GetHour()); SysTm.wMinute=WORD(Tm.GetMin()); SysTm.wSecond=WORD(Tm.GetSec()); SysTm.wMilliseconds=WORD(Tm.GetMSec()); ESAssert(SystemTimeToFileTime(&SysTm, &FileTm)); TUInt64 UInt64(uint(FileTm.dwHighDateTime), uint(FileTm.dwLowDateTime)); return UInt64.Val/uint64(10000); }
UInt64 Timer::GetTicksNanos() { // Do NOT change because this should be the same as Java's system.nanoTime(), // which is what the Choreographer vsync timestamp is based on. struct timespec tp; const int status = clock_gettime(CLOCK_MONOTONIC, &tp); if (status != 0) { OVR_DEBUG_LOG(("clock_gettime status=%i", status )); } const UInt64 result = (UInt64)tp.tv_sec * (UInt64)(1000 * 1000 * 1000) + UInt64(tp.tv_nsec); return result; }
void COutArchive::WriteNumber(UInt64 value) { Byte firstByte = 0; Byte mask = 0x80; int i; for (i = 0; i < 8; i++) { if (value < ((UInt64(1) << ( 7 * (i + 1))))) { firstByte |= Byte(value >> (8 * i)); break; } firstByte |= mask; mask >>= 1; }
/*! * \brief Changes the playing offset of the music * * If the music is not playing, this sets the playing offset for the next Play call * * \param offset The offset in milliseconds * * \remark Music must be valid when calling this function */ void Music::SetPlayingOffset(UInt32 offset) { NazaraAssert(m_impl, "Music not created"); bool isPlaying = m_impl->streaming; if (isPlaying) Stop(); m_impl->playingOffset = offset; m_impl->processedSamples = UInt64(offset) * m_impl->sampleRate * m_impl->stream->GetFormat() / 1000ULL; if (isPlaying) Play(); }
UInt64 Timer::GetTicks() { DWORD ticks = timeGetTime(); UInt64 result; // On Win32 QueryPerformanceFrequency is unreliable due to SMP and // performance levels, so use this logic to detect wrapping and track // high bits. ::EnterCriticalSection(&WinAPI_GetTimeCS); if (WinAPI_OldTime > ticks) WinAPI_WrapCounter++; WinAPI_OldTime = ticks; result = (UInt64(WinAPI_WrapCounter) << 32) | ticks; ::LeaveCriticalSection(&WinAPI_GetTimeCS); return result * MksPerMs; }
bool Value::isInt64() const { #if defined(JSON_HAS_INT64) switch (type_) { case intValue: return true; case uintValue: return value_.uint_ <= UInt64(maxInt64); case realValue: // Note that maxInt64 (= 2^63 - 1) is not exactly representable as a // double, so double(maxInt64) will be rounded up to 2^63. Therefore we // require the value to be strictly less than the limit. return value_.real_ >= double(minInt64) && value_.real_ < double(maxInt64) && IsIntegral(value_.real_); default: break; } #endif // JSON_HAS_INT64 return false; }