Example #1
0
        /// <summary>
        /// Returns the label symbol(a string representation) of the symbol table if it exists, otherwise
        /// an exception is thrown.
        /// </summary>
        /// <param name="table"> the symbol table </param>
        /// <returns> the label (a string representation) of the symbol table if it exists. </returns>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public String getLabelSymbol(org.maltparser.core.symbol.SymbolTable table) throws org.maltparser.core.exception.MaltChainedException
        public string getLabelSymbol(SymbolTable table)
        {
            LWDependencyGraph graph  = (LWDependencyGraph)BelongsToGraph;
            ColumnDescription column = graph.DataFormat.GetColumnDescription(table.Name);

            return(labels[column]);
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void resetTokens(String[] inputTokens, String defaultRootLabel, boolean addEdges) throws org.maltparser.core.exception.MaltChainedException
        public void resetTokens(string[] inputTokens, string defaultRootLabel, bool addEdges)
        {
            nodes.Clear();
            comments.Clear();
            symbolTables.cleanUp();
            // Add nodes
            nodes.Add(new LWNode(this, 0));             // ROOT
            for (int i = 0; i < inputTokens.Length; i++)
            {
                nodes.Add(new LWNode(this, i + 1));
            }

            for (int i = 0; i < inputTokens.Length; i++)
            {
                nodes[i + 1].addColumnLabels(inputTokens[i].Split(TAB_SIGN, true), addEdges);
            }
            // Check graph
            for (int i = 0; i < nodes.Count; i++)
            {
                if (nodes[i].HeadIndex >= nodes.Count)
                {
                    throw new LWGraphException("Not allowed to add a head node that doesn't exists");
                }
            }

            for (int i = 0; i < dataFormat.NumberOfColumns(); i++)
            {
                ColumnDescription column = dataFormat.GetColumnDescription(i);
                if (!column.Internal && column.Category == ColumnDescription.DependencyEdgeLabel)
                {
                    rootLabels.setDefaultRootLabel(symbolTables.getSymbolTable(column.Name), defaultRootLabel);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Returns the label code (an integer representation) of the symbol table if it exists, otherwise
        /// an exception is thrown.
        /// </summary>
        /// <param name="table"> the symbol table </param>
        /// <returns> the label code (an integer representation) of the symbol table if it exists </returns>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public int getLabelCode(org.maltparser.core.symbol.SymbolTable table) throws org.maltparser.core.exception.MaltChainedException
        public int getLabelCode(SymbolTable table)
        {
            LWDependencyGraph graph  = (LWDependencyGraph)BelongsToGraph;
            ColumnDescription column = graph.DataFormat.GetColumnDescription(table.Name);

            return(table.getSymbolStringToCode(labels[column]));
        }
Example #4
0
        private void AddSwaggerUdtIfNeeded(ColumnDescription columnDescription)
        {
            var udtName = (columnDescription.CassandraType.ToLowerInvariant() == "list")
                ? columnDescription.CSharpType.Replace("List<", "").Replace(">", "")
                : columnDescription.CSharpType;
            var udtNameCassandrified = Utils.Utils.CassandrifyName(udtName);
            var udtDef = this.session.Cluster.Metadata.GetUdtDefinition(this.keySpaceName.ToLowerInvariant(), udtNameCassandrified);

            if (udtDef != null && this.swaggerRoot.Definitions.Keys.All(k => k != udtName))
            {
                var schema = new Schema {
                    Type = "object", Properties = new Dictionary <string, Schema>()
                };

                foreach (var field in udtDef.Fields)
                {
                    var csharpType     = this.GetCSharpTypeName(field);
                    var propertySchema = new Schema
                    {
                        Type   = GetSwaggerType(csharpType),
                        Format = GetSwaggerFormat(csharpType),
                    };
                    schema.Properties.Add(Utils.Utils.CamelCase(field.Name), propertySchema);
                }

                this.swaggerRoot.Definitions.Add(udtName, schema);
            }
        }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void init(String setSpec) throws org.maltparser.core.exception.MaltChainedException
        public virtual void init(string setSpec)
        {
            string spec = setSpec.Trim();

            string[] disItems = spec.Split("\\|", true);
            for (int i = 0; i < disItems.Length; i++)
            {
                string[] conItems = spec.Split("\\&", true);
                for (int j = 0; j < conItems.Length; j++)
                {
                    int index = conItems[j].IndexOf(':');
                    if (index != -1)
                    {
                        SymbolTable       table  = prioList.SymbolTableHandler.getSymbolTable(conItems[j].Substring(0, index));
                        ColumnDescription column = prioList.DataFormatInstance.getColumnDescriptionByName(conItems[j].Substring(0, index));
                        if (i == 0 && j == 0)
                        {
                            addPrioSetMember(table, column, conItems[j].Substring(index + 1), RelationToPrevMember.START);
                        }
                        else if (j == 0)
                        {
                            addPrioSetMember(table, column, conItems[j].Substring(index + 1), RelationToPrevMember.DISJUNCTION);
                        }
                        else
                        {
                            addPrioSetMember(table, column, conItems[j].Substring(index + 1), RelationToPrevMember.CONJUNCTION);
                        }
                    }
                    else
                    {
                        throw new HeadRuleException("The specification of the priority list is not correct '" + setSpec + "'. ");
                    }
                }
            }
        }
Example #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void removeLabel(org.maltparser.core.symbol.SymbolTable table) throws org.maltparser.core.exception.MaltChainedException
        public void removeLabel(SymbolTable table)
        {
            LWDependencyGraph graph  = (LWDependencyGraph)BelongsToGraph;
            ColumnDescription column = graph.DataFormat.GetColumnDescription(table.Name);

            labels.Remove(column);
        }
Example #7
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < graph.DataFormat.NumberOfColumns(); i++)
            {
                ColumnDescription column = graph.DataFormat.GetColumnDescription(i);

                if (!column.Internal)
                {
                    if (column.Category == ColumnDescription.Head)
                    {
                        sb.Append(HeadIndex);
                    }
                    else if (column.Category == ColumnDescription.Input || column.Category == ColumnDescription.DependencyEdgeLabel)
                    {
                        sb.Append(labels[column.Position]);
                    }
                    else if (column.Category == ColumnDescription.Ignore)
                    {
                        sb.Append(column.DefaultOutput);
                    }

                    sb.Append('\t');
                }
            }

            sb.Length = (sb.Length > 0)?sb.Length - 1:0;

            return(sb.ToString());
        }
Example #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(Object[] arguments) throws org.maltparser.core.exception.MaltChainedException
        public void initialize(object[] arguments)
        {
            if (arguments.Length != 2)
            {
                throw new FeatureException("Could not initialize PrefixFeature: number of arguments are not correct. ");
            }
            if (!(arguments[0] is FeatureFunction))
            {
                throw new FeatureException("Could not initialize PrefixFeature: the first argument is not a feature. ");
            }
            if (!(arguments[1] is int?))
            {
                throw new FeatureException("Could not initialize PrefixFeature: the second argument is not a string. ");
            }
            ParentFeature = (FeatureFunction)arguments[0];
            PrefixLength  = ((int?)arguments[1]).Value;
            ColumnDescription parentColumn = dataFormatInstance.getColumnDescriptionByName(parentFeature.SymbolTable.Name);

            if (parentColumn.Type != ColumnDescription.STRING)
            {
                throw new FeatureException("Could not initialize PrefixFeature: the first argument must be a string. ");
            }
            Column      = dataFormatInstance.addInternalColumnDescription(tableHandler, "PREFIX_" + prefixLength + "_" + parentFeature.SymbolTable.Name, parentColumn);
            SymbolTable = tableHandler.getSymbolTable(column.Name);
            //		setSymbolTable(tableHandler.addSymbolTable("PREFIX_"+prefixLength+"_"+parentFeature.getSymbolTable().getName(), parentFeature.getSymbolTable()));
        }
Example #9
0
        private static void NormalizeCellValue(CellValue cellValue, string str, ColumnDescription column, DatatypeDescription datatype)
        {
            // 6. if the string is an empty string, apply the remaining steps to the string given by the column default annotation.
            if (string.Empty.Equals(str))
            {
                str = column.Default;
            }

            // 7. if the string is the same as any one of the values of the column null annotation, then the resulting value is null.
            // If the column separator annotation is null and the column required annotation is true, add an error to the list of errors for the cell.
            if (column.Null.Contains(str))
            {
                str = null;
                if (column.Separator == null && column.Required)
                {
                    cellValue.Errors.Add("Got NULL value for a required cell");
                }
            }

            /* Still TODO:
             * 8. parse the string using the datatype format if one is specified, as described below to give a value with an associated datatype. If the datatype base is string, or there is no datatype, the value has an associated language from the column lang annotation. If there are any errors, add them to the list of errors for the cell; in this case the value has a datatype of string; if the datatype base is string, or there is no datatype, the value has an associated language from the column lang annotation.
             * 9. validate the value based on the length constraints described in section 4.6.1 Length Constraints, the value constraints described in section 4.6.2 Value Constraints and the datatype format annotation if one is specified, as described below. If there are any errors, add them to the list of errors for the cell.
             */
            if (cellValue.IsList)
            {
                cellValue.ValueList.Add(str);
            }
            else
            {
                cellValue.Value = str;
            }
        }
        /// <summary>
        /// Handles a change to selection in the list box.
        /// </summary>
        /// <param name="sender">The Object that originated the event.</param>
        /// <param name="e">The event arguments.</param>
        void OnListBoxSelectionChanged(Object sender, SelectionChangedEventArgs e)
        {
            // This will reconcile the 'Width' dialog box to the ColumnDescription item chosen in the list box.
            ListBox           listBox          = sender as ListBox;
            ColumnDescription columnDefinition = listBox.SelectedItem as ColumnDescription;

            this.WidthTextBox.Text = columnDefinition.Width.ToString();
        }
Example #11
0
 private string GetSwaggerType(ColumnDescription columnDescription)
 {
     if (columnDescription.CassandraType.ToLowerInvariant() == "list")
     {
         return("array");
     }
     return(GetSwaggerType(columnDescription.CSharpType));
 }
Example #12
0
 private string GetSwaggerItemsType(ColumnDescription columnDescription)
 {
     if (columnDescription.CassandraType.ToLowerInvariant() == "list" && !columnDescription.IsUdt())
     {
         return(columnDescription.CSharpType.Replace("List<", "").Replace(">", ""));
     }
     return(null);
 }
Example #13
0
 public _EntityColumn(ColumnDescription entityColumn, object queryName)
     : base(new ColumnToken(entityColumn, queryName), null !)
 {
     if (!entityColumn.IsEntity)
     {
         throw new ArgumentException("entityColumn");
     }
 }
Example #14
0
        /// <summary>
        /// Adds a label (a string value) to the symbol table and to the graph element.
        /// </summary>
        /// <param name="table"> the symbol table </param>
        /// <param name="symbol"> a label symbol </param>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void addLabel(org.maltparser.core.symbol.SymbolTable table, String symbol) throws org.maltparser.core.exception.MaltChainedException
        public void addLabel(SymbolTable table, string symbol)
        {
            LWDependencyGraph graph  = (LWDependencyGraph)BelongsToGraph;
            ColumnDescription column = graph.DataFormat.GetColumnDescription(table.Name);

            table.addSymbol(symbol);
            labels[column] = symbol;
        }
Example #15
0
        private static void AsExpected(ColumnDescription columnDescription)
        {
            Assert.NotNull(columnDescription);
            DfAssert.NotEmpty(columnDescription.Name);
            DfAssert.GreaterThanOrEqual(columnDescription.Order, 0);

            AsExpected(columnDescription.Identity);
        }
Example #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public PrioSetMember addPrioSetMember(org.maltparser.core.symbol.SymbolTable table, org.maltparser.core.io.dataformat.ColumnDescription column, String symbolString, org.maltparser.core.syntaxgraph.headrules.PrioSetMember.RelationToPrevMember relationToPrevMember) throws org.maltparser.core.exception.MaltChainedException
        public virtual PrioSetMember addPrioSetMember(SymbolTable table, ColumnDescription column, string symbolString, RelationToPrevMember relationToPrevMember)
        {
            if (table == null)
            {
                throw new HeadRuleException("Could add a member to priority set because the symbol table could be found. ");
            }
            return(addPrioSetMember(table, column, table.addSymbol(symbolString), relationToPrevMember));
        }
Example #17
0
 public PrioSetMember(PrioSet prioSet, SymbolTable table, ColumnDescription column, int symbolCode, RelationToPrevMember relationToPrevMember)
 {
     PrioSet    = prioSet;
     Table      = table;
     Column     = column;
     SymbolCode = symbolCode;
     setRelationToPrevMember(relationToPrevMember);
 }
Example #18
0
        /// <summary>
        /// Creates a immutable dependency graph
        /// </summary>
        /// <param name="dataFormat"> a data format that describes the label types (or the columns in the input and output) </param>
        /// <param name="sourceGraph"> a dependency graph that implements the interface org.maltparser.core.syntaxgraph.DependencyStructure </param>
        /// <param name="defaultRootLabel"> the default root label </param>
        /// <exception cref="MaltChainedException"> </exception>
        public ConcurrentDependencyGraph(DataFormat.DataFormat dataFormat, IDependencyStructure sourceGraph, string defaultRootLabel)
        {
            DataFormat = dataFormat;

            nodes = new ConcurrentDependencyNode[sourceGraph.NDependencyNode()];

            // Add nodes
            nodes[0] = new ConcurrentDependencyNode(this, 0, null); // ROOT

            foreach (int index in sourceGraph.TokenIndices)
            {
                DependencyNode gNode = sourceGraph.GetDependencyNode(index);

                string[] columns = new string[dataFormat.NumberOfColumns()];

                for (int i = 0; i < dataFormat.NumberOfColumns(); i++)
                {
                    ColumnDescription column = dataFormat.GetColumnDescription(i);

                    if (!column.Internal)
                    {
                        if (column.Category == ColumnDescription.Input)
                        {
                            columns[i] = gNode.getLabelSymbol(sourceGraph.SymbolTables.getSymbolTable(column.Name));
                        }
                        else if (column.Category == ColumnDescription.Head)
                        {
                            if (gNode.hasHead())
                            {
                                columns[i] = Convert.ToString(gNode.HeadEdge.Source.Index);
                            }
                            else
                            {
                                columns[i] = Convert.ToString(-1);
                            }
                        }
                        else if (column.Category == ColumnDescription.DependencyEdgeLabel)
                        {
                            SymbolTable sourceTable = sourceGraph.SymbolTables.getSymbolTable(column.Name);

                            if (gNode.HeadEdge.hasLabel(sourceTable))
                            {
                                columns[i] = gNode.HeadEdge.getLabelSymbol(sourceTable);
                            }
                            else
                            {
                                columns[i] = defaultRootLabel;
                            }
                        }
                        else
                        {
                            columns[i] = "_";
                        }
                    }
                }
                nodes[index] = new ConcurrentDependencyNode(this, index, columns);
            }
        }
        private void availableColumnsListBox_DoubleClick(object sender, EventArgs e)
        {
            ColumnDescription column = this.availableColumnsListBox.SelectedItem as ColumnDescription;

            if (column != null)
            {
                this.queryEditor.SelectedText = column.ColumnName;
            }
        }
Example #20
0
 public static string SqlDefinition(this ColumnDescription columnDescription) => SqlTypeUtility.GetSqlColumnDefinition(
     columnDescription.Name,
     columnDescription.UserType,
     columnDescription.Nullable,
     columnDescription.MaxLength,
     columnDescription.Precision,
     columnDescription.Scale,
     null,
     null);
Example #21
0
        private string GetSwaggerRef(ColumnDescription columnDescription)
        {
            if (columnDescription.CassandraType == "Udt")
            {
                this.AddSwaggerUdtIfNeeded(columnDescription);
                return(columnDescription.IsUdt() ? $"#/definitions/{columnDescription.CSharpType}" : columnDescription.CSharpType);
            }

            return(null);
        }
Example #22
0
 private string GetSwaggerItemsRef(ColumnDescription columnDescription)
 {
     if (columnDescription.CassandraType.ToLowerInvariant() == "list" && columnDescription.IsUdt())
     {
         var r = columnDescription.CSharpType.Replace("List<", "").Replace(">", "");
         this.AddSwaggerUdtIfNeeded(columnDescription);
         return($"#/definitions/{r}");
     }
     return(null);
 }
Example #23
0
        /*
         *          if (format == null && type == "string")
         *          {
         *              return "text";
         *          }
         *          if (type?.ToLowerInvariant() == "array")
         *          {
         *              return (items.Ref != null) ?
         *                  $"frozen<list<{Utils.Utils.CassandrifyName(GetRefname(items.Ref))}>>"
         *                  :
         *                  $"frozen<list<{GetCassandraType(items.Type, items.Format, items.Items, items.Ref)}>>";
         *          }
         *          if (type?.ToLowerInvariant() == "boolean")
         *          {
         *              return "boolean";
         *          }
         *          if (reference != null)
         *          {
         *              return Utils.Utils.CassandrifyName(GetRefname(reference));
         *          }
         *          switch (format?.ToLowerInvariant())
         *          {
         *              case "int64":
         *                  return "bigint";
         *              case "int32":
         *                  return "int";
         *              case "int16":
         *                  return "int";
         *              case "int8":
         *                  return "int";
         *              case "date-time":
         *                  return "timestamp";
         *              default:
         *                  return null;
         *          }
         **/
        private static string GetSwaggerFormat(ColumnDescription columnDescription)
        {
            if (columnDescription.CSharpType.StartsWith("List"))
            {
                return(null);
            }

            var cSharpType = columnDescription.CSharpType;

            return(GetSwaggerFormat(cSharpType));
        }
Example #24
0
        /// <summary>
        /// Returns <i>true</i> if the graph element has a label for the symbol table, otherwise <i>false</i>.
        /// </summary>
        /// <param name="table"> the symbol table </param>
        /// <returns> <i>true</i> if the graph element has a label for the symbol table, otherwise <i>false</i>. </returns>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean hasLabel(org.maltparser.core.symbol.SymbolTable table) throws org.maltparser.core.exception.MaltChainedException
        public bool hasLabel(SymbolTable table)
        {
            if (table == null)
            {
                return(false);
            }
            LWDependencyGraph graph  = (LWDependencyGraph)BelongsToGraph;
            ColumnDescription column = graph.DataFormat.GetColumnDescription(table.Name);

            return(labels.ContainsKey(column));
        }
Example #25
0
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="T:System.Object"/>.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ColumnName?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (ColumnDescription?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ IsEditable.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)ColumnIODirection;
         return(hashCode);
     }
 }
Example #26
0
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="T:System.Object"/>.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ColumnName != null ? ColumnName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ColumnDescription != null ? ColumnDescription.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ IsEditable.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)ColumnIODirection;
         return(hashCode);
     }
 }
Example #27
0
        private string GetValueString(ManagedMetaObject metaObjectDescriptor, ColumnDescription columnDescription, ManagedObjectBase entry)
        {
            var property = metaObjectDescriptor.Type.GetProperty(columnDescription.Name);
            var value    = property.GetValue(entry);

            if (value == null)
            {
                return("NULL");
            }
            else
            {
                if (columnDescription.IsReference)
                {
                    var data = columnDescription.Type.GetProperty("Key").GetValue(value);
                    return(data.ToString());
                }
                else if (value.GetType() == typeof(DateTime))
                {
                    DateTime?date = value as DateTime?;
                    if (date.HasValue)
                    {
                        return(date.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                    }
                }
                else if (value.GetType() == typeof(TimeSpan))
                {
                    TimeSpan?date = value as TimeSpan?;
                    if (date.HasValue)
                    {
                        return(date.Value.TotalSeconds.ToString());
                    }
                }
                else if (value.GetType().IsEnum)
                {
                    int val = (int)value;
                    return((val).ToString());
                }
                else if (value.GetType() == typeof(bool))
                {
                    bool?date = (bool)value;
                    if (date.HasValue)
                    {
                        return((date.Value ? 1 : 0).ToString());
                    }
                }
                else
                {
                    return(value.ToString());
                }
            }

            return(null);
        }
Example #28
0
        public static bool IsSameColumnDescription(ColumnDescription descr1, ColumnDescription descr2)

        {
            bool result = true;

            result = descr1.ColumnName == descr2.ColumnName;
            result = descr1.DataType == descr2.DataType;
            result = descr1.DataSize == descr2.DataSize;
            result = descr1.DecimalDigits == descr2.DecimalDigits;
            result = descr1.isNullableInt == descr2.isNullableInt;
            return(result);
        }
Example #29
0
 /// <summary>
 /// Returns an edge label
 /// </summary>
 /// <param name="column"> a column description that describes the label </param>
 /// <returns> an edge label described by the column description. An empty string is returned if the label is not found.  </returns>
 public string GetLabel(ColumnDescription column)
 {
     if (labels.ContainsKey(column.Position))
     {
         return(labels[column.Position]);
     }
     else if (column.Category == ColumnDescription.Ignore)
     {
         return(column.DefaultOutput);
     }
     return("");
 }
Example #30
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public PrioSetMember addPrioSetMember(org.maltparser.core.symbol.SymbolTable table, org.maltparser.core.io.dataformat.ColumnDescription column, int symbolCode, org.maltparser.core.syntaxgraph.headrules.PrioSetMember.RelationToPrevMember relationToPrevMember) throws org.maltparser.core.exception.MaltChainedException
        public virtual PrioSetMember addPrioSetMember(SymbolTable table, ColumnDescription column, int symbolCode, RelationToPrevMember relationToPrevMember)
        {
            cache.Table      = table;
            cache.SymbolCode = symbolCode;
            if (!Contains(cache))
            {
                PrioSetMember newItem = new PrioSetMember(this, table, column, symbolCode, relationToPrevMember);
                Add(newItem);
                return(newItem);
            }
            return(cache);
        }
Example #31
0
            /// <summary>
            /// Constructs the result set.
            /// </summary>
            /// <param name="query"></param>
            /// <param name="result"></param>
            public ResultSetInfo(SqlQuery query, Table result)
            {
                this.query = query;
                this.result = result;
                streamableBlobMap = new Dictionary<long, IRef>();

                resultRowCount = result.RowCount;

                // HACK: Read the contents of the first row so that we can pick up
                //   any errors with reading, and also to fix the 'uniquekey' bug
                //   that causes a new transaction to be started if 'uniquekey' is
                //   a column and the value is resolved later.
                IRowEnumerator rowEnum = result.GetRowEnumerator();
                if (rowEnum.MoveNext()) {
                    int row_index = rowEnum.RowIndex;
                    for (int c = 0; c < result.ColumnCount; ++c) {
                        result.GetCell(c, row_index);
                    }
                }

                // If simple enum, note it here
                resultIsSimpleEnum = (rowEnum is SimpleRowEnumerator);
                rowEnum = null;

                // Build 'row_index_map' if not a simple enum
                if (!resultIsSimpleEnum) {
                    rowIndexMap = new List<int>(result.RowCount);

                    IRowEnumerator en = result.GetRowEnumerator();
                    while (en.MoveNext()) {
                        rowIndexMap.Add(en.RowIndex);
                    }
                }

                // This is a safe operation provides we are shared.
                // Copy all the TableField columns from the table to our own
                // ColumnDescription array, naming each column by what is returned from
                // the 'GetResolvedVariable' method.
                int colCount = result.ColumnCount;
                colDesc = new ColumnDescription[colCount];
                for (int i = 0; i < colCount; ++i) {
                    VariableName v = result.GetResolvedVariable(i);
                    string fieldName;
                    if (v.TableName == null) {
                        // This means the column is an alias
                        fieldName = "@a" + v.Name;
                    } else {
                        // This means the column is an schema/table/column reference
                        fieldName = "@f" + v;
                    }
                    colDesc[i] = new ColumnDescription(fieldName, result.GetColumnInfo(i));
                }

                locked = 0;
            }
 public QueryResponseImpl(int resultId, int queryTime, int colCount, int rowCount, ColumnDescription[] colList)
 {
     this.resultId = resultId;
     this.colList = colList;
     this.rowCount = rowCount;
     this.colCount = colCount;
     this.queryTime = queryTime;
 }
        /// <inheritdoc/>
        public IQueryResponse[] ExecuteQuery(SqlQuery sql)
        {
            try {
                // Execute the command
                int dispatchId = connectionThread.ExecuteQuery(sql);

                // Get the response
                ServerCommand command = connectionThread.ReceiveCommand(DeveelDbConnection.QueryTimeout, dispatchId);
                // If command == null then we timed output
                if (command == null)
                    throw new DataException("Query timed output after " + DeveelDbConnection.QueryTimeout + " seconds.");

                BinaryReader input = new BinaryReader(command.GetInputStream());

                // Query response protocol...
                int status = input.ReadInt32();
                if (status == ProtocolConstants.Success) {
                    int resultId = input.ReadInt32();
                    int queryTime = input.ReadInt32();
                    int rowCount = input.ReadInt32();
                    int colCount = input.ReadInt32();
                    ColumnDescription[] col_list = new ColumnDescription[colCount];
                    for (int i = 0; i < colCount; ++i) {
                        col_list[i] = ColumnDescription.ReadFrom(input);
                    }

                    return new IQueryResponse[] {new QueryResponseImpl(resultId, queryTime, colCount, rowCount, col_list)};
                }
                if (status == ProtocolConstants.Exception) {
                    int dbCode = input.ReadInt32();
                    string message = input.ReadString();
                    string stack_trace = input.ReadString();
                    throw new DbDataException(message, null, dbCode, stack_trace);
                }
                if (status == ProtocolConstants.AuthenticationError) {
                    // Means we could perform the command because user doesn't have enough
                    // rights.
                    string accessType = input.ReadString();
                    string tableName = input.ReadString();
                    throw new DataException("User doesn't have enough privs to " + accessType + " table " + tableName);
                }

                throw new DataException("Illegal response code from server.");
            } catch (IOException e) {
                LogException(e);
                throw new DataException("IO Error: " + e.Message);
            }
        }