From user-return-17392-archive-asf-public=cust-asf.ponee.io@ignite.apache.org Sun Jan 21 21:27:17 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 843BD180652 for ; Sun, 21 Jan 2018 21:27:17 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 681D3160C36; Sun, 21 Jan 2018 20:27:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id ADAE6160C27 for ; Sun, 21 Jan 2018 21:27:16 +0100 (CET) Received: (qmail 39982 invoked by uid 500); 21 Jan 2018 20:27:15 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 39972 invoked by uid 99); 21 Jan 2018 20:27:15 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Jan 2018 20:27:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 037701A08E1 for ; Sun, 21 Jan 2018 20:27:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.918 X-Spam-Level: X-Spam-Status: No, score=0.918 tagged_above=-999 required=6.31 tests=[SPF_FAIL=0.919, SPF_HELO_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Tk09LWCNhyZF for ; Sun, 21 Jan 2018 20:27:13 +0000 (UTC) Received: from n6.nabble.com (n6.nabble.com [162.255.23.37]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 8CAB15F5B4 for ; Sun, 21 Jan 2018 20:27:12 +0000 (UTC) Received: from n6.nabble.com (localhost [127.0.0.1]) by n6.nabble.com (Postfix) with ESMTP id E0ED042108B4 for ; Sun, 21 Jan 2018 13:27:05 -0700 (MST) Date: Sun, 21 Jan 2018 13:27:05 -0700 (MST) From: mamaco To: user@ignite.apache.org Message-ID: <1516566425875-0.post@n6.nabble.com> Subject: Option meta schema in cache level? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I'm trying to use Binary Marshaller to replace old OptimizedMarshaller which is really a pain for deployment. But according to document of Type Metadata, it could be changed at runtime, that means if I access to a 3rd party cache which was created by someone else without explicit type settings, I'll have to get a sample row to retrieve its type manually prior to further operations. is this correct? why not just set a default optional meta type in cache level? as an option, it won't be negative for dynamic row schema. #access to a cache 'SQL_PUBLIC_CITY' (created by JDBC 'Create Table' statement) and do some normal operations. #GetSchema() is weird public class App { private static SchemaType schema=null; public static void main( String[] args ) { Ignite ignite = Ignition.start("C://apache//ignite//apache-ignite-fabric-2.2.0-bin//config//client.xml"); CacheConfiguration cfg = new CacheConfiguration("SQL_PUBLIC_CITY"); IgniteCache cache = ignite.getOrCreateCache(cfg).withKeepBinary(); if(schema==null) schema=GetSchema(cache); Put(ignite,cache,4L,"Los Angeles"); GetAll(cache); Get(ignite,cache,4L); Query(cache,4L); ignite.close(); } public static void GetAll(IgniteCache cache) { Iterator> itr = cache.iterator(); while(itr.hasNext()){ Cache.Entry item = itr.next(); System.out.println("id="+item.getKey().field("id")+" KeyType="+item.getKey().type().typeName().toString()+" V="+item.getKey().type().field("id")); System.out.println("CITY="+item.getValue().field("name")+ " of id="+item.getValue().field("id")); } } public static SchemaType GetSchema(IgniteCache cache) { SchemaType sch=new SchemaType(); Cache.Entry item = cache.iterator().next(); sch.KeyType=item.getKey().type().typeName(); sch.KeyFields=item.getKey().type().fieldNames(); sch.ValueType=item.getValue().type().typeName(); sch.ValueFields=item.getValue().type().fieldNames(); return sch; } public static void Get(Ignite ignite, IgniteCache cache, Long CityId) { BinaryObjectBuilder keyBuilder = ignite.binary().builder(schema.KeyType) .setField("id", CityId); BinaryObject value = cache.get(keyBuilder.build()); if(value!=null) System.out.println("CITY="+value.field("name")); } public static void Put(Ignite ignite, IgniteCache cache,Long CityId,String CityName) { BinaryObjectBuilder keyBuilder = ignite.binary().builder(schema.KeyType) .setField("id", CityId); BinaryObjectBuilder valueBuilder = ignite.binary().builder(schema.ValueType) .setField("name", CityName); cache.put(keyBuilder.build(),valueBuilder.build()); } public static void Query(IgniteCache cache, Long CityId) { QueryCursor> query = cache.query(new SqlFieldsQuery("select * from City where id="+CityId)); System.out.println(query.getAll()); } } -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/