Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip NULL-valued properties in bulk loader (#1108) #1216

Merged
merged 19 commits into from
Jul 12, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
35079b1
Add suppression for erroneous leak reports after DEBUG RELOAD (#1094)…
DvirDukhan Jul 8, 2020
247bf89
Update value.c (#1209)
DvirDukhan Jul 8, 2020
a800f68
LabelScan with child reads data correctly after reset (#1086) (#1207)
DvirDukhan Jul 8, 2020
72a8bc9
Error properly on graph accesses of non-graph keys (#1069) (#1206)
DvirDukhan Jul 8, 2020
3700370
make memcheck rule prints full log for files with leaks (#1072) (#1205)
DvirDukhan Jul 8, 2020
ae6fb45
ReduceScan and ReduceTraversal respect variable scopes (#1070) (#1204)
DvirDukhan Jul 8, 2020
443c689
Better compile-time checking for undefined variables (#1063) (#1203)
DvirDukhan Jul 8, 2020
72658a3
add cloud link and NOT conditions unary validation (#1214)
DvirDukhan Jul 9, 2020
3aadf41
Bidirectional expand into (#1047)
jeffreylovitz May 13, 2020
146884e
Skip NULL-valued properties in bulk loader (#1108)
jeffreylovitz May 24, 2020
e952277
Merge pull request #1215 from RedisGraph/merge_1047_into_2.0
DvirDukhan Jul 9, 2020
c73d7ff
do not propagate transpose effect when introducing a transpose operat…
swilly22 May 17, 2020
eea0178
Merge branch '2.0' into merge_1108_into_2.0
DvirDukhan Jul 9, 2020
e84b2c2
Merge pull request #1217 from RedisGraph/merge_1102_into_2.0
DvirDukhan Jul 9, 2020
4a1cccc
Merge branch '2.0' into merge_1108_into_2.0
DvirDukhan Jul 9, 2020
84bcd5a
added params support to id seek (#1164) (#1218)
DvirDukhan Jul 9, 2020
a4355ec
Move index iterator construction to first Consume call (#1169) (#1219)
DvirDukhan Jul 9, 2020
5c6e976
Merge branch '2.0' into merge_1108_into_2.0
swilly22 Jul 10, 2020
dc61874
Merge branch '2.0' into merge_1108_into_2.0
swilly22 Jul 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ To see RedisGraph in action, visit [Demos](https://github.com/RedisGraph/RedisGr

## Quickstart

1. [Redis Cloud](#redis-cloud)
1. [Docker](#docker)
2. [Build](#building)
3. [Start](#loading-redisgraph-into-redis)
4. [Use from any client](#using-redisgraph)
1. [Build](#building)
1. [Start](#loading-redisgraph-into-redis)
1. [Use from any client](#using-redisgraph)

## Redis Cloud

RedisGraph is available on all Redis Cloud managed services. Redis Cloud Essentials offers a completely free managed databbases up to 30MB.

[Get started here](https://redislabs.com/try-free/)

## Docker

Expand Down
6 changes: 2 additions & 4 deletions src/arithmetic/algebraic_expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,10 @@ void AlgebraicExpression_AddToTheRight
);

// Transpose expression
// T(T(A)) = A
// T(A + B) = T(A) + T(B)
// T(A * B) = T(B) * T(B)
// By wrapping exp in a transpose root node.
void AlgebraicExpression_Transpose
(
AlgebraicExpression *exp // Expression to transpose.
AlgebraicExpression **exp // Expression to transpose.
);

// Evaluate expression tree.
Expand Down
73 changes: 62 additions & 11 deletions src/arithmetic/algebraic_expression/algebraic_expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,71 @@ AlgebraicExpression *AlgebraicExpression_Clone
// AlgebraicExpression attributes.
//------------------------------------------------------------------------------

// Returns the source entity alias represented by the left-most operand row domain.
// Forward declaration.
static const char *_AlgebraicExpression_Source(AlgebraicExpression *root, bool transposed);

// Returns the source entity alias (row domain)
// Taking into consideration transpose
static const char *_AlgebraicExpression_Operation_Source
(
AlgebraicExpression *root, // Root of expression.
bool transposed // Is root transposed
) {
switch(root->operation.op) {
case AL_EXP_ADD:
// Src (A+B) = Src(A)
// Src (Transpose(A+B)) = Src (Transpose(A)+Transpose(B)) = Src (Transpose(A))
return _AlgebraicExpression_Source(FIRST_CHILD(root), transposed);
case AL_EXP_MUL:
// Src (A*B) = Src(A)
// Src (Transpose(A*B)) = Src (Transpose(B)*Transpose(A)) = Src (Transpose(B))
if(transposed) return _AlgebraicExpression_Source(LAST_CHILD(root), transposed);
else return _AlgebraicExpression_Source(FIRST_CHILD(root), transposed);
case AL_EXP_TRANSPOSE:
// Src (Transpose(Transpose(A))) = Src(A)
// Negate transpose.
return _AlgebraicExpression_Source(FIRST_CHILD(root), !transposed);
default:
assert("Unknown algebraic expression operation" && false);
}
}

// Returns the source entity alias (row domain)
// Taking into consideration transpose
static const char *_AlgebraicExpression_Operand_Source
(
AlgebraicExpression *root, // Root of expression.
bool transposed // Is root transposed
) {
return (transposed) ? root->operand.dest : root->operand.src;
}

// Returns the source entity alias (row domain)
// Taking into consideration transpose
static const char *_AlgebraicExpression_Source
(
AlgebraicExpression *root, // Root of expression.
bool transposed // Is root transposed
) {
assert(root);
switch(root->type) {
case AL_OPERATION:
return _AlgebraicExpression_Operation_Source(root, transposed);
case AL_OPERAND:
return _AlgebraicExpression_Operand_Source(root, transposed);
default:
assert("Unknow algebraic expression node type" && false);
}
}

// Returns the source entity alias, row domain.
const char *AlgebraicExpression_Source
(
AlgebraicExpression *root // Root of expression.
) {
assert(root);
while(root->type == AL_OPERATION) {
root = root->operation.children[0];
}
return _AlgebraicExpression_Source(root, false);

return root->operand.src;
}

// Returns the destination entity alias represented by the right-most operand column domain.
Expand All @@ -137,12 +191,9 @@ const char *AlgebraicExpression_Destination
AlgebraicExpression *root // Root of expression.
) {
assert(root);
while(root->type == AL_OPERATION) {
uint child_count = AlgebraicExpression_ChildCount(root);
root = root->operation.children[child_count - 1];
}

return root->operand.dest;
// Dest(exp) = Src(Transpose(exp))
// Gotta love it!
return _AlgebraicExpression_Source(root, true);
}

/* Returns the first edge alias encountered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ static AlgebraicExpression *_AlgebraicExpression_OperandFromEdge

QGNode *src_node = e->src;
QGNode *dest_node = e->dest;
const char *src = src_node->alias;
const char *dest = dest_node->alias;

// Use original `src` and `dest` for algebraic operands.
const char *src = (transpose) ? dest_node->alias : src_node->alias;
const char *dest = (transpose) ? src_node->alias : dest_node->alias;
const char *edge = _should_populate_edge(e) ? e->alias : NULL;
bool var_len_traversal = QGEdge_VariableLength(e);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ AlgebraicExpression *_AlgebraicExpression_FromString
break;
case 'T':
root = _AlgebraicExpression_FromString(exp, matrices);
AlgebraicExpression_Transpose(root);
AlgebraicExpression_Transpose(&root);
break;
default:
// Operand.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,107 @@ static void _AlgebraicExpression_FlattenMultiplications(AlgebraicExpression *roo
}
}

//------------------------------------------------------------------------------
// Transpose pushdown
//------------------------------------------------------------------------------

// Forward declaration.
static void _Pushdown_TransposeExp(AlgebraicExpression *exp);

// Transpose addition.
static void _Pushdown_TransposeAddition
(
AlgebraicExpression *exp
) {
// T(A + B) = T(A) + T(B)
// Transpose children.
uint child_count = AlgebraicExpression_ChildCount(exp);
for(uint i = 0; i < child_count; i++) _Pushdown_TransposeExp(exp->operation.children[i]);
}

// Transpose multiplication.
static void _Pushdown_TransposeMultiplication
(
AlgebraicExpression *exp
) {
// Swap children, Transpose(A * B) = Transpose(B) * Transpose(A)
array_reverse(exp->operation.children);
// Transpose children.
uint child_count = AlgebraicExpression_ChildCount(exp);
for(uint i = 0; i < child_count; i++) _Pushdown_TransposeExp(exp->operation.children[i]);
}

// Transpose transpose.
static void _Pushdown_TransposeTranspose
(
AlgebraicExpression *exp
) {
// T(T(A)) = A
// Expecting just a single operand.
assert(AlgebraicExpression_ChildCount(exp) == 1);
AlgebraicExpression *only_child = _AlgebraicExpression_OperationRemoveRightmostChild(exp);

// Replace Transpose operation with its child.
_AlgebraicExpression_InplaceRepurpose(exp, only_child);
}

// Transpose operation.
static void _Pushdown_TransposeOperation
(
AlgebraicExpression *exp
) {
switch(exp->operation.op) {
case AL_EXP_ADD:
// T(A + B) = T(A) + T(B)
_Pushdown_TransposeAddition(exp);
break;
case AL_EXP_MUL:
_Pushdown_TransposeMultiplication(exp);
break;
case AL_EXP_TRANSPOSE:
_Pushdown_TransposeTranspose(exp);
break;
default:
assert("Unknown algebraic expression operation");
break;
}
}

// Transpose operand.
static void _Pushdown_TransposeOperand
(
AlgebraicExpression *exp
) {
// No need to transpose a diagonal matrix.
if(exp->operand.diagonal) return;

// A -> Transpose(A)
// We're going to repourpose exp, make a clone.
AlgebraicExpression *operand = AlgebraicExpression_Clone(exp);
_InplaceRepurposeOperandToOperation(exp, AL_EXP_TRANSPOSE);

/* Add original operand as a child of exp (which is now a transpose operation).
* Transpose(A) */
AlgebraicExpression_AddChild(exp, operand);
}

static void _Pushdown_TransposeExp
(
AlgebraicExpression *exp
) {
switch(exp->type) {
case AL_OPERATION:
_Pushdown_TransposeOperation(exp);
break;
case AL_OPERAND:
_Pushdown_TransposeOperand(exp);
break;
default:
assert("unknown algebraic expression node type" && false);
break;
}
}

/* Push down transpose operations to the point where they are applied to individual operands
* once this optimization is applied there shouldn't be instances of transpose acting on
* operation nodes such as multiplication and addition.
Expand Down Expand Up @@ -290,15 +391,15 @@ static void _AlgebraicExpression_PushDownTranspose(AlgebraicExpression *root) {
/* Transpose operation:
* Transpose(A + B) = Transpose(A) + Transpose(B)
* Transpose(A * B) = Transpose(B) * Transpose(A) */
AlgebraicExpression_Transpose(child);
_Pushdown_TransposeExp(child);
/* Replace Transpose root with transposed expression.
* Remove root only child. */
_AlgebraicExpression_OperationRemoveRightmostChild(root);
_AlgebraicExpression_InplaceRepurpose(root, child);

/* Note, there's no need to dig deep into `root` sub-expression
* looking for additional transpose nodes, as calling
* AlgebraicExpression_Transpose will remove all of those. */
/* It is possible for `root` to contain a transpose subexpression
* push it further down. */
_AlgebraicExpression_PushDownTranspose(root);
}
break;
default:
Expand Down
Loading