mariadb/storage/ndb/include/kernel/AttributeHeader.hpp

244 lines
5.7 KiB
C++
Raw Normal View History

/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef ATTRIBUTE_HEADER
#define ATTRIBUTE_HEADER
/**
* @class AttributeHeader
* @brief Header passed in front of every attribute value in AttrInfo signal
*/
class AttributeHeader {
friend class Dbtup;
friend class Backup;
friend class NdbOperation;
friend class DbUtil;
friend class Suma;
public:
/**
2005-07-18 13:31:02 +02:00
* Pseudo columns
*/
2005-07-18 13:31:02 +02:00
STATIC_CONST( PSEUDO = 0x8000 );
STATIC_CONST( FRAGMENT = 0xFFFE ); // Read fragment no
STATIC_CONST( ROW_COUNT = 0xFFFD ); // Read row count (committed)
STATIC_CONST( COMMIT_COUNT = 0xFFFC ); // Read commit count
STATIC_CONST( RANGE_NO = 0xFFFB ); // Read range no (when batched ranges)
STATIC_CONST( ROW_SIZE = 0xFFFA );
STATIC_CONST( FRAGMENT_MEMORY= 0xFFF9 );
ndb - wl#2624 re-commit due to bk problem mysql-test/r/ndb_basic.result: wl#2624 re-commit due to bk problem mysql-test/r/ndb_blob.result: wl#2624 re-commit due to bk problem mysql-test/r/ndb_charset.result: wl#2624 re-commit due to bk problem mysql-test/r/ndb_condition_pushdown.result: wl#2624 re-commit due to bk problem mysql-test/r/ndb_index_ordered.result: wl#2624 re-commit due to bk problem mysql-test/t/ndb_index_ordered.test: wl#2624 re-commit due to bk problem sql/ha_ndbcluster.cc: wl#2624 re-commit due to bk problem sql/ha_ndbcluster.h: wl#2624 re-commit due to bk problem sql/mysqld.cc: wl#2624 re-commit due to bk problem sql/set_var.cc: wl#2624 re-commit due to bk problem sql/sql_class.h: wl#2624 re-commit due to bk problem storage/ndb/include/kernel/AttributeHeader.hpp: wl#2624 re-commit due to bk problem storage/ndb/include/ndbapi/NdbDictionary.hpp: wl#2624 re-commit due to bk problem storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtux/Makefile.am: wl#2624 re-commit due to bk problem storage/ndb/src/ndbapi/Makefile.am: wl#2624 re-commit due to bk problem storage/ndb/src/ndbapi/NdbDictionary.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/ndbapi/NdbScanOperation.cpp: wl#2624 re-commit due to bk problem
2005-09-15 02:33:28 +02:00
STATIC_CONST( RECORDS_IN_RANGE = 0xFFF8 );
Import ndb varsize BitKeeper/deleted/.del-MetaData.cpp~146ae9865dd35829: Delete: storage/ndb/src/kernel/vm/MetaData.cpp BitKeeper/deleted/.del-MetaData.hpp~538342afcd8ac53c: Delete: storage/ndb/src/kernel/vm/MetaData.hpp BitKeeper/deleted/.del-DbtupLCP.cpp~855b1ed3fbc86a42: Delete: storage/ndb/src/kernel/blocks/dbtup/DbtupLCP.cpp BitKeeper/deleted/.del-DbtupSystemRestart.cpp~15b54d7e4e75d2d: Delete: storage/ndb/src/kernel/blocks/dbtup/DbtupSystemRestart.cpp BitKeeper/deleted/.del-DbtupUndoLog.cpp~5a2ef6e86b1404e9: Delete: storage/ndb/src/kernel/blocks/dbtup/DbtupUndoLog.cpp storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp'' storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp'' storage/ndb/include/kernel/signaldata/CreateObj.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/CreateObj.hpp'' storage/ndb/include/kernel/signaldata/DictObjOp.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/DictObjOp.hpp'' storage/ndb/include/kernel/signaldata/DropFilegroup.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/DropFilegroup.hpp'' storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp'' storage/ndb/include/kernel/signaldata/DropObj.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/DropObj.hpp'' storage/ndb/include/kernel/signaldata/Extent.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/Extent.hpp'' storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp'' storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp'' storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp'' storage/ndb/include/kernel/signaldata/RestoreImpl.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/RestoreImpl.hpp'' storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp: New BitKeeper file ``storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp'' storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp'' storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp'' storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp'' storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp'' storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp'' storage/ndb/src/kernel/blocks/dbtup/test_varpage.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/test_varpage.cpp'' storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp'' storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp'' storage/ndb/src/kernel/blocks/diskpage.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/diskpage.cpp'' storage/ndb/src/kernel/blocks/diskpage.hpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/diskpage.hpp'' storage/ndb/src/kernel/blocks/lgman.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/lgman.cpp'' storage/ndb/src/kernel/blocks/lgman.hpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/lgman.hpp'' storage/ndb/src/kernel/blocks/pgman.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/pgman.cpp'' storage/ndb/src/kernel/blocks/pgman.hpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/pgman.hpp'' storage/ndb/src/kernel/blocks/print_file.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/print_file.cpp'' storage/ndb/src/kernel/blocks/restore.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/restore.cpp'' storage/ndb/src/kernel/blocks/restore.hpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/restore.hpp'' storage/ndb/src/kernel/blocks/tsman.cpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/tsman.cpp'' storage/ndb/src/kernel/blocks/tsman.hpp: New BitKeeper file ``storage/ndb/src/kernel/blocks/tsman.hpp'' storage/ndb/src/kernel/vm/DLCFifoList.hpp: New BitKeeper file ``storage/ndb/src/kernel/vm/DLCFifoList.hpp'' storage/ndb/src/kernel/vm/DLCHashTable.hpp: New BitKeeper file ``storage/ndb/src/kernel/vm/DLCHashTable.hpp'' storage/ndb/src/kernel/vm/KeyTable2Ref.hpp: New BitKeeper file ``storage/ndb/src/kernel/vm/KeyTable2Ref.hpp'' storage/ndb/src/kernel/vm/Rope.cpp: New BitKeeper file ``storage/ndb/src/kernel/vm/Rope.cpp'' storage/ndb/src/kernel/vm/Rope.hpp: New BitKeeper file ``storage/ndb/src/kernel/vm/Rope.hpp''
2005-11-07 12:19:28 +01:00
STATIC_CONST( DISK_REF = 0xFFF7 );
STATIC_CONST( ROWID = 0xFFF6 );
STATIC_CONST( ROW_GCI = 0xFFF5 );
ndb - wl#2624 re-commit due to bk problem mysql-test/r/ndb_basic.result: wl#2624 re-commit due to bk problem mysql-test/r/ndb_blob.result: wl#2624 re-commit due to bk problem mysql-test/r/ndb_charset.result: wl#2624 re-commit due to bk problem mysql-test/r/ndb_condition_pushdown.result: wl#2624 re-commit due to bk problem mysql-test/r/ndb_index_ordered.result: wl#2624 re-commit due to bk problem mysql-test/t/ndb_index_ordered.test: wl#2624 re-commit due to bk problem sql/ha_ndbcluster.cc: wl#2624 re-commit due to bk problem sql/ha_ndbcluster.h: wl#2624 re-commit due to bk problem sql/mysqld.cc: wl#2624 re-commit due to bk problem sql/set_var.cc: wl#2624 re-commit due to bk problem sql/sql_class.h: wl#2624 re-commit due to bk problem storage/ndb/include/kernel/AttributeHeader.hpp: wl#2624 re-commit due to bk problem storage/ndb/include/ndbapi/NdbDictionary.hpp: wl#2624 re-commit due to bk problem storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/kernel/blocks/dbtux/Makefile.am: wl#2624 re-commit due to bk problem storage/ndb/src/ndbapi/Makefile.am: wl#2624 re-commit due to bk problem storage/ndb/src/ndbapi/NdbDictionary.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: wl#2624 re-commit due to bk problem storage/ndb/src/ndbapi/NdbScanOperation.cpp: wl#2624 re-commit due to bk problem
2005-09-15 02:33:28 +02:00
// NOTE: in 5.1 ctors and init take size in bytes
/** Initialize AttributeHeader at location aHeaderPtr */
static AttributeHeader& init(void* aHeaderPtr, Uint32 anAttributeId,
Uint32 aByteSize);
/** Returns size of AttributeHeader (usually one or two words) */
Uint32 getHeaderSize() const; // In 32-bit words
/** Store AttributeHeader in location given as argument */
void insertHeader(Uint32*);
/** Get next attribute header (if there is one) */
AttributeHeader* getNext() const;
/** Get location of attribute value */
Uint32* getDataPtr() const;
/** Getters and Setters */
Uint32 getAttributeId() const;
void setAttributeId(Uint32);
Uint32 getByteSize() const;
void setByteSize(Uint32);
Uint32 getDataSize() const; // In 32-bit words, rounded up
void setDataSize(Uint32); // Set size to multiple of word size
bool isNULL() const;
void setNULL();
/** Print **/
//void print(NdbOut&);
void print(FILE*);
static Uint32 getByteSize(Uint32);
static Uint32 getDataSize(Uint32);
public:
AttributeHeader(Uint32 = 0);
AttributeHeader(Uint32 anAttributeId, Uint32 aByteSize);
~AttributeHeader();
Uint32 m_value;
};
/**
* 1111111111222222222233
* 01234567890123456789012345678901
* ssssssssssssssssiiiiiiiiiiiiiiii
*
* i = Attribute Id
* s = Size of current "chunk" in bytes - 16 bits.
* To allow round up to word, max value is 0xFFFC (not checked).
* e - [ obsolete future ]
* Element data/Blob, read element of array
* If == 0 next data word contains attribute value.
* If == 1 next data word contains:
* For Array of Fixed size Elements
* Start Index (16 bit), Stop Index(16 bit)
* For Blob
* Start offset (32 bit) (length is defined in previous word)
*
* An attribute value equal to "null" is represented by setting s == 0.
*/
inline
AttributeHeader& AttributeHeader::init(void* aHeaderPtr, Uint32 anAttributeId,
Uint32 aByteSize)
{
return * new (aHeaderPtr) AttributeHeader(anAttributeId, aByteSize);
}
inline
AttributeHeader::AttributeHeader(Uint32 aHeader)
{
m_value = aHeader;
}
inline
AttributeHeader::AttributeHeader(Uint32 anAttributeId, Uint32 aByteSize)
{
m_value = 0;
this->setAttributeId(anAttributeId);
this->setByteSize(aByteSize);
}
inline
AttributeHeader::~AttributeHeader()
{}
inline
Uint32 AttributeHeader::getHeaderSize() const
{
// Should check 'e' bit here
return 1;
}
inline
Uint32 AttributeHeader::getAttributeId() const
{
return (m_value & 0xFFFF0000) >> 16;
}
inline
void AttributeHeader::setAttributeId(Uint32 anAttributeId)
{
m_value &= 0x0000FFFF; // Clear attribute id
m_value |= (anAttributeId << 16);
}
inline
Uint32 AttributeHeader::getByteSize() const
{
return (m_value & 0xFFFF);
}
inline
void AttributeHeader::setByteSize(Uint32 aByteSize)
{
m_value &= (~0xFFFF);
m_value |= aByteSize;
}
inline
Uint32 AttributeHeader::getDataSize() const
{
return (((m_value & 0xFFFF) + 3) >> 2);
}
inline
void AttributeHeader::setDataSize(Uint32 aDataSize)
{
m_value &= (~0xFFFF);
m_value |= (aDataSize << 2);
}
inline
bool AttributeHeader::isNULL() const
{
return (getDataSize() == 0);
}
inline
void AttributeHeader::setNULL()
{
setDataSize(0);
}
inline
Uint32* AttributeHeader::getDataPtr() const
{
return (Uint32*)&m_value + getHeaderSize();
}
inline
void AttributeHeader::insertHeader(Uint32* target)
{
*target = m_value;
}
inline
AttributeHeader*
AttributeHeader::getNext() const {
return (AttributeHeader*)(getDataPtr() + getDataSize());
}
inline
void
//AttributeHeader::print(NdbOut& output) {
AttributeHeader::print(FILE* output) {
fprintf(output, "AttributeId: H\'%.8x (D\'%d), DataSize: H\'%.8x (D\'%d), "
"isNULL: %d\n",
getAttributeId(), getAttributeId(),
getDataSize(), getDataSize(),
isNULL());
}
inline
Uint32
AttributeHeader::getByteSize(Uint32 m_value){
return (m_value & 0xFFFF);
}
inline
Uint32
AttributeHeader::getDataSize(Uint32 m_value){
return (((m_value & 0xFFFF) + 3) >> 2);
}
#endif