jgaskins on experimental-bolt-conversion
Enforce serializable types earl… Ensure we use separate vars for… (compare)
jgaskins on experimental-bolt-conversion
Strings have unsigned lengths (compare)
jgaskins on experimental-bolt-conversion
Add Serializable::{Node,Relatio… (compare)
jgaskins on experimental-bolt-conversion
Add Neo4j::Serializable::Node (compare)
jgaskins on experimental-bolt-conversion
Allow time zone cache to be use… Fix DST issue with timestamps w… (compare)
jgaskins on experimental-bolt-conversion
Flush connection properly (compare)
jgaskins on experimental-bolt-conversion
Support Bolt v4 (compare)
jgaskins on experimental-bolt-conversion
Fix tiny negative ints How did… (compare)
jgaskins on experimental-bolt-conversion
Remove retries from the connect… Use lock-free atomic mutation i… Increase max idle pool size Th… and 1 more (compare)
jgaskins on experimental-bolt-conversion
Handle busted exec_cast queries… (compare)
jgaskins on experimental-bolt-conversion
Clarify specs, add Bolt seriali… (compare)
jgaskins on experimental-bolt-conversion
Make Driver a superclass of bot… (compare)
jgaskins on experimental-bolt-conversion
Add experimental to_bolt_params… (compare)
module Neo4j
module Bolt
class Connection
private def run(statement, parameters = {} of String => Type, retries = 0)
write_message do |msg|
msg.write_structure_start 2
msg.write_byte Commands::Run
msg.write statement
msg.write parameters
end
result = read_result
case result
when Failure
raise ::Neo4j::QueryException.new(result.attrs["message"].as(String), result.attrs["code"].as(String))
when Success, Ignored
result
else
raise ::Neo4j::UnknownResult.new("Cannot identify this result: #{result.inspect}")
end
rescue ex : IO::EOFError
initialize @uri, @ssl
if retries < 10
sleep 0.1
run statement, parameters, retries + 1
else
raise ex
end
end
end
end
end
Channel(Array(Type))
. It's super naive right now and requires you to completely consume results before sending any followup queries (so, before a transaction
block ends, for example), but it reduces latency to first row and kept my example query (millions of nodes) at 1.4MB RAM compared to 2.4GB when the query result is consumed eagerly.
127_i8+1
= -127_i8, but 1+127_i8
= 128_i32 arghhhhh
{
0_i8,
-1_i8,
1_i8,
Int8::MAX,
Int8::MIN,
0_i16,
-1_i16,
1_i16,
Int8::MIN.to_i16 - 1,
Int8::MAX.to_i16 + 1,
Int16::MIN,
Int16::MAX,
0_i32,
-1_i32,
1_i32,
Int16::MIN.to_i32 - 1,
Int16::MAX.to_i32 + 1,
Int32::MIN,
Int32::MAX,
0__i64,
-1_i64,
1__i64,
Int32::MIN.to_i64 - 1,
Int32::MAX.to_i64 + 1,
Int64::MIN,
Int64::MAX,
}.each do |int|
it "serializes #{int}" do
unpack(pack(int)).should eq int
end
end
Int64
but that certainly might help with your overflows.
In this version, a couple of arithmetic operators were added thanks to #6890: &+, &-, &. They will perform additions, subtraction and multiplication with wrapping (as in, not overflowing). Some may notice that that is the exact same behaviour as +, -, . In a future version, the regular operators are going to raise on overflow. This will allow you to trust the result of the operations when reaching the limits of the representable range. The ampersand operators might be useful to think of them as applying an & 0xFF bit mask to the result.
Ah, looks like they only aliased the current, non-raising versions so people can migrate their code if they don't want to raise on overflow. https://crystal-lang.org/2018/11/01/crystal-0.27.0-released.html
Hmm, so it looks like Neo4j is sending us the numbers in the smallest type possible:
result = connection.execute "RETURN $int8, $int16, $int32, $int64",
int8: Int8::MAX,
int16: Int16::MAX,
int32: Int32::MAX,
int64: Int64::MAX
pp result.first
# => [127_i8, 32767_i16, 2147483647, 9223372036854775807_i64]
We're deserializing it in whatever integer type Neo4j tells us it is. :-\
Int64
to avoid the int-overflow issue you're seeing, but also I think that might break things like Neo4j.map_node(some_int_value: Int16)
.
v0.2.3
before_install:
- curl -sSL https://neo4j.com/artifact.php?name=neo4j-community-3.5.2-unix.tar.gz | tar x
- cd neo4j-community-3.5*
- bin/neo4j start
- false ; while [ $? -ne 0 ]; do sleep 1 ; curl -sI http://localhost:7474 | head -1 | grep 200 ; done