當前位置: 首頁>>代碼示例>>Java>>正文


Java Serializer類代碼示例

本文整理匯總了Java中com.thinkaurelius.titan.graphdb.database.serialize.Serializer的典型用法代碼示例。如果您正苦於以下問題:Java Serializer類的具體用法?Java Serializer怎麽用?Java Serializer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Serializer類屬於com.thinkaurelius.titan.graphdb.database.serialize包,在下文中一共展示了Serializer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: serializeHeader

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
private DataOutput serializeHeader(Serializer serializer, int capacity, LogTxStatus status, EnumMap<LogTxMeta,Object> meta) {
    Preconditions.checkArgument(status!=null && meta!=null,"Invalid status or meta");
    DataOutput out = serializer.getDataOutput(capacity);
    out.putLong(times.getTime(txTimestamp));
    VariableLong.writePositive(out, transactionId);
    out.writeObjectNotNull(status);

    Preconditions.checkArgument(meta.size()<Byte.MAX_VALUE,"Too much meta data: %s",meta.size());
    out.putByte(VariableLong.unsignedByte(meta.size()));
    for (Map.Entry<LogTxMeta,Object> metaentry : meta.entrySet()) {
        assert metaentry.getValue()!=null;
        out.putByte(VariableLong.unsignedByte(metaentry.getKey().ordinal()));
        out.writeObjectNotNull(metaentry.getValue());
    }
    return out;
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:17,代碼來源:TransactionLogHeader.java

示例2: parse

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public static Entry parse(StaticBuffer buffer, Serializer serializer, TimestampProvider times) {
    ReadBuffer read = buffer.asReadBuffer();
    Instant txTimestamp = times.getTime(read.getLong());
    TransactionLogHeader header = new TransactionLogHeader(VariableLong.readPositive(read),
            txTimestamp, times);
    LogTxStatus status = serializer.readObjectNotNull(read,LogTxStatus.class);
    EnumMap<LogTxMeta,Object> metadata = new EnumMap<LogTxMeta, Object>(LogTxMeta.class);
    int metaSize = VariableLong.unsignedByte(read.getByte());
    for (int i=0;i<metaSize;i++) {
        LogTxMeta meta = LogTxMeta.values()[VariableLong.unsignedByte(read.getByte())];
        metadata.put(meta,serializer.readObjectNotNull(read,meta.dataType()));
    }
    if (read.hasRemaining()) {
        StaticBuffer content = read.subrange(read.getPosition(),read.length()-read.getPosition());
        return new Entry(header,content, status,metadata);
    } else {
        return new Entry(header,null, status,metadata);
    }
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:20,代碼來源:TransactionLogHeader.java

示例3: serializeHeader

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
private DataOutput serializeHeader(Serializer serializer, int capacity, LogTxStatus status, EnumMap<LogTxMeta,Object> meta) {
    Preconditions.checkArgument(status!=null && meta!=null,"Invalid status or meta");
    DataOutput out = serializer.getDataOutput(capacity);
    out.putLong(txTimestamp.getNativeTimestamp());
    VariableLong.writePositive(out, transactionId);
    out.writeObjectNotNull(status);

    Preconditions.checkArgument(meta.size()<Byte.MAX_VALUE,"Too much meta data: %s",meta.size());
    out.putByte(VariableLong.unsignedByte(meta.size()));
    for (Map.Entry<LogTxMeta,Object> metaentry : meta.entrySet()) {
        assert metaentry.getValue()!=null;
        out.putByte(VariableLong.unsignedByte(metaentry.getKey().ordinal()));
        out.writeObjectNotNull(metaentry.getValue());
    }
    return out;
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:17,代碼來源:TransactionLogHeader.java

示例4: parse

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public static Entry parse(StaticBuffer buffer, Serializer serializer, TimestampProvider times) {
    ReadBuffer read = buffer.asReadBuffer();
    Timepoint txTimestamp = new StandardTimepoint(read.getLong(), times);
    TransactionLogHeader header = new TransactionLogHeader(VariableLong.readPositive(read),
            txTimestamp);
    LogTxStatus status = serializer.readObjectNotNull(read,LogTxStatus.class);
    EnumMap<LogTxMeta,Object> metadata = new EnumMap<LogTxMeta, Object>(LogTxMeta.class);
    int metaSize = VariableLong.unsignedByte(read.getByte());
    for (int i=0;i<metaSize;i++) {
        LogTxMeta meta = LogTxMeta.values()[VariableLong.unsignedByte(read.getByte())];
        metadata.put(meta,serializer.readObjectNotNull(read,meta.dataType()));
    }
    if (read.hasRemaining()) {
        StaticBuffer content = read.subrange(read.getPosition(),read.length()-read.getPosition());
        return new Entry(header,content, status,metadata);
    } else {
        return new Entry(header,null, status,metadata);
    }
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:20,代碼來源:TransactionLogHeader.java

示例5: readEntry

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public static Entry readEntry(ReadBuffer in, Serializer serializer) {
    long valuePosition = VariableLong.readPositive(in);
    Preconditions.checkArgument(valuePosition>0 && valuePosition<=Integer.MAX_VALUE);
    StaticBuffer buffer = readBuffer(in);

    StaticArrayEntry entry = new StaticArrayEntry(buffer, (int) valuePosition);
    int metaSize = in.getByte();
    for (int i=0;i<metaSize;i++) {
        EntryMetaData meta = EntryMetaData.values()[in.getByte()];
        entry.setMetaData(meta,serializer.readObjectNotNull(in,meta.getDataType()));
    }
    return entry;
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:14,代碼來源:BufferUtil.java

示例6: serializeModifications

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public StaticBuffer serializeModifications(Serializer serializer, LogTxStatus status, StandardTitanTx tx,
                                           final Collection<InternalRelation> addedRelations,
                                           final Collection<InternalRelation> deletedRelations) {
    Preconditions.checkArgument(status==LogTxStatus.PRECOMMIT || status==LogTxStatus.USER_LOG);
    DataOutput out = serializeHeader(serializer, 256 + (addedRelations.size() + deletedRelations.size()) * 40, status, status == LogTxStatus.PRECOMMIT ? tx.getConfiguration() : null);
    logRelations(out, addedRelations, tx);
    logRelations(out, deletedRelations,tx);
    return out.getStaticBuffer();
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:10,代碼來源:TransactionLogHeader.java

示例7: serializeUserLog

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public StaticBuffer serializeUserLog(Serializer serializer, Entry sourceTxEntry, StandardTransactionId sourceTxId) {
    Preconditions.checkArgument(sourceTxEntry!=null && sourceTxEntry.status==LogTxStatus.PRECOMMIT
            && sourceTxEntry.header.transactionId==sourceTxId.getTransactionId());
    StaticBuffer sourceContent = sourceTxEntry.content;
    Preconditions.checkArgument(sourceContent!=null && sourceContent.length()>0);
    EnumMap<LogTxMeta, Object> meta =  new EnumMap<LogTxMeta, Object>(LogTxMeta.class);
    meta.put(LogTxMeta.SOURCE_TRANSACTION,sourceTxId);
    DataOutput out = serializeHeader(serializer, 50 + sourceContent.length(), LogTxStatus.USER_LOG, meta);
    out.putBytes(sourceContent);
    return out.getStaticBuffer();
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:12,代碼來源:TransactionLogHeader.java

示例8: serializeSecondary

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public StaticBuffer serializeSecondary(Serializer serializer, LogTxStatus status,
                                       Map<String,Throwable> indexFailures, boolean userLogSuccess) {
    Preconditions.checkArgument(status==LogTxStatus.SECONDARY_SUCCESS || status==LogTxStatus.SECONDARY_FAILURE);
    DataOutput out = serializeHeader(serializer,30,status);
    if (status==LogTxStatus.SECONDARY_FAILURE) {
        out.putBoolean(userLogSuccess);
        out.putInt(indexFailures.size());
        for (String index : indexFailures.keySet()) {
            assert StringUtils.isNotBlank(index);
            out.writeObjectNotNull(index);
        }
    } else assert userLogSuccess && indexFailures.isEmpty();
    return out.getStaticBuffer();
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:15,代碼來源:TransactionLogHeader.java

示例9: getContentAsModifications

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public Collection<Modification> getContentAsModifications(Serializer serializer) {
    Preconditions.checkArgument(status==LogTxStatus.PRECOMMIT || status==LogTxStatus.USER_LOG);
    List<Modification> mods = Lists.newArrayList();
    ReadBuffer in = content.asReadBuffer();
    mods.addAll(readModifications(Change.ADDED,in,serializer));
    mods.addAll(readModifications(Change.REMOVED,in,serializer));
    return mods;
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:9,代碼來源:TransactionLogHeader.java

示例10: readModifications

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
private static Collection<Modification> readModifications(Change state, ReadBuffer in, Serializer serializer) {
    List<Modification> mods = Lists.newArrayList();
    long size = VariableLong.readPositive(in);
    for (int i = 0; i < size; i++) {
        long vid = VariableLong.readPositive(in);
        com.thinkaurelius.titan.diskstorage.Entry entry = BufferUtil.readEntry(in,serializer);
        mods.add(new Modification(state,vid,entry));
    }
    return mods;
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:11,代碼來源:TransactionLogHeader.java

示例11: SecondaryFailures

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
private SecondaryFailures(StaticBuffer content, Serializer serializer) {
    ReadBuffer in = content.asReadBuffer();
    this.userLogFailure = !in.getBoolean();
    int size = in.getInt();
    ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    for (int i = 0; i < size; i++) {
        builder.add(serializer.readObjectNotNull(in,String.class));
    }
    this.failedIndexes = builder.build();
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:11,代碼來源:TransactionLogHeader.java

示例12: IndexSerializer

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public IndexSerializer(Configuration config, Serializer serializer, Map<String, ? extends IndexInformation> indexes, final boolean hashKeys) {
    this.serializer = serializer;
    this.configuration = config;
    this.mixedIndexes = indexes;
    this.hashKeys=hashKeys;
    if (hashKeys) log.info("Hashing index keys");
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:8,代碼來源:IndexSerializer.java

示例13: getSerializer

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public static Serializer getSerializer(Configuration configuration) {
    Serializer serializer = new StandardSerializer();
    for (RegisteredAttributeClass<?> clazz : getRegisteredAttributeClasses(configuration)) {
        clazz.registerWith(serializer);
    }
    return serializer;
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:8,代碼來源:GraphDatabaseConfiguration.java

示例14: getSerializer

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
public static Serializer getSerializer(Configuration configuration) {
    Serializer serializer = new StandardSerializer(
            configuration.get(ATTRIBUTE_ALLOW_ALL_SERIALIZABLE),
            configuration.get(KRYO_INSTANCE_CACHE));
    for (RegisteredAttributeClass<?> clazz : getRegisteredAttributeClasses(configuration)) {
        clazz.registerWith(serializer);
    }
    return serializer;
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:10,代碼來源:GraphDatabaseConfiguration.java

示例15: edgeTypeIDTest

import com.thinkaurelius.titan.graphdb.database.serialize.Serializer; //導入依賴的package包/類
@Test
    public void edgeTypeIDTest() {
        int partitionBits = 16;
        IDManager eid = new IDManager(partitionBits);
        int trails = 1000000;
        assertEquals(eid.getPartitionBound(), (1l << partitionBits));

        Serializer serializer = new StandardSerializer();
        for (int t = 0; t < trails; t++) {
            long count = RandomGenerator.randomLong(1, eid.getSchemaCountBound());
            long id;
            IDHandler.DirectionID dirID;
            RelationCategory type;
            if (Math.random() < 0.5) {
                id = eid.getSchemaId(IDManager.VertexIDType.UserEdgeLabel,count);
                assertTrue(eid.isEdgeLabelId(id));
                assertFalse(eid.isSystemRelationTypeId(id));
                type = RelationCategory.EDGE;
                if (Math.random() < 0.5)
                    dirID = IDHandler.DirectionID.EDGE_IN_DIR;
                else
                    dirID = IDHandler.DirectionID.EDGE_OUT_DIR;
            } else {
                type = RelationCategory.PROPERTY;
                id = eid.getSchemaId(IDManager.VertexIDType.UserPropertyKey,count);
                assertTrue(eid.isPropertyKeyId(id));
                assertFalse(eid.isSystemRelationTypeId(id));
                dirID = IDHandler.DirectionID.PROPERTY_DIR;
            }
            assertTrue(eid.isRelationTypeId(id));

            StaticBuffer b = IDHandler.getRelationType(id, dirID, false);
//            System.out.println(dirID);
//            System.out.println(getBinary(id));
//            System.out.println(getBuffer(b.asReadBuffer()));
            ReadBuffer rb = b.asReadBuffer();
            IDHandler.RelationTypeParse parse = IDHandler.readRelationType(rb);
            assertEquals(id,parse.typeId);
            assertEquals(dirID, parse.dirID);
            assertFalse(rb.hasRemaining());

            //Inline edge type
            WriteBuffer wb = new WriteByteBuffer(9);
            IDHandler.writeInlineRelationType(wb, id);
            long newId = IDHandler.readInlineRelationType(wb.getStaticBuffer().asReadBuffer());
            assertEquals(id,newId);

            //Compare to Kryo
            DataOutput out = serializer.getDataOutput(10);
            IDHandler.writeRelationType(out, id, dirID, false);
            assertEquals(b, out.getStaticBuffer());

            //Make sure the bounds are right
            StaticBuffer[] bounds = IDHandler.getBounds(type,false);
            assertTrue(bounds[0].compareTo(b)<0);
            assertTrue(bounds[1].compareTo(b)>0);
            bounds = IDHandler.getBounds(RelationCategory.RELATION,false);
            assertTrue(bounds[0].compareTo(b)<0);
            assertTrue(bounds[1].compareTo(b)>0);
        }
    }
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:62,代碼來源:IDManagementTest.java


注:本文中的com.thinkaurelius.titan.graphdb.database.serialize.Serializer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。