Skip to content

Commit

Permalink
Added new signatures to constructors of 3 functions
Browse files Browse the repository at this point in the history
They allow a list of Strings in addition to varargs
  • Loading branch information
sylvainhalle committed Nov 23, 2023
1 parent 97cb609 commit b3b6724
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
15 changes: 15 additions & 0 deletions Mtnp/src/ca/uqac/lif/cep/mtnp/UpdateTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package ca.uqac.lif.cep.mtnp;

import java.util.List;

import ca.uqac.lif.cep.UniformProcessor;
import ca.uqac.lif.mtnp.table.HardTable;
import ca.uqac.lif.mtnp.table.TableEntry;
Expand Down Expand Up @@ -54,6 +56,19 @@ public UpdateTable(int in_arity, String ... column_names)
m_table = new HardTable(column_names);
}

/**
* Creates a new instance of the processor.
* @param in_arity The input arity
* @param column_names The names of the columns in the resulting table
*/
public UpdateTable(int in_arity, List<String> column_names)
{
super(in_arity, 1);
String[] col_names = new String[column_names.size()];
column_names.toArray(col_names);
m_table = new HardTable(col_names);
}

/**
* Creates a new instance of the processor.
* @param in_arity The input arity
Expand Down
8 changes: 7 additions & 1 deletion Mtnp/src/ca/uqac/lif/cep/mtnp/UpdateTableMap.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
BeepBeep, an event stream processor
Copyright (C) 2008-2017 Sylvain Hallé
Copyright (C) 2008-2023 Sylvain Hallé
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
Expand All @@ -17,6 +17,7 @@
*/
package ca.uqac.lif.cep.mtnp;

import java.util.List;
import java.util.Map;

import ca.uqac.lif.mtnp.table.TableEntry;
Expand All @@ -32,6 +33,11 @@ public UpdateTableMap(String ... col_names)
{
super(1, col_names);
}

public UpdateTableMap(List<String> col_names)
{
super(1, col_names);
}

@Override
protected boolean compute(Object[] inputs, Object[] outputs)
Expand Down
16 changes: 14 additions & 2 deletions Tuples/src/ca/uqac/lif/cep/tuples/MergeScalars.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
BeepBeep, an event stream processor
Copyright (C) 2008-2017 Sylvain Hallé
Copyright (C) 2008-2023 Sylvain Hallé
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
Expand All @@ -17,6 +17,7 @@
*/
package ca.uqac.lif.cep.tuples;

import java.util.List;
import java.util.Set;

import ca.uqac.lif.cep.Connector;
Expand All @@ -42,7 +43,7 @@ public class MergeScalars extends Function
/**
* The names given to the attributes corresponding to each scalar
*/
protected String[] m_attributeNames;
protected final String[] m_attributeNames;

protected FixedTupleBuilder m_builder;

Expand All @@ -52,6 +53,17 @@ public MergeScalars(String ... names)
m_attributeNames = names;
m_builder = new FixedTupleBuilder(names);
}

public MergeScalars(List<String> names)
{
super();
m_attributeNames = new String[names.size()];
for (int i = 0; i < names.size(); i++)
{
m_attributeNames[i] = names.get(i);
}
m_builder = new FixedTupleBuilder(m_attributeNames);
}

@Override
public void evaluate(Object[] inputs, Object[] outputs, Context context, EventTracker tracker)
Expand Down

0 comments on commit b3b6724

Please sign in to comment.