在 Neo4j 中存储二进制对象
Neo4j 似乎不允许我存储二进制对象。这是否意味着我必须将 Neo4j 与其他数据存储(例如文件系统、Oracle 等)结合使用?
Neo4j doesn't seem to allow me to store binary objects. Does this mean I must used Neo4j in conjuntion with another data store, such as the filesystem., Oracle, etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Daniel 已经回答说可以在 Neo4J 中存储二进制对象。
但我建议你不要这样做。您无法对数据库中的二进制对象做任何有趣的事情。你无法搜索它们。通过存储二进制对象,您将实现的唯一一件事是增加数据库的文件大小。请注意,Neo4J 不可水平扩展。它没有自动分片。因此,如果您的数据库变得太大,您就会遇到麻烦。通过将二进制文件存储在文件系统或外部分布式键值存储(如 riak、cassandra、hadoop 等)中,您可以保持数据库较小,这有利于性能、备份并避免水平扩展问题。
Daniel already answered that it's possible to store binary objects in Neo4J.
But i would suggest you not to do so. You can do nothing interesting with binary objects in database. You cannot search them. The only thing you will achieve by storing binary objects - grow the file size of your database. Mind you, Neo4J is not scalable horizontally. It does not have automatic sharding. So if your db grows too big, you are in trouble. By storing binaries in a file system or external distributed key-value store like riak, cassandra, hadoop etc, you are keeping your database small, which is good for performance, backups and avoiding horizontal scaling problems.
如果您查看此处的 API: http ://api.neo4j.org/1.2/org/neo4j/graphdb/PropertyContainer.html#setProperty(java.lang.String, java.lang.Object),您看到允许
使用 字节数组。 -数组,您可以存储二进制对象。当您在 Oracle 中存储二进制对象(使用 Java)时,您也可以将数据加载为 byte[]。
If you look in the API here: http://api.neo4j.org/1.2/org/neo4j/graphdb/PropertyContainer.html#setProperty(java.lang.String, java.lang.Object), you see that byte arrays are allowed.
Using byte-arrays you can store your binary objects. When you store binary objects (using Java) in Oracle, you load in the data as byte[] as well.
您可以将二进制对象存储为 byte[] 或编码为字符串,但我建议将较大(例如 > 1,000 字节)的 blob 存储为单独的文件,并且仅在数据库中保留对该文件的引用。
我们也在 Structr (http://structr.org) 中执行此操作。
You can store binary objects as byte[] or encoded in a String, but I would recommend to store larger (e.g. > 1,000 bytes) blobs as separate files, and only keep a reference to the file in your database.
We do this in Structr (http://structr.org) as well.
如前所述,这样做是非常不利的。
但是,如果您决定这样做,可以在 C# 中这样做:
As mentioned doing this is highly disadvantageous.
However if you decide to do so, you could do it like this in C#: