You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: terms.rs
    path of file: ./repos/surrealdb/core/src/idx/ft
    
    the code of the file until where you have to start completion: use crate::err::Error;
use crate::idx::trees::bkeys::FstKeys;
use crate::idx::trees::btree::{BState, BState1, BState1skip, BStatistics, BTree, BTreeStore};
use crate::idx::trees::store::{IndexStores, TreeNodeProvider};
use crate::idx::{IndexKeyBase, VersionedSerdeState};
use crate::kvs::{Key, Transaction, TransactionType, Val};
use revision::{revisioned, Revisioned};
use roaring::RoaringTreemap;
use serde::{Deserialize, Serialize};

pub(crate) type TermId = u64;

pub(super) struct Terms {
	state_key: Key,
	index_key_base: IndexKeyBase,
	btree: BTree<FstKeys>,
	store: BTreeStore<FstKeys>,
	available_ids: Option<RoaringTreemap>,
	next_term_id: TermId,
}

impl Terms {
	pub(super) async fn new(
		ixs: &IndexStores,
		tx: &mut Transaction,
		index_key_base: IndexKeyBase,
		default_btree_order: u32,
		tt: TransactionType,
		cache_size: u32,
	) -> Result<Self, Error> {
		let state_ke
    
	async fn test_resolve_terms() {
		const BTREE_ORDER: u32 = 7;

		let ds = Datastore::new("memory").await.unwrap();

		{
			// Empty operation
			let (tx, t) = new_operation(&ds, BTREE_ORDER, Write).await;
			finish(tx, t).await;
		}

		// Resolve a first term
		{
			let (mut tx, mut t) = new_operation(&ds, BTREE_ORDER, Write).await;
			assert_eq!(t.resolve_term_id(&mut tx, "C").await.unwrap(), 0);
			finish(tx, t).await;
			let (mut tx, t) = new_operation(&ds, BTREE_ORDER, Read).await;
			assert_eq!(t.statistics(&mut tx).await.unwrap().keys_count, 1);
		}

		// Resolve a second term
		{
			let (mut tx, mut t) = new_operation(&ds, BTREE_ORDER, Write).await;
			assert_eq!(t.resolve_term_id(&mut tx, "D").await.unwrap(), 1);
			finish(tx, t).await;
			let (mut tx, t) = new_operation(&ds, BTREE_ORDER, Read).await;
			assert_eq!(t.statistics(&mut tx).await.unwrap().keys_count, 2);
		}

		// Resolve two existing terms with new frequencies
		{
			let (mut tx, mut t) = new_operation(&ds, BTREE_ORDER, Write).await;
			assert_eq!(t.resolve_term_id(&mut tx, "C").await.unwrap(), 0);
			assert_eq!(t.resolve_term_id(&mut tx, "D").await.unwrap(), 1);
			finish(tx, t).await;

			let (mut tx, t) = new_operation(&ds, BTREE_ORDER, Read).await;
			assert_eq!(t.statistics(&mut tx).await.unwrap().keys_count, 2);
		}

		// Resolve one existing terms and two new terms
		{
			let (mut tx, mut t) = new_operation(&ds, BTREE_ORDER, Write).await;
			assert_eq!(t.resolve_term_id(&mut tx, "A").await.unwrap(), 2);
			assert_eq!(t.resolve_term_id(&mut tx, "C").await.unwrap(), 0);
			assert_eq!(t.resolve_term_id(&mut tx, "E").await.unwrap(), 3);
			finish(tx, t).await;

			let (mut tx, t) = new_operation(&ds, BTREE_ORDER, Read).await;
			assert_eq!(t.statistics(&mut tx).await.unwrap().keys_count, 4);
		}
	}