Merging changes
This commit is contained in:
1 parent
c4216d2272
commit
797816be7e
437 files changed
+54228
-28
No files matched your search
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BCG
|
||||
{
|
||||
public class ColumnKeyedData
|
||||
{
|
||||
private int[] _key_col_indices = null;
|
||||
private string[] _key_col_names;
|
||||
private BlueRowHasher _row_hasher;
|
||||
private Dictionary<int, IBlueRow> _row_map = new Dictionary<int, IBlueRow>();
|
||||
|
||||
public ColumnKeyedData(params string[] key_col_names)
|
||||
{
|
||||
_key_col_names = key_col_names;
|
||||
_row_hasher = new BlueRowHasher(key_col_names.Length);
|
||||
}
|
||||
|
||||
public void delete_rows(IBlueRowCollection rows)
|
||||
{
|
||||
if (rows != null)
|
||||
{
|
||||
_init_schema(rows.schema);
|
||||
foreach (IBlueRow r in rows)
|
||||
{
|
||||
int row_hash = _row_hasher.get_hash(r, _key_col_indices);
|
||||
if (_row_map.ContainsKey(row_hash))
|
||||
_row_map.Remove(row_hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void add_rows(IBlueRowCollection rows)
|
||||
{
|
||||
if (rows != null)
|
||||
{
|
||||
_init_schema(rows.schema);
|
||||
foreach (IBlueRow r in rows)
|
||||
{
|
||||
int row_hash = _row_hasher.get_hash(r, _key_col_indices);
|
||||
_row_map[row_hash] = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reset_state (IBlueRowCollection rows)
|
||||
{
|
||||
_row_map.Clear();
|
||||
add_rows(rows);
|
||||
}
|
||||
|
||||
public IEnumerable<IBlueRow> get_all_rows() { return _row_map.Values; }
|
||||
|
||||
private void _init_schema(IBlueTableSchema schema)
|
||||
{
|
||||
if (_key_col_indices == null)
|
||||
_key_col_indices = BlueDataUtility.get_column_indices(schema, _key_col_names);
|
||||
}
|
||||
|
||||
public IBlueRow get_row(params object[] key_vals)
|
||||
{
|
||||
int row_hash = _row_hasher.get_hash(key_vals);
|
||||
IBlueRow rv = null;
|
||||
_row_map.TryGetValue(row_hash, out rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user