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

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

Introduction

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

Prototype

@NonNull
public PackSource getPackSource() 

Source Link

Document

Get the source of the pack.

Usage

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

License:Apache License

/**
 * Inserts a Pack description into the store.
 * If a description for this "name" already exists it will be overwritten.
 *
 * @param desc  the pack description to insert
 * @throws IOException  if an exception occurs when communicating to the
 *                      database//from  ww w  .ja  va  2  s.  co  m
 */
public void insertDesc(Collection<DfsPackDescription> desc) throws IOException {

    try {
        for (DfsPackDescription pd : desc) {
            Statement stmt = QueryBuilder.insertInto(keyspace, DESC_TABLE_NAME).value("name", pd.toString())
                    .value("source", pd.getPackSource().ordinal()).value("last_modified", pd.getLastModified())
                    .value("size_map", DescMapper.getFileSizeMap(pd)).value("object_count", pd.getObjectCount())
                    .value("delta_count", pd.getDeltaCount()).value("extensions", DescMapper.getExtBits(pd))
                    .value("index_version", pd.getIndexVersion());
            session.execute(stmt);
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw new IOException(e);
    }
}

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

License:Eclipse Distribution License

private static String toJson(DfsPackDescription desc) {
    JSONObject json = new JSONObject().put("modified", desc.getLastModified())
            .put("objects", desc.getObjectCount()).put("deltas", desc.getDeltaCount())
            .put("ixVersion", desc.getIndexVersion());

    for (PackExt ext : PackExt.values()) {
        if (desc.hasFileExt(ext)) {
            json.put(ext.getExtension() + "Size", desc.getFileSize(ext));
        }/*  w w w .j  av a  2  s .  c  o m*/
    }

    if (desc.getPackSource() != null) {
        json.put("source", desc.getPackSource().name());
    }

    return json.toString();
}