Examples of BlockId


Examples of org.jcoredb.fs.BlockId

   * @param block
   */
  public void put(Block block)
  {
    //Get the segment id from the block id
    BlockId blockId = block.getId();
    SegmentId segId = new SegmentId(blockId.getContainerId(), blockId.getSegmentId());

    //Get or init the values list
    List<Block> values;
   
    if (containsKey(segId))
View Full Code Here

Examples of org.jcoredb.fs.BlockId

   * @see org.jcoredb.fs.IFileSystem#write(org.jcoredb.fs.Block)
   */
  @Override
  public void write(Block block) throws BlockWriteErr, SegmentGetErr
  {
    BlockId id = block.getId();
   
    IContainer c = containers.get(id.getContainerId());
    DataSegment seg = (DataSegment) c.getSegment(id.getSegmentId());
   
    seg.writeBlock(block);
  }
View Full Code Here

Examples of org.jcoredb.fs.BlockId

   * @see org.jcoredb.fs.IFileSystem#append(org.jcoredb.fs.Block, boolean)
   */
  @Override
  public BlockId append(Block block, boolean only) throws BlockAppendErr
  {
    BlockId blockId = block.getId();
   
    IContainer c = containers.get(block.getId().getContainerId());
   
    blockId = c.append(block, only);
   
View Full Code Here

Examples of org.jcoredb.fs.BlockId

  @Override
  public void run() {
   
    try
    {
      BlockId id = block.getId();
   
      IContainer c = fs.getContainer(id.getContainerId());
      DataSegment seg = (DataSegment) c.getSegment(id.getSegmentId());
     
      seg.writeBlock(block);
    }
    catch (Exception e)
    {
View Full Code Here

Examples of org.jcoredb.fs.BlockId

   * @param block
   */
  public void put(Block block)
  {
    //Get the segment id from the block id
    BlockId blockId = block.getId();
    int cntId = blockId.getContainerId();

    //Get or init the values list
    List<Block> values;
   
    if (containsKey(cntId))
View Full Code Here

Examples of org.jcoredb.fs.BlockId

   * @see org.jcoredb.fs.IContainer#append(org.jcoredb.fs.Block, boolean)
   */
  @Override
  public BlockId append(Block block, boolean only) throws BlockAppendErr
  {
    BlockId blockId = null;
    DataSegment seg = null;

    try {

      if (!only) {
        blockId = findNextFreeBlock();
      } else {
        blockId = findLastFreeBlock();
      }

      if (blockId != null) {
        seg = segments.get(blockId.getSegmentId());
      } else {
        seg = extend();
        blockId = new BlockId(id, seg.getId(), 0);
      }

      block.setId(blockId);

      // System.out.println(blockId);
View Full Code Here

Examples of org.jcoredb.fs.BlockId

  {
    for (DataSegment seg : this.segments.values())
    {
      for (int i = 0; i < this.segmentSize; i++)
      {
        if (seg.getHeader().isFree(i)) return new BlockId(this.id, seg.getId(), i);
      }
    }
   
    return null;
  }
View Full Code Here

Examples of org.jcoredb.fs.BlockId

   
    int lastFree = lastSeg.getHeader().getLastFree();
   
    if (lastFree != -1)
    {
      return new BlockId(this.id, lastSeg.getId(), lastFree);
    }
    else
    {
      return null;
    }
View Full Code Here

Examples of org.jcoredb.fs.BlockId

 
    IFileSystem fs = new FileSystem(Constants.ROOT_PATH);
    fs.create(0);
    fs.open();
   
    Block b = new Block(new BlockId(0));
    byte[] content = "<test> <content> Hello world! </content> </test>".getBytes();
    b.setBytes(content);
   
    Block b2 = new Block(new BlockId(0));
    b.setBytes(content);
   
    BlockId bid = fs.append(b, false);
    BlockId bid2 = fs.append(b2, false);
   
    assertEquals(0, bid.getContainerId());
    assertEquals(0, bid.getSegmentId());
    assertEquals(0, bid.getId());
   
    assertEquals(0, bid2.getContainerId());
    assertEquals(0, bid2.getSegmentId());
    assertEquals(1, bid2.getId());
       
    fs.close();
  }
View Full Code Here

Examples of org.jcoredb.fs.BlockId

    ArrayList<Block> blocks = new ArrayList<Block>();
    ArrayList<BlockId> blockIds = new ArrayList<BlockId>();
   
    for (int i = 0; i < 200; i++) {

      Block b = new Block(new BlockId(0));
      byte[] content = "<test> <content> Hello world! </content> </test>".getBytes();
      b.setBytes(content);
     
      blocks.add(b);
     
      BlockId bid = fs.append(b, false);

      blockIds.add(bid);
    }

    BlockId toDelete = blockIds.get(100);
   
    fs.delete(toDelete, true);
   
    Block b = fs.read(toDelete);
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.