public bool TryUnion(RowScanPlanItem rowScan2) { var c1 = GetOnlySymbolScan(); var c2 = rowScan2.GetOnlySymbolScan(); if (c1 != null && c2 != null && c1.ColumnID == c2.ColumnID) { switch (c1.DataType.ColumnType) { case EFieldType.Byte: _partitionFilter = new SymbolFilter <byte>(c1, ExtractColumnContains <byte>(c1).Concat(rowScan2.ExtractColumnContains <byte>(c2)) .Distinct().ToArray()); break; case EFieldType.Bool: _partitionFilter = new SymbolFilter <bool>(c1, ExtractColumnContains <bool>(c1).Concat(rowScan2.ExtractColumnContains <bool>(c2)) .Distinct().ToArray()); break; case EFieldType.Int16: _partitionFilter = new SymbolFilter <Int16>(c1, ExtractColumnContains <Int16>(c1).Concat(rowScan2.ExtractColumnContains <Int16>(c2)) .Distinct().ToArray()); break; case EFieldType.Int32: _partitionFilter = new SymbolFilter <int>(c1, ExtractColumnContains <int>(c1).Concat(rowScan2.ExtractColumnContains <int>(c2)) .Distinct().ToArray()); break; case EFieldType.Int64: _partitionFilter = new SymbolFilter <long>(c1, ExtractColumnContains <long>(c1).Concat(rowScan2.ExtractColumnContains <long>(c2)) .Distinct().ToArray()); break; case EFieldType.Double: _partitionFilter = new SymbolFilter <double>(c1, ExtractColumnContains <double>(c1) .Concat(rowScan2.ExtractColumnContains <double>(c2)) .Distinct().ToArray()); break; case EFieldType.Symbol: case EFieldType.String: _partitionFilter = new SymbolFilter <string>(c1, ExtractColumnContains <string>(c1) .Concat(rowScan2.ExtractColumnContains <string>(c2)) .Distinct().ToArray()); break; case EFieldType.DateTime: case EFieldType.DateTimeEpochMs: _partitionFilter = new SymbolFilter <DateTime>(c1, ExtractColumnContains <DateTime>(c1) .Concat(rowScan2.ExtractColumnContains <DateTime>(c2)) .Distinct().ToArray()); break; default: return(false); } return(true); } return(false); }
public bool TryIntersect(RowScanPlanItem rowScan2) { if (_partitionFilter is IColumnFilter && rowScan2._partitionFilter is IColumnFilter) { if (_andFilters == null) { _andFilters = new List <IRowFilter>(); } var thisMain = (IColumnFilter)_partitionFilter; var thatMain = (IColumnFilter)rowScan2._partitionFilter; if (thisMain.GetCardinality(_journal, _tx) > thatMain.GetCardinality(_journal, _tx)) { _andFilters.Add(thisMain); _partitionFilter = rowScan2._partitionFilter; if (rowScan2._andFilters != null) { _andFilters.AddRange(rowScan2._andFilters); } } else { _andFilters.Add(thatMain); if (rowScan2._andFilters != null) { _andFilters.AddRange(rowScan2._andFilters); } } return(true); } else if (_partitionFilter is IColumnFilter) { if (_andFilters == null) { _andFilters = new List <IRowFilter>(); } var thisMain = (IColumnFilter)_partitionFilter; _andFilters.Add(thisMain); _partitionFilter = rowScan2._partitionFilter; if (rowScan2._andFilters != null) { _andFilters.AddRange(rowScan2._andFilters); } return(true); } else if (rowScan2._partitionFilter is IColumnFilter) { if (_andFilters == null) { _andFilters = new List <IRowFilter>(); } var thatMain = (IColumnFilter)rowScan2._partitionFilter; _andFilters.Add(thatMain); if (rowScan2._andFilters != null) { _andFilters.AddRange(rowScan2._andFilters); } return(true); } return(false); }