public OSqlCreateProperty Property(string propertyName, OType type) { _propertyName = propertyName; _type = type; _sqlQuery.Property(_propertyName, _type); return this; }
public static OGroup TypeToGroup(OType t) { switch (t) { case OType.noop: return OGroup.noop; case OType.fx: case OType.fy: return OGroup.fz; case OType.xfx: case OType.xfy: case OType.yfx: return OGroup.zfz; case OType.xf: case OType.yf: return OGroup.zf; } throw new Exception("*** Illegal call to TypeToGroup"); }
public static string GetTypeByProposition(string proposition) { if (AType.IsTrue(proposition)) { return(AType.GetPropositionType().ToUpper()); } if (EType.IsTrue(proposition)) { return(EType.GetPropositionType().ToUpper()); } if (IType.IsTrue(proposition)) { return(IType.GetPropositionType().ToUpper()); } if (OType.IsTrue(proposition)) { return(OType.GetPropositionType().ToUpper()); } //TODo:- Add Hidden & Exclusive Proportion return(INVALIDTYPE); }
public static string GetImplicatedProposition(string proposition) { if (AType.IsTrue(proposition)) { return(AType.ImplicateProposition(proposition).ToUpper()); } if (EType.IsTrue(proposition)) { return(EType.ImplicateStatement(proposition).ToUpper()); } if (IType.IsTrue(proposition)) { return(IType.ImplicateStatement(proposition).ToUpper()); } if (OType.IsTrue(proposition)) { return(OType.ImplicateStatement(proposition).ToUpper()); } //TODo:- Add Hidden & Exclusive Proportion return(INVALIDTYPE); }
public static string GetConvertedProposition(string statement) { if (AType.IsTrue(statement)) { return(AType.ConvertProposition(statement).ToUpper()); } if (EType.IsTrue(statement)) { return(EType.ConvertStatement(statement).ToUpper()); } if (IType.IsTrue(statement)) { return(IType.ConvertStatement(statement).ToUpper()); } if (OType.IsTrue(statement)) { return(OType.ConvertStatement(statement).ToUpper()); } //TODo:- Add Hidden & Exclusive Proportion return(INVALIDTYPE); }
public static string GetStatementByType(string type) { if (AType.IsTrue(type)) { return(AType.GetStatementTemplate()); } if (EType.IsTrue(type)) { return(EType.GetStatementTemplate()); } if (IType.IsTrue(type)) { return(IType.GetStatementTemplate()); } if (OType.IsTrue(type)) { return(OType.GetStatementTemplate()); } return(INVALIDTYPE); }
public Term(string op, Term t, OType ot, int prec) { _functor = op; args = new Term[1]; args[0] = t; arity = 1; fType = FType.comp; oType = ot; precedence = (short)prec; }
public bool IsDefinedAsPrefix(out string op, out int pr, out OType ot) { op = name; ot = type[0]; pr = prec[0]; return (pr != -1); }
public OSqlCreateProperty LinkedType(OType type) { _sqlQuery.LinkedType(type); return this; }
public OperationTypeAttribute(OType type) { Type = type; }
private OType? getLinkedType(OType type, String key) { if (type != OType.EmbeddedList && type != OType.EmbeddedSet && type != OType.EmbeddedMap) return null; throw new NotImplementedException("Linked Type still not implemented"); }
public OpRec(int p, OType t, string o) { Pr = p; Fx = t.ToString(); Op = o; }
public Term(string op, Term a1, Term a2, FType ft, OType ot, int prec) { _functor = op; args = new Term[2]; args[0] = a1; args[1] = a2; arity = 2; fType = ft; // comp or dcg oType = ot; precedence = (short)prec; }
public Term(string s, OperatorDescr od, Term[] a, OType ot, int prec) { _functor = s; args = a; arity = (short)a.Length; oDescr = od; fType = (arity == 0) ? FType.atom : FType.comp; oType = ot; precedence = (short)prec; }
public Term(object _f, short ar, FType ft, OType ot, short prec) // used only bye CleanCopy and CleanUpEx { _functor = _f; arity = ar; args = new Term[arity]; fType = ft; oType = ot; precedence = prec; }
public DataPickerDialog(OType type) { InitializeComponent(); SelectedType = type; }
public bool IsPredefined(OType type, string name) { int g = (int)TypeToGroup(type); return (prec[g] != -1 && !user[g]); }
public string OTypeToString(OType objectiveType) { return oTypeTo [objectiveType]; }
public Term(string op, OType ot, int prec) { _functor = op; fType = FType.atom; oType = ot; precedence = (short)prec; }
private int writeOType(BinaryBuffer buffer, Object value, OType valueType, OType? linkedType) { int pointer = 0; switch (valueType) { case OType.Integer: case OType.Long: case OType.Short: pointer = buffer.WriteVariant(Convert.ToInt32(value)); break; case OType.String: pointer = buffer.Write((string)value); break; case OType.Double: pointer = buffer.Write((double)value); break; case OType.Float: pointer = buffer.Write((float)value); break; case OType.Byte: pointer = buffer.Write((byte)value); break; case OType.Boolean: pointer = buffer.Write(((bool)value) ? (byte)1 : (byte)0); break; case OType.DateTime: DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); pointer = buffer.WriteVariant((long)((DateTime)value - unixEpoch).TotalMilliseconds); break; //case OType.Decimal: // /* // * The Decimal is converted to an integer and stored as scale and value // * (example "10234.546" is stored as scale "3" and value as:"10234546") // * +---------------+-------------------+--------------+ // * | scale:byte[4] | valueSize:byte[4] | value:byte[] | // * +---------------+-------------------+--------------+ // * scale an 4 byte integer that represent the scale of the value // * valueSize the length of the value // * bytes value the bytes that represent the value of the decimal in big-endian order. // */ // var dec = ((decimal)value); // byte[] bytes = BinarySerializer.ToArray(dec); // var unscaledValueBytes = FromDecimal(dec); // var unscaledValue = new BigInteger(unscaledValueBytes); // break; case OType.Link: ORID rid = (ORID)value; pointer = buffer.Write(rid); break; case OType.LinkList: case OType.LinkSet: var col = (ICollection<ORID>)value; pointer = buffer.WriteVariant(col.Count); foreach (var item in col) { if (item == null) { buffer.Write(NULL_RECORD_ID); } else { buffer.Write(item); } } break; case OType.LinkBag: break; default: throw new NotImplementedException("Type " + valueType + " still not supported"); } return pointer; }
public Term(OperatorDescr od) // Term consisting of an operator only (used at Term construction time only) { string op; int pr; OType ot; if (od.IsDefinedAsInfix(out op, out pr, out ot)) { _functor = od.Name; arity = 2; oType = ot; oDescr = od; precedence = (short)pr; } else if (od.IsDefinedAsPrefix(out op, out pr, out ot)) { _functor = od.Name; arity = 1; oType = ot; oDescr = od; precedence = (short)pr; } else if (od.IsDefinedAsPostfix(out op, out pr, out ot)) { _functor = od.Name; arity = 1; oType = ot; oDescr = od; precedence = (short)pr; } fType = FType.opr; }
private void readOType(BinaryReader reader, string fieldName, ODocument document, OType type) { switch (type) { case OType.Integer: document.SetField<int>(fieldName, readAsInteger(reader)); break; case OType.Long: document.SetField<long>(fieldName, readAsLong(reader)); break; case OType.Short: document.SetField<short>(fieldName, readAsShort(reader)); break; case OType.String: document.SetField<string>(fieldName, readString(reader)); break; case OType.Double: document.SetField<double>(fieldName, BitConverter.Int64BitsToDouble(readLong(reader))); break; case OType.Float: document.SetField<float>(fieldName, readFloat(reader)); break; case OType.Decimal: var scale = reader.ReadInt32EndianAware(); var valueSize = reader.ReadInt32EndianAware(); // read Fine the value var valuex = reader.ReadBytesRequired(valueSize); Int64 x1 = 0; if ((valuex[0] & 0x80) == 0x80) x1 = (sbyte)valuex[0]; else x1 = valuex[0]; for (int i = 1; i < valuex.Length; i++) { x1 = (x1 << 8) | valuex[i]; } try { document.SetField(fieldName, new Decimal(x1 * Math.Pow(10, (-1) * scale))); } catch (OverflowException) { document.SetField(fieldName, x1 * Math.Pow(10, (-1) * scale)); } break; case OType.Byte: document.SetField<byte>(fieldName, reader.ReadByte()); break; case OType.Boolean: document.SetField<bool>(fieldName, reader.ReadByte() == 1 ? true : false); break; case OType.DateTime: document.SetField<DateTime>(fieldName, readDateTime(reader)); break; case OType.Date: document.SetField<DateTime>(fieldName, readDate(reader)); break; case OType.EmbeddedList: var listLength = readAsInteger(reader); OType embeddedListRecorType = (OType)reader.ReadByte(); List<Object> embeddedList = new List<Object>(); for (int i = 0; i < listLength; i++) { var d = new ODocument(); OType dataType = (OType)reader.ReadByte(); readOType(reader, i.ToString(), d, dataType); embeddedList.AddRange(d.Values); } document.SetField(fieldName, embeddedList); break; case OType.EmbeddedSet: var embeddedSetLen = readAsInteger(reader); OType embeddedSetRecorType = (OType)reader.ReadByte(); HashSet<ODocument> embeddedSet = new HashSet<ODocument>(); for (int i = 0; i < embeddedSetLen; i++) { var d = new ODocument(); OType dataType = (OType)reader.ReadByte(); readOType(reader, "", d, dataType); embeddedSet.Add(d); } document.SetField(fieldName, embeddedSet); break; case OType.EmbeddedMap: /* * header:headerStructure | values:valueStructure * headerStructure * =============== * keyType:byte | keyValue:byte[] * * valueStructure * ============== * valueType:byte | value:byte[] */ var size = readAsInteger(reader); var fd = new FieldDefinition[size]; Dictionary<string, Object> map = new Dictionary<string, object>(); for (int i = 0; i < size; i++) { fd[i] = new FieldDefinition(); var d = new ODocument(); var keyType = (OType)reader.ReadByte(); if (keyType != OType.String) throw new NotImplementedException("key type " + keyType + " not implemented for EmbededMap"); readOType(reader, "key", d, keyType); fd[i].FieldName = d.GetField<string>("key"); fd[i].Pointer = reader.ReadInt32EndianAware(); fd[i].DataType = (OType)reader.ReadByte(); } for (int i = 0; i < size; i++) { var d = new ODocument(); if (fd[i].Pointer > 0) { readOType(reader, "value", d, fd[i].DataType); map.Add(fd[i].FieldName, d.GetField<object>("value")); } else { map.Add(fd[i].FieldName, null); } } document.SetField<Dictionary<string, Object>>(fieldName, map); break; case OType.Embedded: var version = reader.ReadByte(); parseDocument(reader, document); break; case OType.Link: var claster = readAsLong(reader); var record = readAsLong(reader); document.SetField(fieldName, new ORID((short)claster, record)); break; case OType.LinkBag: var rids = new HashSet<ORID>(); var config = reader.ReadByte(); if ((config & 2) == 2) { // uuid parsing is not implemented config += 16; } if ((config & 1) == 1) // 1 - embedded,0 - tree-based { var entriesSize = reader.ReadInt32EndianAware(); for (int j = 0; j < entriesSize; j++) { var clusterid = reader.ReadInt16EndianAware(); var clusterposition = reader.ReadInt64EndianAware(); rids.Add(new ORID(clusterid, clusterposition)); } } else { throw new NotImplementedException("tree based ridbag"); } document.SetField(fieldName, rids); break; case OType.LinkList: var linkList = readLinkCollection(reader); document.SetField(fieldName, linkList); break; case OType.LinkSet: var linkSet = new HashSet<ORID>(readLinkCollection(reader)); document.SetField(fieldName, linkSet); break; case OType.Any: break; default: throw new OException(OExceptionType.Deserialization, "The field type: " + type.ToString() + "not implemented"); } }
public Term(string op, Term[] terms, FType ft, OType ot, int prec) { _functor = op; arity = (short)terms.Length; args = terms; fType = ft; oType = ot; precedence = (short)prec; }
public Term(ClauseNode c) // Create a Term from a ClauseNode (= Head + Body) { if (c.NextNode == null) // fact { Term t = c.Term; _functor = t._functor; arity = t.arity; args = t.args; varNo = t.varNo; ULink = t.ULink; fType = t.fType; oType = t.oType; oDescr = t.oDescr; precedence = t.precedence; hasValue = t.hasValue; isUnified = t.isUnified; isPacked = t.isPacked; } else { _functor = Parser.IMPLIES; arity = 2; args = new Term[2]; args[0] = c.Term; fType = FType.comp; oType = OType.xfx; args[1] = TermSeq(c.NextNode); precedence = 1200; } }
private static bool CheckOperatorClash(Term t0, string op1, int pr1, OType ot1, bool genXcp) { if (t0 == null || t0.isPacked) return true; bool ambig = false; bool ok = true; string op0 = t0.functor; int pr0 = t0.precedence; OType ot0 = t0.oType; // Console.WriteLine ("CheckOperatorClash {0} {1} {2} <=> {3} {4} {5}", op0, pr0, ot0, op1, pr1, ot1); // Console.WriteLine ("ActionCodeEx {0}", ActionCodeEx [(int)ot0, (int)ot1]); switch (ActionCodeEx[(int)ot0, (int)ot1]) // t0 and t1 are in the left-to-right order corresponding to the input expression { case 16: // xf xf case 18: // xf xfx case 19: // xf xfy case 23: // yf xf case 25: // yf xfx case 26: // yf xfy ok = (pr0 < pr1); break; case 17: // xf yf case 20: // xf yfx case 24: // yf yf case 27: // yf yfx ok = (pr0 <= pr1); break; case 00: // fx fx case 01: // fx fy case 28: // xfx fx case 29: // xfx fy case 42: // yfx fx case 43: // yfx fy ok = (pr0 > pr1); break; case 07: // fy fx case 08: // fy fy case 35: // xfy fx case 36: // xfy fy ok = (pr0 >= pr1); break; case 04: // fx xfx case 05: // fx xfy case 32: // xfx xfx case 33: // xfx xfy case 34: // xfx yfx case 39: // xfy xfx case 41: // xfy yfx case 46: // yfx xfx case 47: // yfx xfy ok = (pr0 != pr1); break; case 10: // fy yf case 13: // fy yfx case 38: // xfy yf ambig = (pr0 == pr1); ok = (!ambig); break; case 03: // fx yf case 06: // fx yfx case 09: // fy xf case 11: // fy xfx case 12: // fy xfy case 31: // xfx yf case 37: // xfy xf case 40: // xfy xfy case 45: // yfx yf case 48: // yfx yfx break; case 02: // fx xf case 30: // xfx xf case 44: // yfx xf ok = false; break; // the following situations cannot occur at all: f:f case 14: // xf fx case 15: // xf fy case 21: // yf fx case 22: // yf fy PrologIO.Error("CheckOperatorClash -- unexpected operator combination {0} {1} {2} with {3} {4} {5}", op0, pr0, ot0, op1, pr1, ot1); break; } if (!ok && genXcp) { if (ambig) PrologIO.Error("Ambiguous operator combination: {0} ({1} {2}) with {3} ({4} {5})", op0, pr0, ot0, op1, pr1, ot1); else PrologIO.Error("Operator precedence clash: {0} ({1} {2}) with {3} ({4} {5})", op0, pr0, ot0, op1, pr1, ot1); return false; } else return ok; }
private void validateMetadata(ODocument metadata, OType expectedType) { Assert.IsNotNull(metadata); Assert.AreEqual(expectedType, (OType)metadata.GetField<int>("type")); }
private void ExecuteAtomicOperation(ref Stack <ExpressionNode> stack, ref Stack <CompleteOperation> operations, CompleteOperation current, CompleteOperation previous) { OType type = current.Type; switch (type) { case OType.Arithmetic: { if (previous == null || previous.Type != OType.Value && previous.Type != OType.Method) { // WATCH: previous.Type != OType.Method used for handle external constant // HACK: need to change later // if leading sign if (current.OriginalOperation == Operation.Addition || current.OriginalOperation == Operation.Substraction) { stack.Push(new ExpressionValue(0)); } } if (operations.Count == 0) { operations.Push(current); } else { while (operations.Count > 0 && operations.Peek().Priority >= current.Priority) { CreateNode(ref stack, operations.Pop().OriginalOperation); } operations.Push(current); } } break; case OType.Separator: { if (current.OriginalOperation == Operation.OpenBracket) { if (operations.Count > 0 && operations.Peek().Type == OType.Method) { var temp = operations.Pop(); operations.Push(current); operations.Push(temp); } else { operations.Push(current); } } else if (current.OriginalOperation == Operation.CloseBracket) { int argsCount = 0; while (operations.Count > 0) { var temp = operations.Pop(); if (temp.Type == OType.Arithmetic) { CreateNode(ref stack, temp.OriginalOperation); } else if (temp.Type == OType.Method) { if (stack.Count >= argsCount) { var method = aggregation.GetMethod(temp.Value); if (method.HasValue) { if (!method.Value.IsMatchArgs(++argsCount)) { throw new InvalidOperationException("no signature match for passed arguments"); } var _params = new List <ExpressionNode>(); for (int i = 0; i < argsCount; i++) { _params.Add(stack.Pop()); } _params.Reverse(); stack.Push(new ExpressionExternMethod(aggregation, method.Value.Name, method.Value.IsStatic, _params.ToArray())); } } else { throw new Exception("exception"); } } else if (temp.Type == OType.Separator) { argsCount++; } if (temp.OriginalOperation == Operation.OpenBracket) { break; } } } else if (current.OriginalOperation == Operation.Comma) { while (operations.Peek().Type != OType.Method && operations.Peek().Type != OType.Separator) { CreateNode(ref stack, operations.Pop().OriginalOperation); } operations.Push(new CompleteOperation(',')); } } break; case OType.Value: { stack.Push(new ExpressionValue(double.Parse(current.Value))); } break; case OType.Method: { Aggregation.Lib.Constant?constant = null; if ((constant = aggregation.GetConstant(current.Value)) != null) { stack.Push(new ExpressionExternConstant(aggregation, current.Value)); } else { operations.Push(current); } } break; } }