LongKeyNode putRecord(DBRecord record, Table table) throws IOException {

		long key = record.getKey();
		int index = getKeyIndex(key);

		// Handle record update case
		if (index >= 0) {
			if (table != null) {
				// update index tables associated with table
				table.updatedRecord(getRecord(table.getSchema(), index), record);
			}
			LongKeyNode newRoot = updateRecord(index, record);
			return newRoot;
		}

		// Handle new record - see if we have room in this leaf
		index = -index - 1;
		if (insertRecord(index, record)) {
			if (index == 0 && parent != null) {
				parent.keyChanged(getKey(1), key);
			}
			if (table != null) {
				// update index tables associated with table
				table.insertedRecord(record);
			}
			return getRoot();
		}

		// Special Case - append new leaf to right
		if (index == keyCount) {
			LongKeyNode newRoot = appendNewLeaf(record);
			if (table != null) {
				// update index tables associated with table
				table.insertedRecord(record);
			}
			return newRoot;
		}

		// Split leaf and complete insertion
		LongKeyRecordNode leaf = split().getLeafNode(key);
		return leaf.putRecord(record, table);
	}
Insert or Update a record.
@param record data record with long key
@param table table which will be notified when record is inserted or updated.
This must be specified when table has indexed columns.
@return root node which may have changed.
@throws IOException thrown if IO error occurs
Ghidra/Framework/DB/src/main/java/db/LongKeyRecordNode.java