Exemplo n.º 1
0
int main (int argc, char * argv[])
{
    char * filename = argv[1];

    Program_Module m = Program_ModuleNew();
    Program_ParseArguments (m, argc, argv);

    printf ("Compiling %s\n", String_Data (m->options.file));

    if (Parse_File (m, m->options.file) != 0)
    {
        printf ("Lex errors: %lu\n", Vector_Size (&m->errors.lexer));
        VECTOR_FOREACH (struct Error_t, error, &m->errors.lexer)
        {
            Error_Print (stdout, error);
        }

        printf ("Parse errors: %lu\n", Vector_Size (&m->errors.parser));
        VECTOR_FOREACH (struct Error_t, error, &m->errors.parser)
        {
            Error_Print (stdout, error);
        }

        VECTOR_FOREACH (struct Program_Option_t, o, &m->options.debug)
        {
            if (String_Equal (&o->key, "parse-only"))
            {
                printf ("Exiting, because of '%s'.\n", o->key.data);
                exit (0);
            }
        }

        printf ("Exiting, fix the errors and try again.");
        exit (0);
    }
Exemplo n.º 2
0
TEST_F(RangeTest, testRangeTree) {
  NumericRangeTree *t = NewNumericRangeTree();
  ASSERT_TRUE(t != NULL);

  for (size_t i = 0; i < 50000; i++) {

    NumericRangeTree_Add(t, i + 1, (double)(1 + prng() % 5000));
  }
  ASSERT_EQ(t->numRanges, 16);
  ASSERT_EQ(t->numEntries, 50000);

  struct {
    double min;
    double max;
  } rngs[] = {{0, 100}, {10, 1000}, {2500, 3500}, {0, 5000}, {4999, 4999}, {0, 0}};

  for (int r = 0; rngs[r].min || rngs[r].max; r++) {

    Vector *v = NumericRangeTree_Find(t, rngs[r].min, rngs[r].max);
    ASSERT_TRUE(Vector_Size(v) > 0);
    // printf("Got %d ranges for %f..%f...\n", Vector_Size(v), rngs[r].min, rngs[r].max);
    for (int i = 0; i < Vector_Size(v); i++) {
      NumericRange *l;
      Vector_Get(v, i, &l);
      ASSERT_TRUE(l);
      // printf("%f...%f\n", l->minVal, l->maxVal);
      ASSERT_FALSE(l->minVal > rngs[r].max);
      ASSERT_FALSE(l->maxVal < rngs[r].min);
    }
    Vector_Free(v);
  }
  NumericRangeTree_Free(t);
}
Exemplo n.º 3
0
dfaNode *__dfn_getCache(Vector *cache, sparseVector *v) {
  size_t n = Vector_Size(cache);
  for (int i = 0; i < n; i++) {
    dfaNode *dfn;
    Vector_Get(cache, i, &dfn);

    if (__sv_equals(v, dfn->v)) {
      return dfn;
    }
  }
  return NULL;
}
Exemplo n.º 4
0
void Free_AST_OrderNode(AST_OrderNode *orderNode) {
	if(orderNode != NULL) {
		for(int i = 0; i < Vector_Size(orderNode->columns); i++) {
			AST_ColumnNode *c = NULL;
			Vector_Get(orderNode->columns, i , &c);
			Free_AST_ColumnNode(c);
		}

		Vector_Free(orderNode->columns);
		free(orderNode);
	}
}
Exemplo n.º 5
0
/*
 * Before the ExecutionPlan has been constructed, we can analyze the FilterTree
 * to see if a scan operation can employ an index. This function will return the iterator
 * required for constructing an indexScan operation.
 */
IndexIterator* Index_IntersectFilters(RedisModuleCtx *ctx, const char *graphName, Vector *filters, const char *label) {
  FT_PredicateNode *const_filter;
  Index *idx;
  while (Vector_Size(filters) > 0) {
    Vector_Pop(filters, &const_filter);
    // Look this property up to see if it has been indexed (using the label rather than the node alias)
    if ((idx = Index_Get(ctx, graphName, label, const_filter->Lop.property)) != NULL) {
      // Build an iterator from the first matching index
      return IndexIterator_CreateFromFilter(idx, const_filter);
    }
  }

  return NULL;
}
Exemplo n.º 6
0
void Free_AST_GraphEntity(AST_GraphEntity *graphEntity) {
	if(graphEntity->label != NULL) {
		free(graphEntity->label);
	}
	if(graphEntity->alias != NULL) {
		free(graphEntity->alias);
	}
	if(graphEntity->properties != NULL) {
		for(int i = 0; i < Vector_Size(graphEntity->properties); i++) {
			SIValue *val;
			Vector_Get(graphEntity->properties, i, &val);
			SIValue_Free(val);
			free(val);
		}
		Vector_Free(graphEntity->properties);
	}
	free(graphEntity);
}