Examples of TDeserializer


Examples of com.facebook.presto.hive.shaded.org.apache.thrift.TDeserializer

        fcversion = jsonContainer.getString("fcversion");
      } catch (JSONException ignored) {}
      checkCompatibility(version, fcversion);
      String tableDesc = jsonContainer.getString("table");
      Table table = new Table();
      TDeserializer deserializer = new TDeserializer(new TJSONProtocol.Factory());
      deserializer.deserialize(table, tableDesc, "UTF-8");
      JSONArray jsonPartitions = new JSONArray(jsonContainer.getString("partitions"));
      List<Partition> partitionsList = new ArrayList<Partition>(jsonPartitions.length());
      for (int i = 0; i < jsonPartitions.length(); ++i) {
        String partDesc = jsonPartitions.getString(i);
        Partition partition = new Partition();
        deserializer.deserialize(partition, partDesc, "UTF-8");
        partitionsList.add(partition);
      }
      return new AbstractMap.SimpleEntry<Table, List<Partition>>(table, partitionsList);
    } catch (JSONException e) {
      throw new SemanticException(ErrorMsg.GENERIC_ERROR.getMsg("Error in serializing metadata"), e);
View Full Code Here

Examples of com.facebook.thrift.TDeserializer

    (byte)0x80, (byte)0xbc
  };

  public static void main(String[] args) throws Exception {
    TSerializer   binarySerializer   = new   TSerializer(new TBinaryProtocol.Factory());
    TDeserializer binaryDeserializer = new TDeserializer(new TBinaryProtocol.Factory());

    OneOfEach ooe = new OneOfEach();
    ooe.im_true = true;
    ooe.im_false = false;
    ooe.a_bite = (byte) 0xd6;
    ooe.integer16 = 27000;
    ooe.integer32 = 1 << 24;
    ooe.integer64 = (long) 6000 * 1000 * 1000;
    ooe.double_precision = Math.PI;
    ooe.some_characters = "JSON THIS! \"\1";
    ooe.zomg_unicode = new String(kUnicodeBytes, "UTF-8");
    ooe.base64 = "string to bytes".getBytes();

    Nesting n = new Nesting(new Bonk(), new OneOfEach());
    n.my_ooe.integer16 = 16;
    n.my_ooe.integer32 = 32;
    n.my_ooe.integer64 = 64;
    n.my_ooe.double_precision = (Math.sqrt(5) + 1) / 2;
    n.my_ooe.some_characters = ":R (me going \"rrrr\")";
    n.my_ooe.zomg_unicode = new String(kUnicodeBytes, "UTF-8");
    n.my_bonk.type = 31337;
    n.my_bonk.message = "I am a bonk... xor!";

    HolyMoley hm = new HolyMoley();

    hm.big = new ArrayList<OneOfEach>();
    hm.big.add(ooe);
    hm.big.add(n.my_ooe);
    hm.big.get(0).a_bite = (byte) 0x22;
    hm.big.get(1).a_bite = (byte) 0x23;

    hm.contain = new HashSet<List<String>>();
    ArrayList<String> stage1 = new ArrayList<String>(2);
    stage1.add("and a one");
    stage1.add("and a two");
    hm.contain.add(stage1);
    stage1 = new ArrayList<String>(3);
    stage1.add("then a one, two");
    stage1.add("three!");
    stage1.add("FOUR!!");
    hm.contain.add(stage1);
    stage1 = new ArrayList<String>(0);
    hm.contain.add(stage1);

    ArrayList<Bonk> stage2 = new ArrayList<Bonk>();
    hm.bonks = new HashMap<String, List<Bonk>>();
    hm.bonks.put("nothing", stage2);
    Bonk b = new Bonk();
    b.type = 1;
    b.message = "Wait.";
    stage2.add(b);
    b = new Bonk();
    b.type = 2;
    b.message = "What?";
    stage2.add(b);
    stage2 = new ArrayList<Bonk>();
    hm.bonks.put("something", stage2);
    b = new Bonk();
    b.type = 3;
    b.message = "quoth";
    b = new Bonk();
    b.type = 4;
    b.message = "the raven";
    b = new Bonk();
    b.type = 5;
    b.message = "nevermore";
    hm.bonks.put("poe", stage2);


    byte[] binaryCopy = binarySerializer.serialize(hm);
    HolyMoley hmCopy = new HolyMoley();
    binaryDeserializer.deserialize(hmCopy, binaryCopy);
    HolyMoley hmCopy2 = new HolyMoley(hm);

    if (!hm.equals(hmCopy))
      throw new RuntimeException("copy constructor modified the original object!");
    if (!hmCopy.equals(hmCopy2))
View Full Code Here

Examples of org.apache.blur.thirdparty.thrift_0_9_0.TDeserializer

      String blurTablePath = ZookeeperPathConstants.getTablePath(cluster, table);
      byte[] bytes = getData(blurTablePath);
      if (bytes == null) {
        throw new RuntimeException("Table [" + table + "] in cluster [" + cluster + "] not found.");
      }
      TDeserializer deserializer = new TDeserializer(new TJSONProtocol.Factory());
      deserializer.deserialize(tableDescriptor, bytes);
    } catch (TException e) {
      throw new RuntimeException(e);
    } catch (KeeperException e) {
      throw new RuntimeException(e);
    } catch (InterruptedException e) {
View Full Code Here

Examples of org.apache.thrift.TDeserializer

        int scLength = dis.readInt();
        ByteBuffer super_column = null;
        if (scLength > 0)
            super_column = ByteBuffer.wrap(readBuf(scLength, dis));

        TDeserializer dser = new TDeserializer(new TBinaryProtocol.Factory());
        SlicePredicate pred = new SlicePredicate();
        FBUtilities.deserialize(dser, pred, dis);

        AbstractBounds range = AbstractBounds.serializer().deserialize(dis);
        int max_keys = dis.readInt();
View Full Code Here

Examples of org.apache.thrift.TDeserializer

  public void testTDeserializer() throws TException {
    TSerializer ser = new TSerializer(getFactory());
    byte[] bytes = ser.serialize(Fixtures.compactProtoTestStruct);

    TDeserializer deser = new TDeserializer(getFactory());
    CompactProtoTestStruct cpts = new CompactProtoTestStruct();
    deser.deserialize(cpts, bytes);

    assertEquals(Fixtures.compactProtoTestStruct, cpts);
  }
View Full Code Here

Examples of org.apache.thrift.TDeserializer

      long serElapsed = serEnd - serStart;
      System.out.println("Ser:\t" + serElapsed + "ms\t"
          + ((double)serElapsed / NUM_REPS) + "ms per serialization");

      HolyMoley cpts = new HolyMoley();
      TDeserializer deser = new TDeserializer(getFactory());
      long deserStart = System.currentTimeMillis();
      for (int rep = 0; rep < NUM_REPS; rep++) {
        deser.deserialize(cpts, serialized);
      }
      long deserEnd = System.currentTimeMillis();
      long deserElapsed = deserEnd - deserStart;
      System.out.println("Des:\t" + deserElapsed + "ms\t"
          + ((double)deserElapsed / NUM_REPS) + "ms per deserialization");
View Full Code Here

Examples of org.apache.thrift.TDeserializer

  public void testTDeserializer() throws TException {
    TSerializer ser = new TSerializer(getFactory());
    byte[] bytes = ser.serialize(Fixtures.compactProtoTestStruct);

    TDeserializer deser = new TDeserializer(getFactory());
    CompactProtoTestStruct cpts = new CompactProtoTestStruct();
    deser.deserialize(cpts, bytes);

    assertEquals(Fixtures.compactProtoTestStruct, cpts);
  }
View Full Code Here

Examples of org.apache.thrift.TDeserializer

      long serElapsed = serEnd - serStart;
      System.out.println("Ser:\t" + serElapsed + "ms\t"
          + ((double)serElapsed / NUM_REPS) + "ms per serialization");

      HolyMoley cpts = new HolyMoley();
      TDeserializer deser = new TDeserializer(getFactory());
      long deserStart = System.currentTimeMillis();
      for (int rep = 0; rep < NUM_REPS; rep++) {
        deser.deserialize(cpts, serialized);
      }
      long deserEnd = System.currentTimeMillis();
      long deserElapsed = deserEnd - deserStart;
      System.out.println("Des:\t" + deserElapsed + "ms\t"
          + ((double)deserElapsed / NUM_REPS) + "ms per deserialization");
View Full Code Here

Examples of org.apache.thrift.TDeserializer

    }

    public static <T> T thriftDeserialize(Class c, byte[] b) {
        try {
            T ret = (T) c.newInstance();
            TDeserializer des = threadDes.get();
            if (des == null) {
                des = new TDeserializer();
                threadDes.set(des);
            }
            des.deserialize((TBase) ret, b);
            return ret;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
       
View Full Code Here

Examples of org.apache.thrift.TDeserializer

    }

    private static CfDef cfdefFromString(String st)
    {
        assert st != null;
        TDeserializer deserializer = new TDeserializer(new TBinaryProtocol.Factory());
        CfDef cfDef = new CfDef();
        try
        {
            deserializer.deserialize(cfDef, FBUtilities.hexToBytes(st));
        }
        catch (TException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.