ReadIntAsync() public method

Reads the int async.
public ReadIntAsync ( ) : Task
return Task
コード例 #1
0
ファイル: ResultFrame.cs プロジェクト: priyaparul/CqlSharp
        protected override async Task InitializeAsync()
        {
            FrameReader reader = Reader;

            ResultOpcode = (ResultOpcode)await reader.ReadIntAsync().ConfigureAwait(false);

            switch (ResultOpcode)
            {
            case ResultOpcode.Void:
                break;

            case ResultOpcode.Rows:
                Schema = await ReadCqlSchemaAsync().ConfigureAwait(false);

                _count = await reader.ReadIntAsync().ConfigureAwait(false);

                break;

            case ResultOpcode.SetKeyspace:
                Keyspace = await reader.ReadStringAsync().ConfigureAwait(false);

                break;

            case ResultOpcode.SchemaChange:
                Change = await reader.ReadStringAsync().ConfigureAwait(false);

                Keyspace = await reader.ReadStringAsync().ConfigureAwait(false);

                Table = await reader.ReadStringAsync().ConfigureAwait(false);

                break;

            case ResultOpcode.Prepared:
                PreparedQueryId = await reader.ReadShortBytesAsync().ConfigureAwait(false);

                Schema = await ReadCqlSchemaAsync().ConfigureAwait(false);

                break;

            default:
                throw new ArgumentException("Unexpected ResultOpcode");
            }

            //_readLock = new SemaphoreSlim(1);
        }
コード例 #2
0
        protected override async Task InitializeAsync()
        {
            FrameReader stream = Reader;
            var         code   = (ErrorCode)await stream.ReadIntAsync().ConfigureAwait(false);

            string msg = await stream.ReadStringAsync().ConfigureAwait(false);

            switch (code)
            {
            case ErrorCode.Unavailable:
            {
                var cl = (CqlConsistency)await stream.ReadShortAsync().ConfigureAwait(false);

                int required = await stream.ReadIntAsync().ConfigureAwait(false);

                int alive = await stream.ReadIntAsync().ConfigureAwait(false);

                Exception = new UnavailableException(msg, cl, required, alive);
                break;
            }

            case ErrorCode.WriteTimeout:
            {
                var cl = (CqlConsistency)await stream.ReadShortAsync().ConfigureAwait(false);

                int received = await stream.ReadIntAsync().ConfigureAwait(false);

                int blockFor = await stream.ReadIntAsync().ConfigureAwait(false);

                string writeType = await stream.ReadStringAsync().ConfigureAwait(false);

                Exception = new WriteTimeOutException(msg, cl, received, blockFor, writeType);
                break;
            }

            case ErrorCode.ReadTimeout:
            {
                var cl = (CqlConsistency)await stream.ReadShortAsync().ConfigureAwait(false);

                int received = await stream.ReadIntAsync().ConfigureAwait(false);

                int blockFor = await stream.ReadIntAsync().ConfigureAwait(false);

                bool dataPresent = 0 != await stream.ReadByteAsync().ConfigureAwait(false);

                Exception = new ReadTimeOutException(msg, cl, received, blockFor, dataPresent);
                break;
            }

            case ErrorCode.Syntax:
                Exception = new SyntaxException(msg);
                break;

            case ErrorCode.Unauthorized:
                Exception = new UnauthorizedException(msg);
                break;

            case ErrorCode.Invalid:
                Exception = new InvalidException(msg);
                break;

            case ErrorCode.AlreadyExists:
                string keyspace = await stream.ReadStringAsync().ConfigureAwait(false);

                string table = await stream.ReadStringAsync().ConfigureAwait(false);

                Exception = new AlreadyExistsException(msg, keyspace, table);
                break;

            case ErrorCode.Unprepared:
                byte[] unknownId = await stream.ReadShortBytesAsync().ConfigureAwait(false);

                Exception = new UnpreparedException(msg, unknownId);
                break;

            default:
                Exception = new ProtocolException(code, msg);
                break;
            }
        }
コード例 #3
0
ファイル: ResultFrame.cs プロジェクト: priyaparul/CqlSharp
        internal async Task <CqlSchema> ReadCqlSchemaAsync()
        {
            FrameReader reader = Reader;
            var         flags  = (MetadataFlags)await reader.ReadIntAsync().ConfigureAwait(false);

            bool globalTablesSpec = 0 != (flags & MetadataFlags.GlobalTablesSpec);

            int colCount = await reader.ReadIntAsync().ConfigureAwait(false);

            string keyspace = null;
            string table    = null;

            if (globalTablesSpec)
            {
                keyspace = await reader.ReadStringAsync().ConfigureAwait(false);

                table = await reader.ReadStringAsync().ConfigureAwait(false);
            }

            var columnSpecs = new List <CqlColumn>(colCount);

            for (int colIdx = 0; colIdx < colCount; ++colIdx)
            {
                string colKeyspace = keyspace;
                string colTable    = table;
                if (!globalTablesSpec)
                {
                    colKeyspace = await reader.ReadStringAsync().ConfigureAwait(false);

                    colTable = await reader.ReadStringAsync().ConfigureAwait(false);
                }
                string colName = await reader.ReadStringAsync().ConfigureAwait(false);

                var colType = (CqlType)await reader.ReadShortAsync().ConfigureAwait(false);

                string  colCustom    = null;
                CqlType?colKeyType   = null;
                CqlType?colValueType = null;
                switch (colType)
                {
                case CqlType.Custom:
                    colCustom = await reader.ReadStringAsync().ConfigureAwait(false);

                    break;

                case CqlType.List:
                case CqlType.Set:
                    colValueType = (CqlType)await reader.ReadShortAsync().ConfigureAwait(false);

                    break;

                case CqlType.Map:
                    colKeyType = (CqlType)await reader.ReadShortAsync().ConfigureAwait(false);

                    colValueType = (CqlType)await reader.ReadShortAsync().ConfigureAwait(false);

                    break;
                }

                columnSpecs.Add(new CqlColumn(colIdx, colKeyspace, colTable, colName, colType, colCustom,
                                              colKeyType, colValueType));
            }

            return(new CqlSchema(columnSpecs));
        }