List of usage examples for org.apache.thrift.protocol TCompactProtocol TCompactProtocol
public TCompactProtocol(TTransport transport)
From source file:org.apache.jena.hadoop.rdf.types.converters.ThriftConverter.java
License:Apache License
private static TProtocol getInputProtocol() { TProtocol protocol = inputProtocols.get(); if (protocol != null) return protocol; protocol = new TCompactProtocol(getInputTransport()); inputProtocols.set(protocol);/* www. j a va 2s . co m*/ return protocol; }
From source file:org.apache.jena.hadoop.rdf.types.converters.ThriftConverter.java
License:Apache License
private static TProtocol getOutputProtocol() { TProtocol protocol = outputProtocols.get(); if (protocol != null) return protocol; protocol = new TCompactProtocol(getOutputTransport()); outputProtocols.set(protocol);//from ww w .j a v a 2s . co m return protocol; }
From source file:org.apache.jena.riot.thrift.TRDF.java
License:Apache License
public static TProtocol protocol(TTransport transport) { if (true)// w w w . j av a2s . c o m return new TCompactProtocol(transport); // Keep the warnings down. if (false) return new TTupleProtocol(transport); if (false) return new TJSONProtocol(transport); throw new RiotThriftException("No protocol impl choosen"); }
From source file:org.apache.parquet.format.Util.java
License:Apache License
private static InterningProtocol protocol(TIOStreamTransport t) { return new InterningProtocol(new TCompactProtocol(t)); }
From source file:org.apache.parquet.thrift.TestProtocolReadToWrite.java
License:Apache License
private TCompactProtocol protocol(OutputStream to) { return new TCompactProtocol(new TIOStreamTransport(to)); }
From source file:org.apache.parquet.thrift.TestProtocolReadToWrite.java
License:Apache License
private TCompactProtocol protocol(InputStream from) { return new TCompactProtocol(new TIOStreamTransport(from)); }
From source file:org.diqube.cluster.connection.DefaultConnectionFactory.java
License:Open Source License
private <T extends TServiceClient> T createProtocolAndClient(Class<T> thriftClientClass, String thriftServiceName, TTransport transport) throws ConnectionException { TProtocol queryProtocol = new TMultiplexedProtocol(new TCompactProtocol(transport), thriftServiceName); T queryResultClient;/*from w w w . ja v a2s . c o m*/ try { queryResultClient = thriftClientClass.getConstructor(TProtocol.class).newInstance(queryProtocol); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { ConnectionPool.logger.error("Error while constructing a client", e); throw new ConnectionException("Error while constructing a client", e); } return queryResultClient; }
From source file:org.diqube.connection.DefaultConnectionFactory.java
License:Open Source License
private <T> T createProtocolAndClient(DiqubeThriftServiceInfo<T> serviceInfo, TTransport transport) throws ConnectionException { TProtocol innerProtocol;/*w w w . jav a 2 s .c o m*/ if (serviceInfo.isIntegrityChecked()) { if (!(transport instanceof RememberingTransport)) transport = new RememberingTransport(transport); innerProtocol = new IntegrityCheckingProtocol(new TCompactProtocol(transport), macKeys); } else innerProtocol = new TCompactProtocol(transport); TProtocol queryProtocol = new TMultiplexedProtocol(innerProtocol, serviceInfo.getServiceName()); try { @SuppressWarnings("unchecked") T queryResultClient = (T) serviceInfo.getClientClass().getConstructor(TProtocol.class) .newInstance(queryProtocol); return queryResultClient; } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { ConnectionPool.logger.error("Error while constructing a client", e); throw new ConnectionException("Error while constructing a client", e); } }
From source file:org.diqube.data.serialize.DataDeserializer.java
License:Open Source License
private <T extends TBase<?, ?>> T deserializeToThrift(InputStream inputStream, Class<? extends T> thriftClass) throws DeserializationException { TIOStreamTransport transport = new TIOStreamTransport(inputStream); TProtocol compactProt = new TCompactProtocol(transport); try {// w ww . j a va2 s . c o m T thrift = thriftClass.newInstance(); thrift.read(compactProt); return thrift; } catch (TException | InstantiationException | IllegalAccessException e) { throw new DeserializationException("Cannot deserialize", e); } }
From source file:org.diqube.data.serialize.DataSerializer.java
License:Open Source License
/** * Serialize a {@link DataSerialization} object into an output stream and flush that stream. * //w ww.j a v a 2 s. c om * @param obj * The object to serialize. * @param outputStream * The output stream to fill. * @param objectDoneConsumer * Will be called when single objects (referenced transitively from obj) have been "serialized" and can be * freed by the caller, if needed. * @throws SerializationException * If anything went wrong. */ public void serialize(DataSerialization<?> obj, OutputStream outputStream, ObjectDoneConsumer objectDoneConsumer) throws SerializationException { DataSerializationHelper helper = dataSerializationHelperFactory.apply(objectDoneConsumer); TBase<?, ?> res = helper.serializeChild(thriftClasses.get(obj.getClass()), obj); TIOStreamTransport transport = new TIOStreamTransport(outputStream); TProtocol compactProt = new TCompactProtocol(transport); try { res.write(compactProt); outputStream.flush(); } catch (TException | IOException e) { throw new SerializationException("Could not serialize", e); } }