Permalink
Browse files

Basic EmptyRecord and EmptyBlock implementation

  • Loading branch information...
taras-puchko committed Sep 13, 2013
1 parent 34bdff6 commit eb2c91854082c37d1f3fcc4edcc7bdfd5806dfc1
@@ -22,7 +22,6 @@
import org.b1.pack.api.builder.*;
import org.b1.pack.standard.common.*;
-import javax.annotation.Nullable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -97,7 +96,7 @@ private Long createNewId(ObjectKey key) {
return id;
}
- private void addFolderRecords(PbRecordHeader header, @Nullable BuilderFolder folder) {
+ private void addFolderRecords(PbRecordHeader header, BuilderFolder folder) {
PbRecordPointer pointer = createPointer();
addRecords(pointer,
new PbRecord(new PbCatalogFolder(pointer, header)),
@@ -22,7 +22,6 @@
import org.b1.pack.api.builder.Writable;
import org.b1.pack.standard.common.*;
-import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
@@ -73,7 +72,7 @@ public void addContent(Writable content) {
return result;
}
- private void initVolume(@Nullable Long objectCount) {
+ private void initVolume(Long objectCount) {
volumeNumber++;
volumeContent = new CompositeWritable();
volumeContent.add(new ByteArrayWritable(Volumes.createVolumeHead(archiveId, volumeNumber, objectCount, null, null)));
@@ -26,11 +26,14 @@
public static final int COMPLETE_FILE = 2;
public static final int CATALOG_FOLDER = 3;
public static final int COMPLETE_FOLDER = 4;
+ public static final int EMPTY_RECORD = 5;
public static final int AES_BLOCK = 0;
public static final int PLAIN_BLOCK = 1;
public static final int FIRST_LZMA_BLOCK = 2;
public static final int NEXT_LZMA_BLOCK = 3;
+ public static final int RESERVED_BLOCK = 4;
+ public static final int EMPTY_BLOCK = 5;
public static final int LAST_MODIFIED_TIME = 0;
public static final int UNIX_PERMISSIONS = 1;
@@ -18,7 +18,6 @@
import com.google.common.base.Preconditions;
-import javax.annotation.Nullable;
import java.io.*;
public class Numbers {
@@ -61,7 +60,7 @@ public static int getSerializedSize(long value) {
return serializeLong(value).length;
}
- public static void writeLong(@Nullable Long value, OutputStream stream) throws IOException {
+ public static void writeLong(Long value, OutputStream stream) throws IOException {
if (value == null) {
stream.write(1);
} else {
@@ -106,10 +106,11 @@ private void readBlockType() throws IOException {
while (true) {
blockPointer = volumeCursor.getBlockPointer();
blockType = Numbers.readLong(volumeCursor.getInputStream());
- if (blockType != null) {
+ if (blockType == null) {
+ volumeCursor.next();
+ } else if (blockType != Constants.EMPTY_BLOCK) {
return;
}
- volumeCursor.next();
}
}
@@ -66,6 +66,8 @@ private void readCatalog(PackInputStream stream, Long totalCount) throws IOExcep
currentCount++;
readCatalogFolder(stream);
break;
+ case Constants.EMPTY_RECORD:
+ break;
default:
throw new IllegalArgumentException("Invalid entry");
}

0 comments on commit eb2c918

Please sign in to comment.