Example usage for org.eclipse.jgit.internal.storage.dfs DfsPackDescription setPackSource

List of usage examples for org.eclipse.jgit.internal.storage.dfs DfsPackDescription setPackSource

Introduction

In this page you can find the example usage for org.eclipse.jgit.internal.storage.dfs DfsPackDescription setPackSource.

Prototype

public DfsPackDescription setPackSource(@NonNull PackSource source) 

Source Link

Document

Set the source of the pack.

Usage

From source file:com.benhumphreys.jgitcassandra.repo.CassandraObjDatabase.java

License:Apache License

/**
 * Generate a new unique name for a pack file.
 *
 * @param source where the pack stream is created
 * @return a unique name for the pack file. Guaranteed not to collide
 * with any other pack file name in the same DFS.
 * @throws IOException if a new pack name could not be generated
 *///from  w ww .ja  v  a2s  . c o  m
@Override
protected DfsPackDescription newPack(PackSource source) throws IOException {
    DfsPackDescription desc = new DfsPackDescription(getRepository().getDescription(),
            UUID.randomUUID() + "-" + source.name());
    return desc.setPackSource(source);
}

From source file:com.benhumphreys.jgitcassandra.store.ObjStore.java

License:Apache License

/**
 * Converts a row to a DfsPackDescription
 *///from   w w w  .  j a  v  a2s  .  c om
private DfsPackDescription rowToPackDescription(Row row) {
    final String name = row.getString("name");
    final int source = row.getInt("source");
    final long lastModified = row.getLong("last_modified");
    final Map<String, Long> sizeMap = row.getMap("size_map", String.class, Long.class);
    final long objectCount = row.getLong("object_count");
    final long deltaCount = row.getLong("delta_count");
    final int extensions = row.getInt("extensions");
    final int indexVersion = row.getInt("index_version");

    DfsPackDescription desc = new DfsPackDescription(repoDesc, name);

    desc.setPackSource(DfsObjDatabase.PackSource.values()[source]);
    desc.setLastModified(lastModified);
    DescMapper.setFileSizeMap(desc, sizeMap);
    desc.setObjectCount(objectCount);
    desc.setDeltaCount(deltaCount);
    DescMapper.setExtsFromBits(desc, extensions);
    desc.setIndexVersion(indexVersion);

    return desc;
}

From source file:org.chodavarapu.jgitaws.repositories.PackDescriptionRepository.java

License:Eclipse Distribution License

private static DfsPackDescription fromJson(String json, DfsPackDescription desc) {
    JSONObject object = new JSONObject(json);

    desc.setPackSource(object.optEnum(DfsObjDatabase.PackSource.class, "source"))
            .setLastModified(object.optLong("modified")).setObjectCount(object.optLong("objects"))
            .setDeltaCount(object.optLong("deltas")).setIndexVersion(object.optInt("ixVersion"))
            .clearPackStats();//from  w  ww.  ja v  a  2s.c o  m

    for (PackExt ext : PackExt.values()) {
        if (object.has(ext.getExtension() + "Size")) {
            desc.addFileExt(ext);
            desc.setFileSize(ext, object.getLong(ext.getExtension() + "Size"));
        }
    }

    return desc;
}