Code Monkey home page Code Monkey logo

Comments (4)

swilly22 avatar swilly22 commented on June 9, 2024 2

Hi @linuxfreakus, @alan-salimov-vai we've been able to resolve both issues and are in progress of releasing these fixes.

from falkordb.

swilly22 avatar swilly22 commented on June 9, 2024 1

Thank you @linuxfreakus, @alan-salimov-vai
We're able to replicate the issue from our end and are investigating.

from falkordb.

alan-salimov-vai avatar alan-salimov-vai commented on June 9, 2024

Related to this issue, we start from a fresh falkordb instance (pulled from the latest image as of this morning).

Inserting a single node of type "Page" then adding additional nodes normally works.

However, if you add and drop a constraint on the URL field, undefined behavior occurs. Either a segfault or the inserted URLs are malformed (resulting in UnicodeDecodeErrors when attempting to access.)

from falkordb import FalkorDB, Node
from redis.exceptions import ResponseError

def reset_graph(use_constraints=False, port=8080):
    # Connect to FalkorDB
    db = FalkorDB(host='localhost', port=port)
    graph = db.select_graph('Page')
    try:
        graph.delete()
    except ResponseError:
        pass
    for index, url in enumerate(['https://en.wikipedia.org/wiki/Napoleon']):
        node = Node(labels="Page", properties={'url':url})
        query = 'CREATE ' + (str(node))
        graph.query(query)
        
        if use_constraints:
            graph.create_node_unique_constraint('Page', 'url')
            graph.list_constraints()
            graph.drop_node_unique_constraint('Page', 'url')
        
    ct = graph.query("MATCH (n:Page) RETURN COUNT(n)").result_set[0][0]
    print("Graph reset, count=", ct)
    return graph

target_url_list = ['https://en.wikipedia.org/wiki/Assembly_language', 'https://en.wikipedia.org/wiki/Sabbatical']

# ---- NO CONSTRAINT SET ---- # 
graph = reset_graph(use_constraints=False)
insert_query = graph.query("""
        WITH $target_urls AS target_urls_list
        UNWIND target_urls_list AS target_url
        MATCH (src:Page {url: $source_url})
        MERGE (tgt:Page {url: target_url})
        MERGE (src)-[:CONNECTED_TO]->(tgt)
        RETURN src
    """, params={"source_url": 'https://en.wikipedia.org/wiki/Napoleon', "target_urls": target_url_list})

ct = graph.query("MATCH (n:Page) RETURN COUNT(n)").result_set[0][0]
print(ct) # Prints 3
url_match_set = graph.query("MATCH (n:Page) RETURN n.url").result_set # Returns 3 URLs 

# ---- YES CONSTRAINT SET ---- # 
graph = reset_graph(use_constraints=True)
insert_query = graph.query("""
        WITH $target_urls AS target_urls_list
        UNWIND target_urls_list AS target_url
        MATCH (src:Page {url: $source_url})
        MERGE (tgt:Page {url: target_url})
        MERGE (src)-[:CONNECTED_TO]->(tgt)
    """, params={"source_url": 'https://en.wikipedia.org/wiki/Napoleon', "target_urls": target_url_list}) # --> SEGFAULT


# LONGER TARGET LIST 
target_list = ['https://www.worldcat.org/issn/0098-3500',
 'https://en.wikipedia.org/wiki/Assembly_language',
 'https://en.wikipedia.org/wiki/Sabbatical',
 'https://en.wikipedia.org/wiki/Kazushige_Goto',
 'https://en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard',
 'https://en.wikipedia.org/wiki/TFLOPS',
 'https://en.wikipedia.org/wiki/BSD_license',
 'https://en.wikipedia.org/wiki/Multiprocessing',
 'https://en.wikipedia.org/wiki/LAPACK']

graph = reset_graph(use_constraints=True)
insert_query = graph.query("""
        WITH $target_urls AS target_urls_list
        UNWIND target_urls_list AS target_url
        MATCH (src:Page {url: $source_url})
        MERGE (tgt:Page {url: target_url})
        MERGE (src)-[:CONNECTED_TO]->(tgt)
    """, params={"source_url": 'https://en.wikipedia.org/wiki/Napoleon', "target_urls": target_url_list})

ct = graph.query("MATCH (n:Page) RETURN COUNT(n)").result_set[0][0]
print(ct) # Returns 7??? 

url_match_set = graph.query("MATCH (n:Page) RETURN n.url").result_set
print(url_match_set) # Throws UnicodeDecodeError. Malformed URLs here.```

from falkordb.

alan-salimov-vai avatar alan-salimov-vai commented on June 9, 2024

Seems like this is related to the index return from graph.list_indices().

from falkordb.

Related Issues (20)

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.