public string Format(Stream input)
 {
     using (MemoryStream byteOutput = ByteBufferIO.Read(input))
     {
         return(Format(byteOutput.ToArray()));
     }
 }
Esempio n. 2
0
        public void SetUp()
        {
            string costs = "" +
                           "3 3\n" +
                           "0 0 1\n" +
                           "0 1 2\n" +
                           "0 2 3\n" +
                           "1 0 4\n" +
                           "1 1 5\n" +
                           "1 2 6\n" +
                           "2 0 7\n" +
                           "2 1 8\n" +
                           "2 2 9\n";

            using (ConnectionCostsCompiler compiler = new ConnectionCostsCompiler())
                using (var outputStream = File.Create(costFile))
                {
                    var    bytes       = Encoding.UTF8.GetBytes(costs);
                    Stream inputStream = new MemoryStream(bytes);
                    compiler.ReadCosts(inputStream);
                    compiler.Compile(outputStream);
                }

            using (var readStream = File.OpenRead(costFile))
                using (var reader = new BinaryReader(readStream))
                {
                    int size        = reader.ReadRawInt32();
                    var costsBuffer = new MemoryStreamWrapper(ByteBufferIO.Read(readStream));
                    connectionCosts = new ConnectionCosts(size, costsBuffer);
                }
        }
Esempio n. 3
0
 public TokenInfoBuffer(Stream input)
 {
     Buffer         = ByteBufferIO.Read(input);
     TokenInfoCount = Buffer.ReadInt32(IntBytes * 2);
     PosInfoCount   = Buffer.ReadInt32(IntBytes * 3);
     FeatureCount   = Buffer.ReadInt32(IntBytes * 4);
     EntrySize      = TokenInfoCount * ShortBytes + PosInfoCount + FeatureCount * IntBytes;
 }
 private static ConnectionCosts Read(Stream input)
 {
     try
     {
         lock (input)
         {
             using (BinaryReader reader = new BinaryReader(input))
             {
                 int size  = reader.ReadRawInt32();
                 var costs = new MemoryStreamWrapper(ByteBufferIO.Read(reader));
                 return(new ConnectionCosts(size, costs));
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception("ConnectionCosts.Read: " + ex.Message);
     }
 }
Esempio n. 5
0
        public TokenInfoBuffer(Stream inputStream)
        {
            try
            {
                if (buffer != null)
                {
                    buffer.Dispose();
                }

                buffer         = new MemoryStreamWrapper(ByteBufferIO.Read(inputStream));
                tokenInfoCount = GetTokenInfoCount();
                posInfoCount   = GetPosInfoCount();
                featureCount   = GetFeatureCount();
                entrySize      = GetEntrySize(tokenInfoCount, posInfoCount, featureCount);
            }
            catch (Exception ex)
            {
                throw new IOException("TokenInfoBuffer Constructor: " + ex.Message);
            }
        }
Esempio n. 6
0
 public StringValueMapBuffer(Stream inputStream)
 {
     buffer      = new MemoryStreamWrapper(ByteBufferIO.Read(inputStream));
     streamArray = buffer.Stream.ToArray();
     size        = buffer.ReadInt32();
 }
Esempio n. 7
0
 public StringValueMapBuffer(Stream input)
 {
     Buffer = ByteBufferIO.Read(input);
     Size   = Buffer.ReadInt32(0);
 }
Esempio n. 8
0
 public FST(Stream input) : this(ByteBufferIO.Read(input).ToArray())
 {
 }