public Obj Copy(int idx1, int idx2, int idx3) { if (count == 0) { return(EmptyRelObj.Singleton()); } Obj[] objs1 = new Obj[count]; Obj[] objs2 = new Obj[count]; Obj[] objs3 = new Obj[count]; int len = tuples.Length; int next = 0; for (uint i = 0; i < len; i++) { Tuple tuple = tuples[i]; if (tuple.field2OrEmptyMarker != Tuple.Empty) { objs1[next] = store1.GetValue(tuple.field1OrNext); objs2[next] = store2.GetValue(tuple.field2OrEmptyMarker); objs3[next] = store3.GetValue(tuple.field3); next++; } } Miscellanea.Assert(next == count); Obj[][] cols = new Obj[3][]; cols[idx1] = objs1; cols[idx2] = objs2; cols[idx3] = objs3; return(Builder.CreateTernRel(cols[0], cols[1], cols[2], count)); }
public static Obj CreateSet(Obj[] objs, long count) { Miscellanea.Assert(objs.Length >= count); if (count != 0) { Obj[] norm_objs = Algs.SortUnique(objs, (int)count); return(new NeSetObj(norm_objs)); } else { return(EmptyRelObj.Singleton()); } }
public static Obj CreateBinRel(Obj[] col1, Obj[] col2, long count) { Miscellanea.Assert(count <= col1.Length & count <= col2.Length); if (count != 0) { Obj[] norm_col_1, norm_col_2; Algs.SortUnique(col1, col2, (int)count, out norm_col_1, out norm_col_2); return(new NeBinRelObj(norm_col_1, norm_col_2, !Algs.SortedArrayHasDuplicates(norm_col_1))); } else { return(EmptyRelObj.Singleton()); } }
public static Obj CreateTernRel(Obj[] col1, Obj[] col2, Obj[] col3, long count) { Miscellanea.Assert(count <= col1.Length && count <= col2.Length && count <= col3.Length); if (col1.Length != 0) { Obj[] norm_col_1, norm_col_2, norm_col_3; Algs.SortUnique(col1, col2, col3, (int)count, out norm_col_1, out norm_col_2, out norm_col_3); return(new NeTernRelObj(norm_col_1, norm_col_2, norm_col_3)); } else { return(EmptyRelObj.Singleton()); } }
public Obj Copy(bool flipped) { int count = table1.count; if (count == 0) { return(EmptyRelObj.Singleton()); } Obj[] objs1 = new Obj[count]; Obj[] objs2 = new Obj[count]; int next = 0; for (uint i = 0; i < table1.column.Length; i++) { uint code = table1.column[i]; if (code != OverflowTable.EmptyMarker) { Obj val1 = store1.GetValue(i); if (code >> 29 == 0) { objs1[next] = val1; objs2[next++] = store2.GetValue(code); } else { OverflowTable.Iter it = table1.overflowTable.GetIter(code); while (!it.Done()) { uint surr2 = it.Get(); objs1[next] = val1; objs2[next++] = store2.GetValue(surr2); it.Next(); } } } } Miscellanea.Assert(next == count); return(Builder.CreateBinRel(flipped ? objs2 : objs1, flipped ? objs1 : objs2, count)); //## THIS COULD BE MADE MORE EFFICIENT }
public Obj Copy() { if (count == 0) { return(EmptyRelObj.Singleton()); } Obj[] objs = new Obj[count]; int next = 0; for (uint i = 0; i < bitmap.Length; i++) { ulong mask = bitmap[i]; for (uint j = 0; j < 64; j++) { if (((mask >> (int)j) & 1) != 0) { objs[next++] = store.GetValue(j + 64 * i); } } } Miscellanea.Assert(next == count); return(Builder.CreateSet(objs, objs.Length)); }
override public Obj AsObj() { return(EmptyRelObj.Singleton()); }
//////////////////////////////////////////////////////////////////////////////// static long ParseUnordColl(Token[] tokens, long offset, out Obj var) { int length = tokens.Length; if (++offset >= length) { var = null; return(-offset - 1); } if (tokens[offset].type == TokenType.CloseBracket) { var = EmptyRelObj.Singleton(); return(offset + 1); } State state = new State(1); offset = ReadList(tokens, offset, TokenType.Comma, TokenType.Whatever, ReadObj, state); if (offset < 0) { var = null; return(offset); } TokenType type = tokens[offset++].type; int count = state.Count(); bool isMap = type == TokenType.Arrow & count == 1; bool isRel = type == TokenType.Semicolon & (count == 2 | count == 3); if (isMap) { offset = ReadObj(tokens, offset, state); if (offset >= length) { offset = -offset - 1; } if (offset < 0) { var = null; return(offset); } type = tokens[offset++].type; } else if (isRel && offset < length && tokens[offset].type == TokenType.CloseBracket) { type = TokenType.CloseBracket; offset++; } if (type == TokenType.CloseBracket) { count = state.Count(); if (isMap | (isRel & count == 2)) { var = Builder.CreateBinRel(state.cols[0][0], state.cols[0][1]); } else if (isRel) { var = Builder.CreateTernRel(state.cols[0][0], state.cols[0][1], state.cols[0][2]); } else { var = Builder.CreateSet(state.cols[0]); } return(offset); } if (isMap | isRel) { Obj[] entry = new Obj[3]; for (int i = 0; i < state.Count(); i++) { entry[i] = state.cols[0][i]; } return(ParseRelTail(tokens, offset, (uint)state.Count(), entry, isMap, out var)); } var = null; return(-offset); }