private static Schema SchemaFor(Schema[][] schemas, int apiKey, int version) { if (apiKey < 0 || apiKey > schemas.Length) throw new KafkaException("Invalid api key: " + apiKey); Schema[] versions = schemas[apiKey]; if (version < 0 || version > versions.Length) throw new KafkaException("Invalid version for API key " + apiKey + ": " + version); if (versions[version] == null) throw new KafkaException("Unsupported version for API key " + apiKey + ": " + version); return versions[version]; }
public ProtocolSerializationTest() { this.schema = new Schema(new Field("int8", KafkaTypesHelper.Int8), new Field("int16", KafkaTypesHelper.Int16), new Field("int32", KafkaTypesHelper.Int32), new Field("int64", KafkaTypesHelper.Int64), new Field("string", KafkaTypesHelper.String), new Field("bytes", KafkaTypesHelper.Bytes), new Field("array", new KafkaArrayOf(KafkaTypesHelper.Int32)), new Field("struct", new Schema(new Field("field", KafkaTypesHelper.Int32)))); this.s = new Struct(this.schema).Set("int8", (byte)1) .Set("int16", (short)1) .Set("int32", 1) .Set("int64", 1L) .Set("string", "1") .Set("bytes", Encoding.UTF8.GetBytes("1")) .Set("array", new object[] { 1 }); this.s.Set("struct", this.s.Instance("struct").Set("field", new object[] { 1, 2, 3 })); }
public Struct(Schema schema) { Schema = schema; values = new object[Schema.NumFields()]; }
public Struct(Schema schema, object[] values) { Schema = schema; this.values = values; }