Inserts a new, blank record somewhere in the file beginning at the
current record. If the new record does not fit into an existing block,
then a new block is appended to the file.
328109
public void insert() {
		// Block read-only transaction
		if (tx.isReadOnly() && !isTempTable())
			throw new UnsupportedOperationException();

		// Insertion may change the properties of this file,
		// so that we need to lock the file.
		if (!isTempTable())
			tx.concurrencyMgr().modifyFile(fileName);

		// Modify the free chain which is start from a pointer in
		// the header of the file.
		if (fhp == null)
			fhp = openHeaderForModification();

		// Log that this logical operation starts
		tx.recoveryMgr().logLogicalStart();

		if (fhp.hasDeletedSlots()) {
			// Insert into a deleted slot
			moveToRecordId(fhp.getLastDeletedSlot());
			RecordId lds = rp.insertIntoDeletedSlot();
			fhp.setLastDeletedSlot(lds);
		} else {
			// Insert into a empty slot
			if (!fhp.hasDataRecords()) { // no record inserted before
				// Create the first data block
				appendBlock();
				moveTo(1);
				rp.insertIntoNextEmptySlot();
			} else {
				// Find the tail page
				RecordId tailSlot = fhp.getTailSolt();
				moveToRecordId(tailSlot);
				while (!rp.insertIntoNextEmptySlot()) {
					if (atLastBlock())
						appendBlock();
					moveTo(currentBlkNum + 1);
				}
			}
			fhp.setTailSolt(currentRecordId());
		}

		// Log that this logical operation ends
		RecordId insertedRid = currentRecordId();
		tx.recoveryMgr().logRecordFileInsertionEnd(ti.tableName(), insertedRid.block().number(), insertedRid.id());

		// Close the header (release the header lock)
		closeHeader();
	}
229047
def put_record(self, data, partition_key=None):
        
        # Byte encode the data
        data = encode_data(data)

        # Create a random partition key if not provided
        if not partition_key:
            partition_key = uuid.uuid4().hex

        # Build the record
        record = {
            'Data': data,
            'PartitionKey': partition_key
        }

        # Flush the queue if it reaches the batch size
        if self.queue.qsize() >= self.batch_size:
            logger.info("Queue Flush: batch size reached")
            self.pool.submit(self.flush_queue)

        # Append the record
        logger.debug('Putting record "{}"'.format(record['Data'][:100]))
        self.queue.put(record)
1320627
public void add(Rec record) throws DBException
    {
        if (this.getRecord().getEditMode() != Constants.EDIT_ADD)
            throw new DBException(Constants.INVALID_RECORD);
        m_record = (FieldList)record;
        this.fieldsToData(record);
        this.doAdd(record);
        this.setDataSource(null);
        this.getRecord().setEditMode(Constants.EDIT_NONE);
    }
144088
def buffer2file(self):
        
        if self.current_file is not None and self.buffer:
            self.current_file.add_block_data(self.buffered_block_length, self.buffer)
            self.buffer = []
            self.buffered_block_length = 0
302677
protected int addBlock(Collection<Record> candidates,
                         Map.Entry block) {
    Collection<Record> recs = (Collection<Record>) block.getValue();
    candidates.addAll(recs);
    return recs.size();
  }
642833
function (buf, cb) {
      //write to the end of the file.
      //if successful, copy into cache.
      if(writing++) throw new Error('already appending to this file')
      file.offset.once(function (_offset) {

        var start = _offset
        var b_start = 0
        var i = Math.floor(start/block_size)
        if(i*block_size < _offset) //usually true, unless file length is multiple of block_size
          get(i, function (err) { //this will add the last block to the cache.
            if(err) cb(explain(err, 'precache before append failed'))
            else next()
          })
        else next()

        function next () {
          while(b_start < buf.length) { //start < _offset+buf.length) {
            var block_start = i*block_size
            var b = cache.get(i)
            if(null == b) {
              b = Buffer.alloc(block_size)
              cache.set(i, b)
            }
            //including if set in above if...
            if(Buffer.isBuffer(b)) {
                var len = Math.min(block_size - (start - block_start), block_size)
                buf.copy(b, start - block_start, b_start, b_start + len)
                start += len
                b_start += len
            }
            else if(Array.isArray(cbs[i]))
              throw new Error('should never happen: new block should be initialized, before a read ever happens')
            else {
              start += block_size
            }

            i++
          }

          file.append(buf, function (err, offset) {
            if(err) return cb(err)
            writing = 0
            cb(null, offset)
          })
        }
      })
    }
88965
def add_record(self, record):
        """"""
        rec = self.get_record(record._record_type, record.host)
        if rec:
            rec = record
            for i,r in enumerate(self._entries):
                if r._record_type == record._record_type \
                        and r.host == record.host:
                            self._entries[i] = record
        else:
            self._entries.append(record)
        self.sort()
        return True
28615
def add_record(self, record):
        
        record.setdefault('_oai', {}).setdefault('sets', [])

        assert not self.has_record(record)

        record['_oai']['sets'].append(self.spec)
507386
public void doAdd(Record record) throws DBException
    {
        m_LastModifiedBookmark = null;
        try   {
            m_pTable.add(this);
            m_LastModifiedBookmark = this.getHandle(DBConstants.BOOKMARK_HANDLE);
        } catch (DBException ex)    {
            throw DatabaseException.toDatabaseException(ex);
        }
    }
151267
def _create_record(attribute_names = self.attribute_names)
      attribute_names = attributes_for_create(attribute_names)

      new_id = self.class._insert_record(
        attributes_with_values(attribute_names)
      )

      self.id ||= new_id if @primary_key

      @new_record = false

      yield(self) if block_given?

      id
    end
760127
private synchronized void uploadCurrentBlock() throws IOException {
    if (!hasActiveBlock()) {
      throw new IllegalStateException("No active block");
    }
    LOG.debug("Writing block # {}", blockCount);
    if (multiPartUpload == null) {
      LOG.debug("Initiating Multipart upload");
      multiPartUpload = new MultiPartUpload();
    }
    try {
      multiPartUpload.uploadBlockAsync(getActiveBlock());
    } finally {
      // set the block to null, so the next write will create a new block.
      clearActiveBlock();
    }
  }
9442
def addRecord(self, record):
        
        if self._destroyed:
            return
        
        if not self.uiRecordBTN.isChecked():
            return
        
        self._queue.append(record)
719319
int insert(Object caller, int version, bbBlock curr, int pos, int len)
    {
        assert mutation_in_progress(caller, version);
        // DEBUG: int amountMoved = 0;
        // DEBUG: int before = this._buf_limit;
        // DEBUG: assert _validate();
        // if there's room in the current block - just
        // move the "trailing" bytes down and we're done
        int neededSpace = len - curr.unusedBlockCapacity();
        if (neededSpace <= 0) {
            // we have all the space we need in the current block
            // DEBUG: amountMoved =
            insertInCurrOnly(caller, version, curr, pos, len);
        }
        else {
            // we'll need at least some additional space beyond the curr
            // block, see if there's room in the
            // next one, otherwise we'll make more (blocks)
            bbBlock next = null;
            if (curr._idx < this._next_block_position - 1) {
                // if there is another block
                next = this._blocks.get(curr._idx + 1);
            }
            if (next != null &&
                (neededSpace <= next.unusedBlockCapacity())
            ) {
                // with the addition of the free space in the following block we have enough
                // DEBUG: amountMoved =
                insertInCurrAndNext(caller, version, curr, pos, len, next);
            }
            else {
                // we'll have to make one or more new blocks
                // first figure out much will be in the first
                // and last blocks (i.e. ignoring the whole
                // blocks
                int lenNeededInLastAddedBlock = neededSpace % _blockSizeUpperLimit;
                int tailLen = curr.bytesAvailableToRead(pos);
                if (lenNeededInLastAddedBlock < tailLen) lenNeededInLastAddedBlock = tailLen;
                if (lenNeededInLastAddedBlock < neededSpace
                 && neededSpace < this._blockSizeUpperLimit) {
                    // if we need less than the largest block then we should
                    // make *one* block with all of the needed space
                    lenNeededInLastAddedBlock = neededSpace;
                }
                bbBlock newblock = insertMakeNewTailBlock(caller, version, curr, lenNeededInLastAddedBlock);
                // now see if the curr block and this newblock have enough
                // available space to do the job, and if there's some trailing
                // data from curr that will end up staying in curr
                if (len <= (curr.unusedBlockCapacity()
                           + newblock.unusedBlockCapacity())
                ) {
                    // insert this as a zero length block immediately  after _curr
                    // insertBlock also adjusts the trailing blocks idx values
                    insertBlock(newblock);
                    // now pretend we just have the "push into the next block" case
                    // DEBUG: amountMoved =
                    insertInCurrAndNext(caller, version, curr, pos, len, newblock);
                }
                else {
                    // and last we have the case of having to insert more than 1 block
                    // which means all of the trailing bytes in _curr move into the last
                    // block
                    // DEBUG: amountMoved =
                    insertAsManyBlocksAsNeeded(caller, version, curr, pos, len, newblock);
                }
            }
        }
        // DEBUG: if (this._buf_limit - before != len
        // DEBUG: || amountMoved != len) {
        // DEBUG: throw new BlockedBufferException("insert went wrong #1 !!!");
        // DEBUG: }
        assert _validate();
        return len;
    }
1191251
private void flushBlock() throws IOException {
        if (this.debug) {
            System.err.println("TarBuffer.flushBlock() called.");
        }

        if (this.outStream == null) {
            throw new IOException("writing to an input buffer");
        }

        // Thanks to 'Todd Kofford <tkofford@bigfoot.com>' for this patch.
        // Use a buffer initialized with 0s to initialize everything in the
        // blockBuffer after the last current, complete record. This prevents
        // any previous data that might have previously existed in the
        // blockBuffer from being written to the file.

        if (this.currRecIdx > 0) {
            int offset = this.currRecIdx * this.recordSize;
            byte[] zeroBuffer = new byte[this.blockSize - offset];

            System.arraycopy(zeroBuffer, 0, this.blockBuffer, offset, zeroBuffer.length);

            this.writeBlock();
        }
    }
725371
public void init(Record record, String strToCompare, String strSeekSign, Converter pconvFlag, boolean bDontFilterIfNullCompare, BaseField fldToCheck, BaseField fldToCompare)
    {
        m_fldFakeDate = null;
        super.init(record, null, strToCompare, null, pconvFlag, bDontFilterIfNullCompare, fldToCheck, fldToCompare);
        if (strSeekSign == null)
            m_strSeekSign = DBConstants.BLANK;    // I Must do this here because I don't want the default value
    }
894561
public void insertOrReplaceRecord(T record) throws IOException {
		if (this.closed) {
			return;
		}

		final int searchHashCode = MathUtils.jenkinsHash(this.buildSideComparator.hash(record));
		final int posHashCode = searchHashCode % this.numBuckets;
		
		// get the bucket for the given hash code
		final MemorySegment originalBucket = this.buckets[posHashCode >> this.bucketsPerSegmentBits];
		final 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;

		// 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);
					
					// deserialize the key to check whether it is really equal, or whether we had only a hash collision
					T valueAtPosition = partition.readRecordAt(pointer);
					if (this.buildSideComparator.equalToReference(valueAtPosition)) {
						long newPointer = insertRecordIntoPartition(record, partition, true);
						bucket.putLong(pointerOffset, newPointer);
						return;
					}
				}
				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 = insertRecordIntoPartition(record, partition, false);

				if (countInSegment < NUM_ENTRIES_PER_BUCKET) {
					// we are good in our current bucket, put the values
					bucket.putInt(bucketInSegmentOffset + BUCKET_HEADER_LENGTH + (countInSegment * HASH_CODE_LEN), searchHashCode); // hash code
					bucket.putLong(bucketInSegmentOffset + BUCKET_POINTER_START_OFFSET + (countInSegment * POINTER_LEN), pointer); // pointer
					bucket.putInt(bucketInSegmentOffset + HEADER_COUNT_OFFSET, countInSegment + 1); // update count
				}
				else {
					insertBucketEntryFromStart(originalBucket, originalBucketOffset, searchHashCode, pointer, partitionNumber);
				}
				return;
			}
			
			final int overflowSegNum = (int) (newForwardPointer >>> 32);
			bucket = overflowSegments[overflowSegNum];
			bucketInSegmentOffset = (int) newForwardPointer;
			countInSegment = bucket.getInt(bucketInSegmentOffset + HEADER_COUNT_OFFSET);
			posInSegment = bucketInSegmentOffset + BUCKET_HEADER_LENGTH;
			numInSegment = 0;
		}
	}
342131
def add_record(self, length):
        # type: (int) -> None
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('CE record not yet initialized!')

        self.len_cont_area += length