public void TestFirstEncoding() { TableFormat tf = new TableFormat(1, 1); tf.addField(FieldFormat.FLOAT_FIELD, "value"); tf.addField(FieldFormat.INTEGER_FIELD, "quality"); DataTable nested = new DataTable(tf, 12345.67f, 123); ClassicEncodingSettings ces = new ClassicEncodingSettings(true); ces.setFormatCache(new FormatCache()); ces.setKnownFormatCollector(new KnownFormatCollector()); DataTable table = new DataTable(AbstractContext.EF_UPDATED, "test", nested, null); String encodedTable = table.encode(ces); String actual = "<F=<<variable><S><A=>><<value><T><A=<F=>>><<user><S><F=N><A=<NULL>>>" + "<M=1><X=1>><D=0><R=<test>" + "<<F=<<value><F><A=0>>" + "<<quality><I><A=0>><M=1><X=1>><D=1>" + "<R=<12345.67><123>>><<NULL>>>"; Assert.AreEqual(encodedTable, actual); }
public ClassicEncodingSettings createClassicEncodingSettings(Boolean forSending) { var es = new ClassicEncodingSettings(false); if (!forSending) { es.setFormatCache(formatCache); } es.setEncodeFormat(!avoidSendingFormats); return(es); }
protected override ClassicEncodingSettings createClassicEncodingSettings(Boolean useFormatCache) { ClassicEncodingSettings settings = base.createClassicEncodingSettings(useFormatCache); if (useFormatCache) { settings.setFormatCache(formatCache); settings.setKnownFormatCollector(knownFormatCollector); } settings.setEncodeFormat(!useFormatCache); return(settings); }
public void TestCachedEncoding() { TableFormat tf = new TableFormat(1, 1); tf.addField(FieldFormat.FLOAT_FIELD, "value"); tf.addField(FieldFormat.INTEGER_FIELD, "quality"); DataTable nested = new DataTable(tf, 12345.67f, 123); ClassicEncodingSettings ces = new ClassicEncodingSettings(true); ces.setFormatCache(new FormatCache()); ces.setKnownFormatCollector(new KnownFormatCollector()); DataTable table = new DataTable(AbstractContext.EF_UPDATED, "test", nested, null); table.encode(ces); String encodedTable = table.encode(ces); String actual = "<D=0><R=<test><<D=0><R=<12345.67><123>>><<NULL>>>"; Assert.AreEqual(encodedTable, actual); }
static void Main() { try { Log.start(); TableFormat tf = new TableFormat(1, 1); tf.addField(FieldFormat.DATE_FIELD, "date"); tf.addField(FieldFormat.FLOAT_FIELD, "value"); tf.addField(FieldFormat.INTEGER_FIELD, "quality"); DataTable nested = new DataTable(tf, DateTime.Now, 12345.67890f, 123); ClassicEncodingSettings ces = new ClassicEncodingSettings(false); ces.setFormatCache(new FormatCache()); //ces.setKnownFormatCollector(new KnownFormatCollector()); ces.setKnownFormatCollector(new KnownFormatCollector()); DataTable table = new DataTable(AbstractContext.EF_UPDATED, "test", nested, null); int tablesPerTask = 10000; // Encoding //System.Threading.WaitCallback etask = new System.Threading.WaitCallback() Action etask = () => { for (int i = 0; i < tablesPerTask; i++) { table.encode(ces); } }; execute(tablesPerTask, etask); // Decoding // table.encode(ces); // First time format will be encoded into table, and we'd like to test decoding tables without format // // final String encoded = table.encode(ces); // // Callable dtask = new Callable() // { // @Override // public Object call() throws Exception // { // try // { // for (int i = 0; i < tablesPerTask; i++) // { // new DataTable(encoded, ces, true); // } // } // catch (Exception ex) // { // ex.printStackTrace(); // } // return null; // } // }; // // execute(tablesPerTask, dtask); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }