Example #1
0
    VarCallbacksAny(const detail::VarCallbacksCFuncPtr<OT, VT> & cbs)
    {
        static_assert(DataSizeBytes >= sizeof(cbs), "Size mismatch!");

        clear();
        callbacks = cbs.clone(getDataPtr());
    }
Example #2
0
void
SimpleSignal::print(FILE * out) const {
    fprintf(out, "---- Signal ----------------\n");
    SignalLoggerManager::printSignalHeader(out, header, 0, 0, false);
    SignalLoggerManager::printSignalData(out, header, getDataPtr());
    for(Uint32 i = 0; i<header.m_noOfSections; i++) {
        Uint32 len = ptr[i].sz;
        fprintf(out, " --- Section %d size=%d ---\n", i, len);
        Uint32 * signalData = ptr[i].p;
        while(len >= 7) {
            fprintf(out,
                    " H\'%.8x H\'%.8x H\'%.8x H\'%.8x H\'%.8x H\'%.8x H\'%.8x\n",
                    signalData[0], signalData[1], signalData[2], signalData[3],
                    signalData[4], signalData[5], signalData[6]);
            len -= 7;
            signalData += 7;
        }
        if(len > 0) {
            fprintf(out, " H\'%.8x", signalData[0]);
            for(Uint32 i = 1; i<len; i++)
                fprintf(out, " H\'%.8x", signalData[i]);
            fprintf(out, "\n");
        }
    }
}
LiteralTypeInstance* VarCharLiteralTypeInstance::makeCopy() const {
  if (isNull()) {
    return new NullLiteralTypeInstance(getType());
  } else {
    return new VarCharLiteralTypeInstance(static_cast<const VarCharType&>(getType()),
                                          static_cast<const char*>(getDataPtr()),
                                          asciiStringMaximumLength());
  }
}
Example #4
0
/****************************************************************************
Desc:	Get a pointer to the UTF8 - no conversions are done.
****************************************************************************/
RCODE XFLAPI F_DataVector::getUTF8Ptr(
	FLMUINT				uiElementNumber,
	const FLMBYTE **	ppszUTF8,
	FLMUINT *			puiBufLen)
{
	RCODE						rc = NE_XFLM_OK;
	F_VECTOR_ELEMENT *	pVector = getVector( uiElementNumber,
												VECT_SLOT_HAS_DATA);
	void *					pvValue;
	FLMUINT					uiStorageLen;
	FLMUINT					uiSenLen;

	if (!pVector)
	{
		*ppszUTF8 = NULL;
		if (puiBufLen)
		{
			*puiBufLen = 0;
		}
		goto Exit;
	}
	if (pVector->uiDataType != XFLM_TEXT_TYPE)
	{
		rc = RC_SET( NE_XFLM_BAD_DATA_TYPE);
		goto Exit;
	}

	if ((pvValue = getDataPtr( pVector)) != NULL)
	{
		*ppszUTF8 = (FLMBYTE *)pvValue;
		uiStorageLen = pVector->uiDataLength;
		if( RC_BAD( rc = flmGetCharCountFromStorageBuf( ppszUTF8,
			uiStorageLen, NULL, &uiSenLen)))
		{
			goto Exit;
		}

		flmAssert( uiStorageLen > uiSenLen);
		uiStorageLen -= uiSenLen;
	}
	else
	{
		*ppszUTF8 = NULL;
		uiStorageLen = 0;
	}

	if (puiBufLen)
	{
		*puiBufLen = uiStorageLen;
	}

Exit:

	return( rc);
}
Example #5
0
void CBaseStar::initialize() {
	_minVal = 9.9999998e10;
	_maxVal = -9.9999998e10;
	_sub4.initialize();

	for (uint idx = 0; idx < _data.size(); ++idx) {
		const CBaseStarEntry *entry = getDataPtr(idx);
		_sub4.checkEntry(entry->_val);

		if (entry->_value < _minVal)
			_minVal = entry->_value;
		if (entry->_value > _maxVal)
			_maxVal = entry->_value;
	}

	_range = (_maxVal - _minVal) / 1.0;
}
Example #6
0
/****************************************************************************
Desc:	Compose a key buffer from the vector's components.
****************************************************************************/
RCODE F_DataVector::outputKey(
	IXD *				pIxd,
	FLMUINT			uiMatchFlags,
	FLMBYTE *		pucKeyBuf,
	FLMUINT			uiKeyBufSize,
	FLMUINT *		puiKeyLen,
	FLMUINT			uiSearchKeyFlag)
{
	RCODE						rc = NE_XFLM_OK;
	ICD *						pIcd;
	FLMBYTE *				pucToKey;
	FLMBYTE *				pucKeyLenPos;
	FLMUINT					uiToKeyLen;
	FLMUINT					uiKeyLen;
	FLMUINT					uiKeyComponent;
	FLMUINT					uiDataComponent;
	FLMUINT					uiContextComponent;
	FLMBOOL					bDataTruncated;
	FLMUINT					uiDataType;
	FLMUINT					uiLanguage;
	F_VECTOR_ELEMENT *	pVector = NULL;
	FLMBYTE					ucIDBuf [256];
	FLMUINT					uiIDLen = 0;
	FLMUINT64				ui64Id;
	FLMUINT					uiMaxKeySize;
	FLMUINT					uiDataLen;
	const FLMBYTE *		pucDataPtr;
	FLMBYTE					ucTmpSen [FLM_MAX_NUM_BUF_SIZE];
	FLMBYTE *				pucTmpSen;
	FLMUINT					uiSenLen;
	FLMUINT					uiIDMatchFlags = uiMatchFlags & (XFLM_MATCH_IDS | XFLM_MATCH_DOC_ID);
	IF_BufferIStream *	pBufferStream = NULL;

	if (uiIDMatchFlags)
	{
		pucToKey = &ucIDBuf [0];
		uiIDLen = 0;
		
		// Put document ID into buffer.  If there is room for at least nine
		// bytes, we can encode the ID right into the buffer safely.  Otherwise,
		// we have to use a temporary buffer and see if there is room.
		
		if (sizeof( ucIDBuf) - uiIDLen >= 9)
		{
			uiIDLen += f_encodeSEN( m_ui64DocumentID, &pucToKey);
		}
		else
		{
			pucTmpSen = &ucTmpSen [0];
			uiSenLen = f_encodeSEN( m_ui64DocumentID, &pucTmpSen);
			if (uiSenLen + uiIDLen > sizeof( ucIDBuf))
			{
				rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW);
				goto Exit;
			}
			f_memcpy( pucToKey, ucTmpSen, uiSenLen);
			uiIDLen += uiSenLen;
			pucToKey += uiSenLen;
		}

		if (uiIDMatchFlags & XFLM_MATCH_IDS)
		{
			// Append the Key component NODE IDs to the key
	
			for (uiKeyComponent = 0;
				  uiKeyComponent < pIxd->uiNumKeyComponents;
				  uiKeyComponent++)
			{
				ui64Id = getID( uiKeyComponent);

				// Put node ID into buffer.  If there is room for at least nine
				// bytes, we can encode the ID right into the buffer safely.  Otherwise,
				// we have to use a temporary buffer and see if there is room.
				
				if (sizeof( ucIDBuf) - uiIDLen >= 9)
				{
					uiIDLen += f_encodeSEN( ui64Id, &pucToKey);
				}
				else
				{
					pucTmpSen = &ucTmpSen [0];
					uiSenLen = f_encodeSEN( ui64Id, &pucTmpSen);
					if (uiSenLen + uiIDLen > sizeof( ucIDBuf))
					{
						rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW);
						goto Exit;
					}
					f_memcpy( pucToKey, ucTmpSen, uiSenLen);
					uiIDLen += uiSenLen;
					pucToKey += uiSenLen;
				}
			}
	
			// Append the Data NODE IDs to the key
	
			for (uiDataComponent = 0;
				  uiDataComponent < pIxd->uiNumDataComponents;
				  uiDataComponent++)
			{
				ui64Id = getID( uiDataComponent +
													pIxd->uiNumKeyComponents);

				// Put node ID into buffer.  If there is room for at least nine
				// bytes, we can encode the ID right into the buffer safely.  Otherwise,
				// we have to use a temporary buffer and see if there is room.
				
				if (sizeof( ucIDBuf) - uiIDLen >= 9)
				{
					uiIDLen += f_encodeSEN( ui64Id, &pucToKey);
				}
				else
				{
					pucTmpSen = &ucTmpSen [0];
					uiSenLen = f_encodeSEN( ui64Id, &pucTmpSen);
					if (uiSenLen + uiIDLen > sizeof( ucIDBuf))
					{
						rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW);
						goto Exit;
					}
					f_memcpy( pucToKey, ucTmpSen, uiSenLen);
					uiIDLen += uiSenLen;
					pucToKey += uiSenLen;
				}
			}
	
			// Append the Context NODE IDs to the key
	
			for (uiContextComponent = 0;
				  uiContextComponent < pIxd->uiNumContextComponents;
				  uiContextComponent++)
			{
				ui64Id = getID( uiContextComponent +
													pIxd->uiNumKeyComponents +
													pIxd->uiNumDataComponents);

				// Put node ID into buffer.  If there is room for at least nine
				// bytes, we can encode the ID right into the buffer safely.  Otherwise,
				// we have to use a temporary buffer and see if there is room.
				
				if (sizeof( ucIDBuf) - uiIDLen >= 9)
				{
					uiIDLen += f_encodeSEN( ui64Id, &pucToKey);
				}
				else
				{
					pucTmpSen = &ucTmpSen [0];
					uiSenLen = f_encodeSEN( ui64Id, &pucTmpSen);
					if (uiSenLen + uiIDLen > sizeof( ucIDBuf))
					{
						rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW);
						goto Exit;
					}
					f_memcpy( pucToKey, ucTmpSen, uiSenLen);
					uiIDLen += uiSenLen;
					pucToKey += uiSenLen;
				}
			}
		}
		
		if (uiIDLen >= uiKeyBufSize)
		{
			rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW);
			goto Exit;
		}
	}

	// Output the key components

	uiMaxKeySize = uiKeyBufSize - uiIDLen;
	uiLanguage = pIxd->uiLanguage;
	uiKeyLen = 0;
	pucToKey = pucKeyBuf;
	pIcd = pIxd->pFirstKey;
	for (uiKeyComponent = 0;;pIcd = pIcd->pNextKeyComponent, uiKeyComponent++)
	{
		pucKeyLenPos = pucToKey;
		pucToKey += 2;
		uiKeyLen += 2;
		
		uiDataType = icdGetDataType( pIcd);

		// Find matching node in the tree - if not found skip and continue.

		if ((pVector = getVector( uiKeyComponent, VECT_SLOT_HAS_DATA)) == NULL)
		{
			UW2FBA( 0, pucKeyLenPos);
		}
		else
		{
			uiToKeyLen = 0;
			bDataTruncated = FALSE;

			// Take the dictionary number and make it the key

			if (pIcd->uiFlags & ICD_PRESENCE)
			{
				FLMUINT	uiNum;

				// Component better be a number - and better match the
				// tag number of the ICD

				if (RC_BAD( rc = getUINT( uiKeyComponent, &uiNum)))
				{
					goto Exit;
				}
				
				flmAssert( uiNum == pIcd->uiDictNum || pIcd->uiDictNum == ELM_ROOT_TAG);

        		// Output the tag number

				if (uiKeyLen + 4 > uiMaxKeySize)
				{
					rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW);
					goto Exit;
				}
				
				f_UINT32ToBigEndian( (FLMUINT32)uiNum, pucToKey);
				uiToKeyLen = 4;
			}
			else if (pIcd->uiFlags & ICD_METAPHONE)
			{
				FLMUINT					uiMeta;
				FLMBYTE					ucStorageBuf[ FLM_MAX_NUM_BUF_SIZE];
				FLMUINT					uiStorageLen;

				if (uiDataType != XFLM_TEXT_TYPE)
				{
					rc = RC_SET_AND_ASSERT( NE_XFLM_SYNTAX);
					goto Exit;
				}
				
				if (pVector->uiDataType == XFLM_TEXT_TYPE)
				{
					if (RC_BAD( rc = getUTF8Ptr( uiKeyComponent,
											&pucDataPtr, &uiDataLen)))
					{
						goto Exit;
					}
					
					if( !pBufferStream)
					{
						if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferStream)))
						{
							goto Exit;
						}
					}
	
					if (RC_BAD( rc = pBufferStream->openStream( 
						(const char *)pucDataPtr, uiDataLen)))
					{
						goto Exit;
					}
	
					if (RC_BAD( rc = f_getNextMetaphone( pBufferStream, &uiMeta)))
					{
						if( rc == NE_XFLM_EOF_HIT)
						{
							rc = RC_SET( NE_XFLM_SYNTAX);
						}
						goto Exit;
					}
	
					pBufferStream->closeStream();
				}
				else if (pVector->uiDataType == XFLM_NUMBER_TYPE)
				{
					if( RC_BAD( rc = getUINT( uiKeyComponent, &uiMeta)))
					{
						goto Exit;
					}
				}
				else
				{
					rc = RC_SET_AND_ASSERT( NE_XFLM_SYNTAX);
					goto Exit;
				}

				if ( uiMeta)
				{
					uiStorageLen = FLM_MAX_NUM_BUF_SIZE;
					if( RC_BAD( rc = flmNumber64ToStorage( uiMeta,
						&uiStorageLen, ucStorageBuf, FALSE, FALSE)))
					{
						goto Exit;
					}

					if( !pBufferStream)
					{
						if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferStream)))
						{
							goto Exit;
						}
					}
					
					if (RC_BAD( rc = pBufferStream->openStream( 
						(const char *)ucStorageBuf, uiStorageLen)))
					{
						goto Exit;
					}

        			// Output the metaphone key piece

					uiToKeyLen = uiMaxKeySize - uiKeyLen;
					if( RC_BAD( rc = KYCollateValue( pucToKey, &uiToKeyLen,
						pBufferStream, XFLM_NUMBER_TYPE,
						pIcd->uiFlags, pIcd->uiCompareRules, pIcd->uiLimit,
						NULL, NULL, uiLanguage,
						FALSE, FALSE, &bDataTruncated, NULL)))
					{
						goto Exit;
					}
					
					pBufferStream->closeStream();
				}
			}
			else
			{
				if (uiDataType == XFLM_TEXT_TYPE)
				{
					if (RC_BAD( rc = getUTF8Ptr( uiKeyComponent,
											&pucDataPtr, &uiDataLen)))
					{
						goto Exit;
					}
				}
				else
				{
					pucDataPtr = (FLMBYTE *)getDataPtr( pVector);
					uiDataLen = pVector->uiDataLength;
				}
				
				if (uiDataLen)
				{
					if( !pBufferStream)
					{
						if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferStream)))
						{
							goto Exit;
						}
					}
					
					if (RC_BAD( rc = pBufferStream->openStream( 
						(const char *)pucDataPtr, uiDataLen)))
					{
						goto Exit;
					}

					uiToKeyLen = uiMaxKeySize - uiKeyLen;
					if( RC_BAD( rc = KYCollateValue( pucToKey, &uiToKeyLen,
						pBufferStream, uiDataType,
						pIcd->uiFlags, pIcd->uiCompareRules, pIcd->uiLimit,
						NULL, NULL, uiLanguage,
						(FLMBOOL) ((pIcd->uiFlags & ICD_SUBSTRING)
								? (isLeftTruncated( pVector)
									? FALSE : TRUE)
								: FALSE),
						isRightTruncated( pVector),
						&bDataTruncated, NULL)))
					{
						goto Exit;
					}
					
					pBufferStream->closeStream();					
				}
			}

			if (uiToKeyLen)
			{

				//	Increment total key length

				pucToKey += uiToKeyLen;
				uiKeyLen += uiToKeyLen;
			}
			if (!bDataTruncated)
			{
				UW2FBA( (FLMUINT16)(uiToKeyLen | uiSearchKeyFlag),
									pucKeyLenPos);
			}
			else
			{
				UW2FBA( (FLMUINT16)(uiToKeyLen | TRUNCATED_FLAG |
									uiSearchKeyFlag), pucKeyLenPos); 
			}
		}

		// Check if done.

		if (!pIcd->pNextKeyComponent)
		{
   	 	break;
		}
	}
	
	// Output the node IDs, if requested.

	if (uiIDMatchFlags)
	{

		// There will always be room at this point for the
		// IDs - because it was subtracted out above.

		f_memcpy( pucToKey, ucIDBuf, uiIDLen);
	}
	*puiKeyLen = uiKeyLen + uiIDLen;

Exit:

	if( pBufferStream)
	{
		pBufferStream->Release();
		pBufferStream = NULL;
	}

	return( rc);
}
Example #7
0
/****************************************************************************
Desc:	Compose a data buffer from the vector's components.
****************************************************************************/
RCODE F_DataVector::outputData(
	IXD *			pIxd,
	FLMBYTE *	pucDataBuf,
	FLMUINT		uiDataBufSize,
	FLMUINT *	puiDataLen)
{
	RCODE						rc = NE_XFLM_OK;
	ICD *						pIcd = pIxd->pFirstData;
	FLMUINT					uiDataComponent = 0;
	F_VECTOR_ELEMENT *	pVector;
	FLMBYTE *				pucData;
	FLMUINT					uiDataLength;
	FLMUINT					uiTotalLength = 0;
	FLMBYTE					ucTmpSen [32];
	FLMBYTE *				pucTmpSen = &ucTmpSen [0];
	FLMUINT					uiSENLen;
	FLMUINT					uiLastDataLen = 0;

	while (pIcd)
	{
		if ((pVector = getVector( uiDataComponent + pIxd->uiNumKeyComponents,
											VECT_SLOT_HAS_DATA)) != NULL)
		{

			// Cannot do data conversions right now.

			flmAssert( pVector->uiDataType == icdGetDataType( pIcd));
			uiDataLength = pVector->uiDataLength;
			pucData = (FLMBYTE *)getDataPtr( pVector);
		}
		else
		{
			uiDataLength = 0;
			pucData = NULL;
		}

		// Output the length of the data as a SEN value

		uiSENLen = f_encodeSEN( uiDataLength, &pucTmpSen);
		if (uiTotalLength + uiSENLen > uiDataBufSize)
		{
			rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW);
			goto Exit;
		}
		f_memcpy( pucDataBuf, ucTmpSen, uiSENLen);
		pucDataBuf += uiSENLen;
		uiTotalLength += uiSENLen;

		// Output the data

		if (uiDataLength)
		{
			if (uiTotalLength + uiDataLength > uiDataBufSize)
			{
				rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW);
				goto Exit;
			}
			f_memcpy( pucDataBuf, pucData, uiDataLength);
			pucDataBuf += uiDataLength;
			uiTotalLength += uiDataLength;
			uiLastDataLen = uiTotalLength;
		}
		pIcd = pIcd->pNextDataComponent;
		uiDataComponent++;
	}

Exit:

	// Even if rc == NE_XFLM_CONV_DEST_OVERFLOW, return a length

	*puiDataLen = uiLastDataLen;

	return( rc);
}
Example #8
0
 Uint32 getFragmentId() const { 
   return (m_fragmentInfo == 0 ? 0 : getDataPtr()[theLength - 1]); 
 }
Example #9
0
/**********************************************************************
Uint32 readData(Uint32 aDataNo);

Return Value:   Return Data word in a signal.
                Return -1: In all other case.
                aDataNo: Data number in signal.
Remark:         Return the dataWord information in a signal for a dataNo.  
******************************************************************************/
inline
Uint32
NdbApiSignal::readData(Uint32 aDataNo) const {
  return getDataPtr()[aDataNo-1];
}
Example #10
0
const CBaseStarEntry *CStarField::getStar(int index) const {
	return (index < 0 || index >= (int)_data.size()) ? nullptr : getDataPtr(index);
}
Example #11
0
const CBaseStarEntry *CStarField::getRandomStar() const {
	if (_data.empty())
		return nullptr;

	return getDataPtr(g_vm->getRandomNumber(_data.size() - 1));
}