Examples of FileSegment


Examples of fi.foyt.hibernate.gae.search.persistence.domainmodel.FileSegment

        switchCurrentSegment();
      }
 
      FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();
     
      FileSegment fileSegment = getCurrentSegment();
      byte[] segmentData = getSegmentData(fileSegment, segmentPosition + 1);
      segmentData[segmentPosition++] = b;
      fileSegmentDAO.updateData(fileSegment, segmentData);
    } catch (Exception e) {
      throw new IOException(e);
View Full Code Here

Examples of fi.foyt.hibernate.gae.search.persistence.domainmodel.FileSegment

          currentSegmentIndex++;
          switchCurrentSegment();
        }
       
        FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();
        FileSegment fileSegment = getCurrentSegment();
        int remainInSegment = GaeFile.SEGMENT_SIZE - segmentPosition;
        int bytesToCopy = len < remainInSegment ? len : remainInSegment;
       
        byte[] segmentData = getSegmentData(fileSegment, segmentPosition + bytesToCopy);
 
View Full Code Here

Examples of fi.foyt.hibernate.gae.search.persistence.domainmodel.FileSegment

  public FileSegmentDAO() {
    super("FILESEGMENT", true);
  }

  public FileSegment create(File file, Long segmentNo, byte[] data) {
    FileSegment fileSegment = new FileSegment(file);
    fileSegment.setData(data);
    fileSegment.setSegmentNo(segmentNo);
    persist(fileSegment);
   
    String lookupKey = FILE_SEGMENTNO_LOOKUP + file.getKey() + "," + segmentNo;
    putLookupKey(lookupKey, fileSegment.getKey());
    updateCountCache(file, countByFile(file) + 1);
    return fileSegment;
  }
View Full Code Here

Examples of fi.foyt.hibernate.gae.search.persistence.domainmodel.FileSegment

    }
   
    Query query = new Query(getKind(), file.getKey())
      .addFilter("segmentNo", FilterOperator.EQUAL, segmentNo);
   
    FileSegment fileSegment = getSingleObject(query);

    if (fileSegment != null) {
      putLookupKey(lookupKey, fileSegment.getKey());
    } else {
      putLookupKey(lookupKey, createNullLookupKey());
    }
   
    return fileSegment;
View Full Code Here

Examples of fi.foyt.hibernate.gae.search.persistence.domainmodel.FileSegment

    return currentSegmentIndex < 0 ? 0 : segmentStart + segmentPosition;
  }

  @Override
  public void seek(long pos) throws IOException {
    FileSegment fileSegment = getCurrentSegment();

    if (fileSegment == null || pos < segmentStart || pos >= segmentStart + GaeFile.SEGMENT_SIZE) {
      currentSegmentIndex = (int) (pos / GaeFile.SEGMENT_SIZE);
      switchCurrentSegment(false);
    }
View Full Code Here

Examples of org.apache.spark.storage.FileSegment

  }

  @Override
  public void channelRead0(ChannelHandlerContext ctx, String blockIdString) {
    BlockId blockId = BlockId.apply(blockIdString);
    FileSegment fileSegment = pResolver.getBlockLocation(blockId);
    // if getBlockLocation returns null, close the channel
    if (fileSegment == null) {
      //ctx.close();
      return;
    }
    File file = fileSegment.file();
    if (file.exists()) {
      if (!file.isFile()) {
        ctx.write(new FileHeader(0, blockId).buffer());
        ctx.flush();
        return;
      }
      long length = fileSegment.length();
      if (length > Integer.MAX_VALUE || length <= 0) {
        ctx.write(new FileHeader(0, blockId).buffer());
        ctx.flush();
        return;
      }
      int len = (int) length;
      ctx.write((new FileHeader(len, blockId)).buffer());
      try {
        ctx.write(new DefaultFileRegion(new FileInputStream(file)
          .getChannel(), fileSegment.offset(), fileSegment.length()));
      } catch (Exception e) {
          LOG.error("Exception: ", e);
      }
    } else {
      ctx.write(new FileHeader(0, blockId).buffer());
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.