示例#1
0
 /**
  * Creates internal hive format version info.
  *
  * @throws IOException
  */
 private void createVersionInfo() throws IOException {
   final byte[] bytes = CURRENTVERSION.getBytes();
   final Tree root = new Tree(repository);
   FileTreeEntry versionFile = root.addFile(VERSION_PATH);
   versionFile.setId(writeBytes(bytes));
   Commit commit = commitTree(root);
   updateHead(commit);
 }
示例#2
0
 public Version put(final String key, final byte[] data, final List<Version> parents) {
   try {
     Tree root = getLatestRoot();
     for (Version parent : parents) {
       VersionImpl version = (VersionImpl) parent;
       TreeEntry treeMember = root.findBlobMember(version.getEntry().getFullName());
       if (treeMember != null) {
         treeMember.delete();
       }
     }
     VersionImpl version = updateTree(root, key, data);
     return version;
   } catch (Exception e) {
     throw new SwarmdbException("Unable to update key: " + key, e);
   }
 }
示例#3
0
 public List<Version> get(final String key) {
   ArrayList<Version> result = new ArrayList<Version>();
   try {
     Commit commit = getLastCommit();
     Tree root = commit.getTree();
     TreeEntry subTreeEntry = root.findTreeMember(key);
     if (subTreeEntry instanceof Tree) {
       Tree subTree = (Tree) subTreeEntry;
       for (TreeEntry entry : subTree.members()) {
         if (entry instanceof FileTreeEntry) {
           result.add(new VersionImpl(commit, key, (FileTreeEntry) entry));
         }
       }
     }
   } catch (Exception e) {
     throw new SwarmdbException("Unable to update key: " + key, e);
   }
   return result;
 }
示例#4
0
 private VersionImpl updateTree(final Tree root, final String key, final byte[] data)
     throws IOException {
   ObjectId objectId = writeBytes(data);
   FileTreeEntry fileTreeEntry = root.addFile(key + "/" + objectId.name());
   fileTreeEntry.setId(objectId);
   Commit commit = commitTree(root);
   updateHead(commit);
   VersionImpl version = new VersionImpl(commit, key, fileTreeEntry);
   return version;
 }