Codota Logo
AbstractBlockFile
Code IndexAdd Codota to your IDE (free)

How to use
AbstractBlockFile
in
org.mulgara.store.xa

Best Java code snippets using org.mulgara.store.xa.AbstractBlockFile (Showing top 14 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: org.openrdf.mulgara/mulgara-util-xa

/**
 * Returns a BlockFile which represents an open file with the specified file
 * name. If the file does not exist it will be created. This factory method
 * allows the type of implementation to be selected.
 *
 * @param fileName the name of the file to open.
 * @param blockSize the size of a block in bytes.
 * @param ioType The type of access to use on the file, memory mapped or with explicit IO.
 * @return the open BlockFile.
 * @throws IOException if an I/O error occurs.
 */
public static BlockFile openBlockFile(
  String fileName, int blockSize, IOType ioType
) throws IOException {
 return openBlockFile(new File(fileName), blockSize, ioType);
}
origin: org.openrdf.mulgara/mulgara-util-xa

/**
 * Truncates the file to zero length.
 *
 * @throws IOException if an I/O error occurs.
 */
public void clear() throws IOException {
 int maxNrRegions = INITIAL_NR_REGIONS;
 mappedByteBuffers = new MappedByteBuffer[maxNrRegions];
 srcByteBuffers = new ByteBuffer[maxNrRegions];
 intBuffers = new IntBuffer[maxNrRegions];
 longBuffers = new LongBuffer[maxNrRegions];
 nrMappedRegions = 0;
 /*
 if (System.getProperty("os.name").startsWith("Win")) {
  // This is needed for Windows.
  System.gc();
  try { Thread.sleep(100); } catch (InterruptedException ie) { }
  System.runFinalization();
 }
 */
 super.clear();
}
origin: org.openrdf.mulgara/mulgara-util-xa

/**
 * Close and delete the block file.
 *
 * @throws IOException if an I/O error occurs
 */
public synchronized void delete() throws IOException {
 try {
  close();
 } finally {
  if (file != null) {
   int retries = 10;
   while (!file.delete() && file.isFile() && retries-- > 0) {
    // Causing any MappedByteBuffers to be unmapped may allow the
    // file to be deleted.  This may be needed for Windows.
    System.gc();
    try { Thread.sleep(100); } catch (InterruptedException ie) { }
    System.runFinalization();
   }
   if (retries < 0) {
    logger.warn("Failed to delete: " + file);
   }
   file = null;
  }
 }
}
origin: org.openrdf.mulgara/mulgara-util-xa

unmap();
  if (!ensureOpen()) {
   throw ex;
origin: org.openrdf.mulgara/mulgara-util-xa

/**
 * Ensures that all data for this BlockFile is stored in persistent storage
 * before returning.
 *
 * @throws IOException if an I/O error occurs.
 */
public void force() throws IOException {
 for (;;) {
  try {
   fc.force(true);
   break;
  } catch (ClosedChannelException ex) {
   // The Channel may have been inadvertently closed by another thread
   // being interrupted.  Attempt to reopen the channel.
   if (!ensureOpen()) {
    throw ex;
   }
   // Loop back and retry the force().
  }
 }
}
origin: org.openrdf.mulgara/mulgara-util-xa

/**
 * Sets the length of the file in blocks. The file will not be expanded if it
 * is already large enough. The file will be truncated to the correct length
 * when {@link #close} is called.
 *
 * @param nrBlocks the length of the file in blocks.
 * @throws IOException if an I/O error occurs.
 */
public void setNrBlocks(long nrBlocks) throws IOException {
 if (nrBlocks == this.nrBlocks) return;
 long prevNrBlocks = this.nrBlocks;
 super.setNrBlocks(nrBlocks);
 if (nrBlocks <= prevNrBlocks) return;
 // Call mapFile() if the file must grow in size.
 int nrRegions =
   (nrBlocks > 0) ? (int) ((((nrBlocks - 1) * blockSize) / stride) + 1) :
   0;
 if (nrRegions > nrMappedRegions) {
  mapFile(nrRegions);
 }
}
origin: org.openrdf.mulgara/mulgara-util-xa

/**
 * Ensures that all data for this BlockFile is stored in persistent storage
 * before returning.
 *
 * @throws IOException if an I/O error occurs.
 */
public synchronized void force() throws IOException {
 for (int i = 0; i < nrMappedRegions; ++i) {
  mappedByteBuffers[i].force();
 }
 super.force();
 // force file metadata
}
origin: org.openrdf.mulgara/mulgara-util-xa

if (!ensureOpen()) {
 throw ex;
origin: org.openrdf.mulgara/mulgara-util-xa

/**
 * Sets the length of the file in blocks.
 *
 * @param nrBlocks The number of blocks in the file.
 * @throws IOException if an I/O error occurs.
 */
public void setNrBlocks(long nrBlocks) throws IOException {
 if (nrBlocks == this.nrBlocks) return;
 super.setNrBlocks(nrBlocks);
 if (nrBlocks <= allocatedNrBlocks) return;
 allocatedNrBlocks = nrBlocks - (nrBlocks % allocationSize) + allocationSize;
 for (;;) {
  try {
   raf.setLength(allocatedNrBlocks * blockSize);
   break;
  } catch (ClosedChannelException ex) {
   // The Channel may have been inadvertently closed by another thread
   // being interrupted.  Attempt to reopen the channel.
   if (!ensureOpen()) {
    throw ex;
   }
   // Loop back and retry the setLength().
  }
 }
}
origin: org.openrdf.mulgara/mulgara-util-xa

/**
 * Constructs a ManagedBlockFile with the specified file.
 *
 * @param objectPool an objectPool for this thread.
 * @param file the name of the BlockFile.
 * @param blockSize the block size in bytes.
 * @param ioType the type of I/O mechanism to use.
 * @throws IOException if an I/O error occurs.
 */
public ManagedBlockFile(
  ObjectPool objectPool, File file, int blockSize,
  BlockFile.IOType ioType
) throws IOException {
 this.file = file;
 File freeListFile = new File(file + FREELIST_EXT);
 if (file.exists() != freeListFile.exists()) {
  logger.error(
    "ERROR: inconsistency between Block file and Free List file"
  );
 }
 blockFile = AbstractBlockFile.openBlockFile(file, blockSize, ioType);
 freeList = FreeList.openFreeList(objectPool, freeListFile);
 isOpen = true;
}
origin: org.openrdf.mulgara/mulgara-util-xa

ensureOpen();
origin: org.openrdf.mulgara/mulgara-util-xa

/**
 * Constructs a FreeList which uses the specified file (if it exists) or
 * creates a new file (if it doesn't already exist).
 *
 * @param objectPool the ObjectPool to use when allocating Blocks.
 * @param file the file.
 * @param ioType the IOType to use for the BlockFile.
 * @throws IOException if an I/O error occurs.
 */
private FreeList(
  ObjectPool objectPool, File file, BlockFile.IOType ioType
) throws IOException {
 this.objectPool = objectPool;
 objectPool.incRefCount();
 this.file = file;
 blockFile = AbstractBlockFile.openBlockFile(file, BLOCK_SIZE_B, ioType);
 itemToPhaseSeqMap = IntFile.open(file + INTFILE_EXT);
 itemToPhaseSeqMap.clear();
}
origin: org.openrdf.mulgara/mulgara-store-stringpool-xa

  throws IOException, SimpleXAResourceException {
if (metarootFile == null) {
 metarootFile = AbstractBlockFile.openBlockFile(
   fileName + ".sp", METAROOT_SIZE * Constants.SIZEOF_LONG,
   BlockFile.IOType.EXPLICIT
origin: org.openrdf.mulgara/mulgara-store-nodepool-xa

  throws IOException, SimpleXAResourceException {
if (metarootFile == null) {
 metarootFile = AbstractBlockFile.openBlockFile(
   fileName + ".np", METAROOT_SIZE * Constants.SIZEOF_LONG,
   BlockFile.IOType.EXPLICIT
org.mulgara.store.xaAbstractBlockFile

Javadoc

An abstract class that represents a file which consists of a number of blocks that are all the same size.

The implementations are only thread-safe if there is no more than one thread writing to the file at any given time and if the writing thread does not write to blocks being read by the reading threads and does not make the file smaller than the size required by the reading threads.

Most used methods

  • openBlockFile
    Returns a BlockFile which represents an open file with the specified file name. If the file does not
  • clear
    Truncates the file to zero length.
  • close
    Closes the block file.
  • ensureOpen
    Checks that a file is open. If it is not then attempts to open the file. Opening the file will also
  • force
    Ensures that all data for this BlockFile is stored in persistent storage before returning.
  • setNrBlocks
    Sets the length of the file in blocks. An implementation may defer changing the file size until a re
  • unmap
    Unmaps a file. Only applies to mapped files, as used by MappedBlockFile.

Popular in Java

  • Running tasks concurrently on multiple threads
  • onRequestPermissionsResult (Fragment)
  • findViewById (Activity)
  • putExtra (Intent)
  • PrintStream (java.io)
    A PrintStream adds functionality to another output stream, namely the ability to print representatio
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now