Git Product home page Git Product logo

data.doublets's People

Contributors

1337101 avatar codacy-badger avatar dependabot-preview[bot] avatar dependabot[bot] avatar flakeed avatar freephoenix888 avatar is2511 avatar konard avatar mitron57 avatar murmelex avatar namelessptr avatar nassipkali avatar uselessgoddess avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

data.doublets's Issues

Property or method is used multiple times, introduce local variable

Constants property:

Constants, IndexPart, SourcePart, TargetPart, Null properties:

  • restrictions[Constants.SourcePart] = _equalityComparer.Equals(restrictions[Constants.SourcePart], Constants.Null) ? restrictions[Constants.IndexPart] : restrictions[Constants.SourcePart];
    restrictions[Constants.TargetPart] = _equalityComparer.Equals(restrictions[Constants.TargetPart], Constants.Null) ? restrictions[Constants.IndexPart] : restrictions[Constants.TargetPart];

    Constants, IndexPart, SourcePart, TargetPart, Itself, Count properties:
  • if (!_equalityComparer.Equals(Constants.Any, Constants.Itself)
    && (((restrictions.Count > Constants.IndexPart) && _equalityComparer.Equals(restrictions[Constants.IndexPart], Constants.Itself))
    || ((restrictions.Count > Constants.SourcePart) && _equalityComparer.Equals(restrictions[Constants.SourcePart], Constants.Itself))
    || ((restrictions.Count > Constants.TargetPart) && _equalityComparer.Equals(restrictions[Constants.TargetPart], Constants.Itself))))

    Constants, IndexPart, SourcePart, TargetPart, Itself, Null, Count properties:
  • public override ulong Update(IList<ulong> restrictions)
    {
    if (restrictions.IsNullOrEmpty())
    {
    return Constants.Null;
    }
    // TODO: Remove usages of these hacks (these should not be backwards compatible)
    if (restrictions.Count == 2)
    {
    return this.Merge(restrictions[0], restrictions[1]);
    }
    if (restrictions.Count == 4)
    {
    return this.UpdateOrCreateOrGet(restrictions[0], restrictions[1], restrictions[2], restrictions[3]);
    }
    // TODO: Looks like this is a common type of exceptions linked with restrictions support
    if (restrictions.Count != 3)
    {
    throw new NotSupportedException();
    }
    var updatedLink = restrictions[Constants.IndexPart];
    this.EnsureLinkExists(updatedLink, nameof(Constants.IndexPart));
    var newSource = restrictions[Constants.SourcePart];
    this.EnsureLinkIsItselfOrExists(newSource, nameof(Constants.SourcePart));
    var newTarget = restrictions[Constants.TargetPart];
    this.EnsureLinkIsItselfOrExists(newTarget, nameof(Constants.TargetPart));
    var existedLink = Constants.Null;
    if (newSource != Constants.Itself && newTarget != Constants.Itself)
    {
    existedLink = this.SearchOrDefault(newSource, newTarget);
    }
    if (existedLink == Constants.Null)
    {
    var before = Links.GetLink(updatedLink);
    if (before[Constants.SourcePart] != newSource || before[Constants.TargetPart] != newTarget)
    {
    Links.Update(updatedLink, newSource == Constants.Itself ? updatedLink : newSource,
    newTarget == Constants.Itself ? updatedLink : newTarget);
    }
    return updatedLink;
    }
    else
    {
    // Replace one link with another (replaced link is deleted, children are updated or deleted), it is actually merge operation
    return this.Merge(updatedLink, existedLink);
    }
    }

This makes code simpler to read and generates different CIL output.

Investigate why these test fail on Linux, but not fail on Windows

if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Using<byte>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(16)); // Cannot use more because current implementation of tree cuts out 5 bits from the address space.
Using<ushort>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(100));
Using<uint>(links => links.DecorateWithAutomaticUniquenessAndUsagesResolution().TestMultipleRandomCreationsAndDeletions(100));
}

Should be ISequenceIndex

public SequencesIndexer<TLink> Indexer { get; set; }

Where is a default SequencesIndexer and FrequencyIncrementingIndexer for OptimalVariantSequences.

This method:

public IList<TLink> Increment(IList<TLink> sequence) // TODO: May be move to ILinksExtensions or make SequenceDoubletsFrequencyIncrementer

Should be moved to FrequencyIncrementingIndexer.

And together with:

public class SequencesIndexer<TLink>

Both should implement a new interface ISequenceIndexer to be injected into SequencesOptions.

There should be a non-cached version of this logic

_unaryToUInt64.Add(unary = Links.GetOrCreate(unary, unary), number = (Integer<TLink>)((Integer<TLink>)number * 2UL));

Try to implement converter that creates links on demand only without precreation.

To to this, we have to check that target is a power of two here:

while (!_unaryToUInt64.TryGetValue(target, out lastValue))

Add an ability to choose tree implementation or even doubly linked collection for ResizableDirectMemoryLinks when using small storage sizes

Byte and UInt16 address space lengths cannot just allow cutting 5 bits from the address space without serious drawbacks.
We need to use simple size balanced tree implementation (without threads and AVL balance factor) to use full address space.
Or maybe for Byte, it will be even faster to use a doubly-linked list.

The alternative will be to find the way not to cut 5 bits from the tree node's size field.

It is bad idea to modify original argument value (IList can be readonly)

restrictions[Constants.SourcePart] = _equalityComparer.Equals(restrictions[Constants.SourcePart], Constants.Null) ? restrictions[Constants.IndexPart] : restrictions[Constants.SourcePart];
restrictions[Constants.TargetPart] = _equalityComparer.Equals(restrictions[Constants.TargetPart], Constants.Null) ? restrictions[Constants.IndexPart] : restrictions[Constants.TargetPart];

Update comments

Use связей instead of взаимосвязей:

/// Представляет объект для работы с базой данных (файлом) в формате Links (массива взаимосвязей).

This is not true, delete this line:
/// AVL - высота дерева может позволить точно расчитать размер дерева, нет необходимости в SBT.

This is done already, delete this line:
/// AVL дерево можно прошить.

New tree algorithm uses 3 bits for balance factor, and 2 bits for threads flags. So long.MaxValue is not the maximum already, update the comment:
/// Текущее теоретическое ограничение на размер связей - long.MaxValue

Remove it is actually merge operation, it is obvious without the comment:
// Replace one link with another (replaced link is deleted, children are updated or deleted), it is actually merge operation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.