<commit_before>﻿using System;
using System.Collections.Generic;

namespace Scalien
{
    public class Index
    {
        Client client;
        Table table;
        ulong databaseID;
        ulong tableID;
        string key;
        long count;

        long index;
        long num;

        public Index(Client client, ulong databaseID, ulong tableID, string key)
        {
            this.client = client;
            this.databaseID = databaseID;
            this.tableID = tableID;
            this.key = key;
            this.index = 0;
            this.count = 100;
            this.num = 0;
        }

        public Index(Table table, string key)
        {
            this.table = table;
            this.key = key;
            this.count = 100;
            this.index = 0;
            this.num = 0;
        }

        public void Create()
        {
            Client client = GetClient();

            ulong oldDatabaseID = client.GetDatabaseID();
            ulong oldTableID = client.GetTableID();

            if (table != null)
            {
                table.Set(key, "0");
            }
            else
            {
                client.UseDatabaseID(databaseID);
                client.UseTableID(tableID);
                client.Set(key, "0");
            }
            
            num = 0;

            client.UseDatabaseID(oldDatabaseID);
            client.UseTableID(oldTableID);
        }

        public ulong Get
        {
            get
            {
                if (num == 0)
                {
                    Client client = GetClient();

                    // retrieve new indices
                    ulong oldDatabaseID = client.GetDatabaseID();
                    ulong oldTableID = client.GetTableID();

                    if (table != null)
                    {
                        index = table.Add(key, count) - count;
                    }
                    else
                    {
                        client.UseDatabaseID(databaseID);
                        client.UseTableID(tableID);
                        index = client.Add(key, count) - count;
                    }
                    
                    num = count;<commit_msg>Removed unnecessary Create() from C# Index class.<commit_after>﻿using System;
using System.Collections.Generic;

namespace Scalien
{
    public class Index
    {
        Client client;
        Table table;
        ulong databaseID;
        ulong tableID;
        string key;
        long count;

        long index;
        long num;

        public Index(Client client, ulong databaseID, ulong tableID, string key)
        {
            this.client = client;
            this.databaseID = databaseID;
            this.tableID = tableID;
            this.key = key;
            this.index = 0;
            this.count = 100;
            this.num = 0;
        }

        public Index(Table table, string key)
        {
            this.table = table;
            this.key = key;
            this.count = 100;
            this.index = 0;
            this.num = 0;
        }

        public ulong Get
        {
            get
            {
                if (num == 0)
                {
                    Client client = GetClient();

                    // retrieve new indices
                    ulong oldDatabaseID = client.GetDatabaseID();
                    ulong oldTableID = client.GetTableID();

                    if (table != null)
                    {
                        index = table.Add(key, count) - count;
                    }
                    else
                    {
                        client.UseDatabaseID(databaseID);
                        client.UseTableID(tableID);
                        index = client.Add(key, count) - count;
                    }
                    
                    num = count;
{'fraction_non_alphanumeric': 0.07869531452239192, 'fraction_numerical': 0.0064716541548019675, 'mean_word_length': 0.9554655870445344, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2270045', 'n_tokens_mistral': 984, 'n_tokens_neox': 903, 'n_words': 227}