Appends next record to this index builder and returns this.

@param recordSize size of record measured in bytes
@return this
167542
public FileIndexBuilder appendNextRecord(long recordSize) {
        checkIfDestroyed();
        if (recordSize < 0)
            throw new IllegalArgumentException("Size cannot be negative.");
        if (currentRecord == step) {
            index.add(startingByte + currentByte);
            currentRecord = 0;
        }
        currentByte += recordSize;
        ++currentRecord;
        return this;
    }
374439
public boolean setPageSize(Rectangle pageSize) {
        if (writer != null && writer.isPaused()) {
            return false;
        }
        nextPageSize = new Rectangle(pageSize);
        return true;
    }
614581
public Clob createNewClob(int blockSize) throws PersistException {
        StoredLob lob = mLobStorage.prepare();
        lob.setLocator(mLocatorSequence.nextLongValue());
        lob.setBlockSize(blockSize);
        lob.setLength(0);
        lob.insert();
        return new ClobImpl(lob.getLocator());
    }
1230391
public function setPageSize($pageSize)
    {
        $formattedPageSize = ucfirst(strtolower($pageSize));

        $this->checkPageSize($formattedPageSize);

        $this->pageSize = $formattedPageSize;

        return $this;
    }
1065870
public Object add(Object data, int iOpenMode) throws DBException, RemoteException
    {
        Object key = this.getKey(data);
        if (key == null)
        {   // If autosequence, bump key
            try   {
                key = m_mDataMap.lastKey();
            } catch (NoSuchElementException ex)   {
                key = new Integer(0);
            }
            if (key instanceof Integer)   // Always
                key = new Integer(((Integer)key).intValue() + 1);
            ((Vector)data).set(0, key);
        }
        if (m_mDataMap.get(key) != null)
            throw new DBException("Duplicate record");
        m_mDataMap.put(key, data);
        m_objCurrentKey = null;
        m_iterator = null;
        
        return key;
    }
633982
public void add(Rec fieldList) throws DBException
    {
        if (this.getBaseRecord() == fieldList)    // If so, set the correct record for write
            fieldList = this.moveToCurrentRecord((Record)fieldList);   // Hopefully, they supplied a default record type and this will switch it.
        if (fieldList == null)
            throw new DBException("Unknown shared record type");
        if (fieldList == this.getBaseRecord())
            super.add(fieldList);
        else
        {
            this.getBaseRecord().matchListeners((Record)fieldList, false, true, true, true, true);      // Clone the listeners that are not there already.
            fieldList.getTable().add(fieldList);
        }
    }
270848
protected void resizeBuckets (int newsize)
    {
        Record<V>[] oldbuckets = _buckets;
        _buckets = createBuckets(newsize);

        // we shuffle the records around without allocating new ones
        int index = oldbuckets.length;
        while (index-- > 0) {
            Record<V> oldrec = oldbuckets[index];
            while (oldrec != null) {
                Record<V> newrec = oldrec;
                oldrec = oldrec.next;

                // always put the newrec at the start of a chain
                int newdex = keyToIndex(newrec.key);
                newrec.next = _buckets[newdex];
                _buckets[newdex] = newrec;
            }
        }
    }
1164854
public final Record makeReferenceRecord()
    {
        if (m_recordReference != null)
            return m_recordReference;       // It already exists
        RecordOwner recordOwner = null;
        if (this.getRecord() != null)
            recordOwner = Record.findRecordOwner(this.getRecord());    // This way the record has access to the correct environment.
        this.setReferenceRecord(this.makeReferenceRecord(recordOwner));
        return m_recordReference;
    }
824674
public DirRecord nextRecord() throws NamingException {
    if (inp == null) {
      if (in == null) {
        throw new NamingException("No ldif input stream");
      }

      inp = new LdifRecord.Input();
      inp.init(new InputStreamReader(in));
    } else if (inp.eof) {
      return null;
    }

    LdifRecord ldr = new LdifRecord();

    if (!ldr.read(inp)) {
      return null;
    }

    return ldr;
  }
768401
@SuppressWarnings("unchecked")
	public long addRecord(T record) throws IOException {

		if (recordsOutFile == null) {
			
			if (closed) {
				throw new IllegalStateException("The large record handler has been closed.");
			}
			if (recordsReader != null) {
				throw new IllegalStateException("The handler has already switched to sorting.");
			}
			
			LOG.debug("Initializing the large record spilling...");
			
			// initialize the utilities
			{
				final TypeComparator<?>[] keyComps = comparator.getFlatComparators();
				numKeyFields = keyComps.length;
				Object[] keyHolder = new Object[numKeyFields];
				
				comparator.extractKeys(record, keyHolder, 0);
				
				TypeSerializer<?>[] keySers = new TypeSerializer<?>[numKeyFields];
				TypeSerializer<?>[] tupleSers = new TypeSerializer<?>[numKeyFields + 1];
				
				int[] keyPos = new int[numKeyFields];
				
				for (int i = 0; i < numKeyFields; i++) {
					keyPos[i] = i;
					keySers[i] = createSerializer(keyHolder[i], i);
					tupleSers[i] = keySers[i];
				}
				// add the long serializer for the offset
				tupleSers[numKeyFields] = LongSerializer.INSTANCE;
				
				keySerializer = new TupleSerializer<Tuple>((Class<Tuple>) Tuple.getTupleClass(numKeyFields+1), tupleSers);
				keyComparator = new TupleComparator<Tuple>(keyPos, keyComps, keySers);
				
				keySerializerFactory = new RuntimeSerializerFactory<Tuple>(keySerializer, keySerializer.getTupleClass());

				keyTuple = keySerializer.createInstance();
			}
			
			// initialize the spilling
			final int totalNumSegments = memory.size();
			final int segmentsForKeys = (totalNumSegments >= 2*MAX_SEGMENTS_FOR_KEY_SPILLING) ? MAX_SEGMENTS_FOR_KEY_SPILLING : 
				Math.max(MIN_SEGMENTS_FOR_KEY_SPILLING, totalNumSegments - MAX_SEGMENTS_FOR_KEY_SPILLING);
				
			List<MemorySegment> recordsMemory = new ArrayList<MemorySegment>();
			List<MemorySegment> keysMemory = new ArrayList<MemorySegment>();
			
			for (int i = 0; i < segmentsForKeys; i++) {
				keysMemory.add(memory.get(i));
			}
			for (int i = segmentsForKeys; i < totalNumSegments; i++) {
				recordsMemory.add(memory.get(i));
			}
			
			recordsChannel = ioManager.createChannel();
			keysChannel = ioManager.createChannel();
			
			recordsOutFile = new FileChannelOutputView(
					ioManager.createBlockChannelWriter(recordsChannel), memManager,
					recordsMemory, memManager.getPageSize());
			
			keysOutFile = new FileChannelOutputView(
					ioManager.createBlockChannelWriter(keysChannel), memManager,
					keysMemory, memManager.getPageSize());
		}
		
		final long offset = recordsOutFile.getWriteOffset();
		if (offset < 0) {
			throw new RuntimeException("wrong offset");
		}
		
		Object[] keyHolder = new Object[numKeyFields];
		
		comparator.extractKeys(record, keyHolder, 0);
		for (int i = 0; i < numKeyFields; i++) {
			keyTuple.setField(keyHolder[i], i);
		}
		keyTuple.setField(offset, numKeyFields);
		
		keySerializer.serialize(keyTuple, keysOutFile);
		serializer.serialize(record, recordsOutFile);
		
		recordCounter++;
		
		return offset;
	}
1204385
public Record moveTableQuery(int iRelPosition) throws DBException
    {
        BaseTable table = null;
        Record record = null;
        Record recordLeft = null;
        boolean bFirstTime = true;
        for (Enumeration<TableLink> e = m_LinkageList.elements() ; e.hasMoreElements() ;)
        {
            TableLink tableLink = e.nextElement();
            table = tableLink.getLeftRecord().getTable();
            if (bFirstTime)
            {   // First time through - far left table!
                recordLeft = record = (Record)table.move(iRelPosition);
                if (record == null)
                    break;
            }
            table = tableLink.getRightRecord().getTable();
            record = table.getRecord();
            record.addNew();
            tableLink.moveDataRight();  // Fill the right table with key
            boolean bFound = record.seek("=");
            if (!bFound)
            {
                if (tableLink.getJoinType() == DBConstants.LEFT_OUTER)  // DBConstants.LEFT_INNER)
                    record.initRecord(DBConstants.DISPLAY);
                else
                {   // Skip this record **NOT TESTED**
                    if ((iRelPosition > 0) || (iRelPosition == DBConstants.FIRST_RECORD))
                        return this.moveTableQuery(+1);
                    return this.moveTableQuery(-1);
                }
            }
            bFirstTime = false;
        }
        // Sync the mode
        if (recordLeft != null)
        {   // Special test for local criteria
            if ((this.handleLocalCriteria(null, false, null) == false)
                || (this.handleRemoteCriteria(null, false, null) == false))
            { // This record didn't pass the test, get the next one that matches
                if ((iRelPosition > 0) || (iRelPosition == DBConstants.FIRST_RECORD))
                    return this.moveTableQuery(+1);
                return this.moveTableQuery(-1);
            }
            this.setEditMode(recordLeft.getEditMode());
        }
        else
            this.setEditMode(DBConstants.END_OF_FILE);
        return recordLeft;
    }
1337203
public Blob createNewBlob(int blockSize) throws PersistException {
        StoredLob lob = mLobStorage.prepare();
        lob.setLocator(mLocatorSequence.nextLongValue());
        lob.setBlockSize(blockSize);
        lob.setLength(0);
        lob.insert();
        return new BlobImpl(lob.getLocator());
    }
1084149
public EntryBuffer append(Entry entry) {
    int offset = offset(entry.getIndex());
    Entry oldEntry = buffer[offset];
    buffer[offset] = entry.acquire();
    if (oldEntry != null) {
      oldEntry.release();
    }
    return this;
  }
785609
@Override
	public void insert(T record) throws IOException {
		if (closed) {
			return;
		}

		final int hashCode = MathUtils.jenkinsHash(buildSideComparator.hash(record));
		final int bucket = hashCode & numBucketsMask;
		final int bucketSegmentIndex = bucket >>> numBucketsPerSegmentBits; // which segment contains the bucket
		final MemorySegment bucketSegment = bucketSegments[bucketSegmentIndex];
		final int bucketOffset = (bucket & numBucketsPerSegmentMask) << bucketSizeBits; // offset of the bucket in the segment
		final long firstPointer = bucketSegment.getLong(bucketOffset);

		try {
			final long newFirstPointer = recordArea.appendPointerAndRecord(firstPointer, record);
			bucketSegment.putLong(bucketOffset, newFirstPointer);
		} catch (EOFException ex) {
			compactOrThrow();
			insert(record);
			return;
		}

		numElements++;
		resizeTableIfNecessary();
	}
242255
public void insertOrReplaceRecord(T record, T tempHolder) throws IOException {
		final int searchHashCode = hash(this.buildSideComparator.hash(record));
		final int posHashCode = searchHashCode % this.numBuckets;
		
		// get the bucket for the given hash code
		MemorySegment originalBucket = this.buckets[posHashCode >> this.bucketsPerSegmentBits];
		int originalBucketOffset = (posHashCode & this.bucketsPerSegmentMask) << NUM_INTRA_BUCKET_BITS;
		MemorySegment bucket = originalBucket;
		int bucketInSegmentOffset = originalBucketOffset;
		
		// get the basic characteristics of the bucket
		final int partitionNumber = bucket.get(bucketInSegmentOffset + HEADER_PARTITION_OFFSET);
		final InMemoryPartition<T> partition = this.partitions.get(partitionNumber);
		final MemorySegment[] overflowSegments = partition.overflowSegments;
		
		this.buildSideComparator.setReference(record);
		
		int countInSegment = bucket.getInt(bucketInSegmentOffset + HEADER_COUNT_OFFSET);
		int numInSegment = 0;
		int posInSegment = bucketInSegmentOffset + BUCKET_HEADER_LENGTH;
		
		long currentForwardPointer = BUCKET_FORWARD_POINTER_NOT_SET;

		// loop over all segments that are involved in the bucket (original bucket plus overflow buckets)
		while (true) {
			
			while (numInSegment < countInSegment) {
				
				final int thisCode = bucket.getInt(posInSegment);
				posInSegment += HASH_CODE_LEN;
					
				// check if the hash code matches
				if (thisCode == searchHashCode) {
					// get the pointer to the pair
					final int pointerOffset = bucketInSegmentOffset + BUCKET_POINTER_START_OFFSET + (numInSegment * POINTER_LEN);
					final long pointer = bucket.getLong(pointerOffset);
					numInSegment++;
					
					// deserialize the key to check whether it is really equal, or whether we had only a hash collision
					try {
						partition.readRecordAt(pointer, tempHolder);
						if (this.buildSideComparator.equalToReference(tempHolder)) {
							long newPointer = partition.appendRecord(record);
							bucket.putLong(pointerOffset, newPointer);
							partition.setCompaction(false);
							if((newPointer >> this.pageSizeInBits) > this.compactionMemory.getBlockCount()) {
								this.compactionMemory.allocateSegments((int)(newPointer >> this.pageSizeInBits));
							}
							return;
						}
					} catch (EOFException e) {
						// system is out of memory so we attempt to reclaim memory with a copy compact run
						long newPointer;
						try {
							compactPartition(partition.getPartitionNumber());
							// retry append
							newPointer = this.partitions.get(partitionNumber).appendRecord(record);
						} catch (EOFException ex) {
							throw new RuntimeException("Memory ran out. Compaction failed. numPartitions: " + this.partitions.size() + 
									" minPartition: " + getMinPartition() +
									" maxPartition: " + getMaxPartition() +
									" bucketSize: " + this.buckets.length +
									" Message: " + ex.getMessage());
						} catch (IndexOutOfBoundsException ex) {
							throw new RuntimeException("Memory ran out. Compaction failed. numPartitions: " + this.partitions.size() + 
									" minPartition: " + getMinPartition() +
									" maxPartition: " + getMaxPartition() +
									" bucketSize: " + this.buckets.length +
									" Message: " + ex.getMessage());
						}
						bucket.putLong(pointerOffset, newPointer);
						return;
					} catch (IndexOutOfBoundsException e) {
						// system is out of memory so we attempt to reclaim memory with a copy compact run
						long newPointer;
						try {
							compactPartition(partition.getPartitionNumber());
							// retry append
							newPointer = this.partitions.get(partitionNumber).appendRecord(record);
						} catch (EOFException ex) {
							throw new RuntimeException("Memory ran out. Compaction failed. numPartitions: " + this.partitions.size() + 
									" minPartition: " + getMinPartition() +
									" maxPartition: " + getMaxPartition() +
									" bucketSize: " + this.buckets.length +
									" Message: " + ex.getMessage());
						} catch (IndexOutOfBoundsException ex) {
							throw new RuntimeException("Memory ran out. Compaction failed. numPartitions: " + this.partitions.size() + 
									" minPartition: " + getMinPartition() +
									" maxPartition: " + getMaxPartition() +
									" bucketSize: " + this.buckets.length +
									" Message: " + ex.getMessage());
						}
						bucket.putLong(pointerOffset, newPointer);
						return;
					} catch (IOException e) {
						throw new RuntimeException("Error deserializing record from the hashtable: " + e.getMessage(), e);
					} 
				}
				else {
					numInSegment++;
				}
			}
			
			// this segment is done. check if there is another chained bucket
			long newForwardPointer = bucket.getLong(bucketInSegmentOffset + HEADER_FORWARD_OFFSET);
			if (newForwardPointer == BUCKET_FORWARD_POINTER_NOT_SET) {
				// nothing found. append and insert
				long pointer = partition.appendRecord(record);
				insertBucketEntryFromSearch(partition, originalBucket, bucket, originalBucketOffset, bucketInSegmentOffset, countInSegment, currentForwardPointer, searchHashCode, pointer);
				if((pointer >> this.pageSizeInBits) > this.compactionMemory.getBlockCount()) {
					this.compactionMemory.allocateSegments((int)(pointer >> this.pageSizeInBits));
				}
				return;
			}
			
			final int overflowSegNum = (int) (newForwardPointer >>> 32);
			bucket = overflowSegments[overflowSegNum];
			bucketInSegmentOffset = (int) (newForwardPointer & 0xffffffff);
			countInSegment = bucket.getInt(bucketInSegmentOffset + HEADER_COUNT_OFFSET);
			posInSegment = bucketInSegmentOffset + BUCKET_HEADER_LENGTH;
			numInSegment = 0;
			currentForwardPointer = newForwardPointer;
		}
	}
1244754
public Record moveRecordToBase(Record record)
    {
        SharedBaseRecordTable sharedTable = this.getSharedTable();
        sharedTable.setCurrentRecord(record);
        boolean bCopyEditMode = false;
        boolean bOnlyModifiedFields = false;
        Record recBase = sharedTable.getBaseRecord();
        sharedTable.copyRecordInfo(recBase, record, bCopyEditMode, bOnlyModifiedFields);
        return recBase;
    }
371853
public String forPaginate(int pageNumber, int pageSize, StringBuilder findSql) {
		int end = pageNumber * pageSize;
		if (end <= 0) {
			end = pageSize;
		}
		int begin = (pageNumber - 1) * pageSize;
		if (begin < 0) {
			begin = 0;
		}
		StringBuilder ret = new StringBuilder();
		ret.append("SELECT * FROM ( SELECT row_number() over (order by tempcolumn) temprownumber, * FROM ");
		ret.append(" ( SELECT TOP ").append(end).append(" tempcolumn=0,");
		ret.append(findSql.toString().replaceFirst("(?i)select", ""));
		ret.append(")vip)mvp where temprownumber>").append(begin);
		return ret.toString();
	}