Java Code Examples for org.apache.kylin.common.persistence.Serializer#serialize()

The following examples show how to use org.apache.kylin.common.persistence.Serializer#serialize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelServiceTest.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccessModelUpdate() throws IOException, JobException {
    Serializer<DataModelDesc> serializer = modelService.getDataModelManager().getDataModelSerializer();
    
    List<DataModelDesc> dataModelDescs = modelService.listAllModels("ci_inner_join_model", "default", true);
    Assert.assertTrue(dataModelDescs.size() == 1);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    serializer.serialize(dataModelDescs.get(0), new DataOutputStream(baos));
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DataModelDesc deserialize = serializer.deserialize(new DataInputStream(bais));

    deserialize.setOwner("somebody");
    DataModelDesc dataModelDesc = modelService.updateModelAndDesc("default", deserialize);
    Assert.assertTrue(dataModelDesc.getOwner().equals("somebody"));
}
 
Example 2
Source File: ModelServiceTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccessModelUpdate() throws IOException, JobException {
    Serializer<DataModelDesc> serializer = modelService.getDataModelManager().getDataModelSerializer();
    
    List<DataModelDesc> dataModelDescs = modelService.listAllModels("ci_inner_join_model", "default", true);
    Assert.assertTrue(dataModelDescs.size() == 1);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    serializer.serialize(dataModelDescs.get(0), new DataOutputStream(baos));
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DataModelDesc deserialize = serializer.deserialize(new DataInputStream(bais));

    deserialize.setOwner("somebody");
    DataModelDesc dataModelDesc = modelService.updateModelAndDesc("default", deserialize);
    Assert.assertTrue(dataModelDesc.getOwner().equals("somebody"));
}
 
Example 3
Source File: SCCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private <T extends RootPersistentEntity> void saveSystemCubeMetadataToFile(String fileName, T metadata,
                                                                           Serializer serializer) throws IOException {
    ByteArrayOutputStream buf = new ByteArrayOutputStream();
    DataOutputStream dout = new DataOutputStream(buf);
    serializer.serialize(metadata, dout);
    dout.close();
    buf.close();

    saveToFile(fileName, buf.toString("UTF-8"));
}
 
Example 4
Source File: SCCreator.java    From kylin with Apache License 2.0 5 votes vote down vote up
private <T extends RootPersistentEntity> void saveSystemCubeMetadataToFile(String fileName, T metadata,
                                                                           Serializer serializer) throws IOException {
    ByteArrayOutputStream buf = new ByteArrayOutputStream();
    DataOutputStream dout = new DataOutputStream(buf);
    serializer.serialize(metadata, dout);
    dout.close();
    buf.close();

    saveToFile(fileName, buf.toString("UTF-8"));
}
 
Example 5
Source File: TableSchemaUpdaterTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
private <T extends RootPersistentEntity> T reinit(T obj, Serializer<T> serializer) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    serializer.serialize(obj, dos);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DataInputStream dis = new DataInputStream(bais);
    return serializer.deserialize(dis);
}