static unsigned getAllocatorId(const void *ptr) { dbgassertex(ptr); HeapletBase *h = findBase(ptr); unsigned id = h->_rawAllocatorId(ptr); return (id & ACTIVITY_MASK); }
void RoxieOutputRowArray::flush() { RoxieOutputRowArrayLock block(*this); dbgassertex(numRows >= commitRows); //This test could be improved... if (firstRow != 0 && firstRow == commitRows) { //A block of rows was removed - copy these rows to the start of the block. memmove(rows, rows+firstRow, (numRows-firstRow) * sizeof(void *)); numRows -= firstRow; firstRow = 0; } commitRows = numRows; }
//Return the number of bits including the first non-zero bit. Undefined if value == 0 inline unsigned getMostSignificantBit(unsigned value) { dbgassertex(value != 0); #if defined(__GNUC__) return (sizeof(unsigned)*8) - __builtin_clz(value); #elif defined (_WIN32) unsigned long index; _BitScanReverse(&index, value); return (unsigned)index+1; #else unsigned mask = 1U << ((sizeof(unsigned)*8)-1); unsigned i; for (i=0; i < sizeof(unsigned)*8; i++) { if (value & mask) return sizeof(unsigned)*8-i; mask = mask >> 1; } return 0; #endif }
//Return the number of leading zeros. Deliberately undefined if value == 0 inline unsigned countLeadingUnsetBits(unsigned value) { dbgassertex(value != 0); #if defined(__GNUC__) return __builtin_clz(value); #elif defined (_WIN32) unsigned long index; _BitScanReverse(&index, value); return (unsigned)((sizeof(unsigned)*8)-1 - index); #else unsigned mask = 1U << ((sizeof(unsigned)*8)-1); unsigned i; for (i=0; i < sizeof(unsigned)*8; i++) { if (value & mask) return i; mask = mask >> 1; } return i; #endif }
//Return the number of trailing zeros. Deliberately undefined if value == 0 inline unsigned countTrailingUnsetBits(unsigned value) { dbgassertex(value != 0); #if defined(__GNUC__) return __builtin_ctz(value); #elif defined (_WIN32) unsigned long index; _BitScanForward(&index, value); return (unsigned)index; #else unsigned mask = 1U; unsigned i; for (i=0; i < sizeof(unsigned)*8; i++) { if (value & mask) return i; mask = mask << 1; } return i; #endif }
static bool hasDestructor(const void *ptr) { dbgassertex(ptr); HeapletBase *h = findBase(ptr); return h->_hasDestructor(ptr); }
static void setDestructorFlag(const void *ptr) { dbgassertex(ptr); HeapletBase *h = findBase(ptr); h->_setDestructorFlag(ptr); }
unsigned getRespondingSubChannel() const // NOTE - 0 based { dbgassertex(retries); unsigned bitpos = countTrailingUnsetBits((unsigned) retries); return bitpos / SUBCHANNEL_BITS; }
void CWriteMasterBase::publish() { if (published) return; published = true; if (!(diskHelperBase->getFlags() & (TDXtemporary|TDXjobtemp))) updateActivityResult(container.queryJob().queryWorkUnit(), diskHelperBase->getFlags(), diskHelperBase->getSequence(), fileName, recordsProcessed); IPropertyTree &props = fileDesc->queryProperties(); props.setPropInt64("@recordCount", recordsProcessed); if (0 == (diskHelperBase->getFlags() & TDXtemporary) || container.queryJob().queryUseCheckpoints()) { if (0 != (diskHelperBase->getFlags() & TDWexpires)) setExpiryTime(props, diskHelperBase->getExpiryDays()); if (TDWupdate & diskHelperBase->getFlags()) { unsigned eclCRC; unsigned __int64 totalCRC; diskHelperBase->getUpdateCRCs(eclCRC, totalCRC); props.setPropInt("@eclCRC", eclCRC); props.setPropInt64("@totalCRC", totalCRC); } } container.queryTempHandler()->registerFile(fileName, container.queryOwner().queryGraphId(), diskHelperBase->getTempUsageCount(), TDXtemporary & diskHelperBase->getFlags(), getDiskOutputKind(diskHelperBase->getFlags()), &clusters); if (!dlfn.isExternal()) { bool temporary = 0 != (diskHelperBase->getFlags()&TDXtemporary); if (!temporary && (queryJob().querySlaves() < fileDesc->numParts())) { // create empty parts for a fileDesc being published that is larger than this clusters size32_t recordSize = 0; IOutputMetaData *diskRowMeta = diskHelperBase->queryDiskRecordSize()->querySerializedDiskMeta(); if (diskRowMeta->isFixedSize() && (TAKdiskwrite == container.getKind())) { recordSize = diskRowMeta->getMinRecordSize(); if (0 != (diskHelperBase->getFlags() & TDXgrouped)) recordSize += 1; } unsigned compMethod = COMPRESS_METHOD_LZW; // rowdiff used if recordSize > 0, else fallback to compMethod if (getOptBool(THOROPT_COMP_FORCELZW, false)) { recordSize = 0; // by default if fixed length (recordSize set), row diff compression is used. This forces compMethod. compMethod = COMPRESS_METHOD_LZW; } else if (getOptBool(THOROPT_COMP_FORCEFLZ, false)) compMethod = COMPRESS_METHOD_FASTLZ; else if (getOptBool(THOROPT_COMP_FORCELZ4, false)) compMethod = COMPRESS_METHOD_LZ4; bool blockCompressed; bool compressed = fileDesc->isCompressed(&blockCompressed); for (unsigned clusterIdx=0; clusterIdx<fileDesc->numClusters(); clusterIdx++) { StringBuffer clusterName; fileDesc->getClusterGroupName(clusterIdx, clusterName, &queryNamedGroupStore()); PROGLOG("Creating blank parts for file '%s', cluster '%s'", fileName.get(), clusterName.str()); unsigned p=0; while (p<fileDesc->numParts()) { if (p == targetOffset) p += queryJob().querySlaves(); IPartDescriptor *partDesc = fileDesc->queryPart(p); CDateTime createTime, modifiedTime; for (unsigned c=0; c<partDesc->numCopies(); c++) { RemoteFilename rfn; partDesc->getFilename(c, rfn); StringBuffer path; rfn.getPath(path); try { ensureDirectoryForFile(path.str()); OwnedIFile iFile = createIFile(path.str()); Owned<IFileIO> iFileIO; if (compressed) iFileIO.setown(createCompressedFileWriter(iFile, recordSize, false, true, NULL, compMethod)); else iFileIO.setown(iFile->open(IFOcreate)); dbgassertex(iFileIO.get()); iFileIO.clear(); // ensure copies have matching datestamps, as they would do normally (backupnode expects it) if (partDesc->numCopies() > 1) { if (0 == c) iFile->getTime(&createTime, &modifiedTime, NULL); else iFile->setTime(&createTime, &modifiedTime, NULL); } } catch (IException *e) { if (0 == c) throw; Owned<IThorException> e2 = MakeThorException(e); e->Release(); e2->setAction(tea_warning); queryJob().fireException(e2); } } partDesc->queryProperties().setPropInt64("@size", 0); p++; } clusterIdx++; } } queryThorFileManager().publish(container.queryJob(), fileName, *fileDesc, NULL); } }