Tabnine Logo
TransactionalRecordWriter
Code IndexAdd Tabnine to your IDE (free)

How to use
TransactionalRecordWriter
in
com.oberasoftware.jasdb.writer.transactional

Best Java code snippets using com.oberasoftware.jasdb.writer.transactional.TransactionalRecordWriter (Showing top 8 results out of 315)

origin: oberasoftware/jasdb

  @Override
  public RecordWriter<UUIDKey> createWriter(File file) throws JasDBStorageException {
    return new TransactionalRecordWriter(file);
  }
}
origin: oberasoftware/jasdb

@Override
public RecordIterator readAllRecords() throws DatastoreException {
  return readAllRecords(-1);
}
origin: oberasoftware/jasdb

@Override
public void removeRecord(UUIDKey documentId) throws JasDBStorageException {
  writer.removeRecord(() -> getRecordPointer(documentId), p -> {
    try {
      index.removeFromIndex(documentId);
    } catch (JasDBStorageException e) {
      LOG.error("Unable to remove record from index", e);
    }
  });
}
origin: oberasoftware/jasdb

private void handleIndexScanAndRebuild() throws JasDBStorageException {
  Collection<Index> indexes = getIndexManager().getIndexes(bagName).values();
  List<Future<?>> indexRebuilds = new ArrayList<>(indexes.size());
  LOG.info("Doing index scan for: {} items", getSize());
  RecordWriter recordWriter = recordWriterFactoryLoader.loadRecordWriter(instanceId, bagName);
  if(recordWriter instanceof TransactionalRecordWriter) {
    TransactionalRecordWriter transactionalRecordWriter = (TransactionalRecordWriter) recordWriter;
    LOG.info("Forcing primary key rebuild first, we need to ensure integrity");
    transactionalRecordWriter.verify(recordResult -> {
      try {
        return new UUIDKey(BagOperationUtil.toEntity(recordResult.getStream()).getInternalId());
      } catch (JasDBStorageException e) {
        throw new RuntimeJasDBException("Unable to read jasdb entitiy", e);
      }
    });
  }
  for(final Index index : indexes) {
    LOG.info("Scheduling index rebuild of index: {} for bag: {}", index, bagName);
    indexRebuilds.add(indexRebuilder.submit(new IndexScanAndRecovery(index, getRecordWriter().readAllRecords())));
  }
  for(Future<?> indexRebuild : indexRebuilds) {
    try {
      indexRebuild.get();
    } catch(ExecutionException | InterruptedException e) {
      throw new JasDBStorageException("Unable to initialize bag, index rebuild failed", e);
    }
  }
}
origin: oberasoftware/jasdb

@Override
public void writeRecord(UUIDKey documentId, ClonableDataStream dataStream) throws JasDBStorageException {
  String recordContents = RecordStreamUtil.toString(dataStream);
  writer.writeRecord(recordContents, p -> {
    try {
      index.insertIntoIndex(documentId.cloneKey(false).addKey(keyInfo.getKeyNameMapper(), "RECORD_POINTER", new LongKey(p)));
    } catch(JasDBStorageException e) {
      try {
        removeRecord(documentId);
      } catch (JasDBStorageException e1) {
        LOG.error("", e);
      }
      throw new RuntimeJasDBException("Unable to write record already exists", e);
    }
  });
}
origin: oberasoftware/jasdb

boolean shouldUpdatePosition = false;
try {
  if (!readRecord(key).isRecordFound()) {
    shouldUpdatePosition = true;
origin: oberasoftware/jasdb

@Override
public RecordResult readRecord(UUIDKey documentId) throws JasDBStorageException {
  try {
    return writer.readRecord(() -> getRecordPointer(documentId));
  } catch(RecordNotFoundException e) {
    return new RecordResultImpl(-1, null, 0, RECORD_FLAG.EMPTY);
  }
}
origin: oberasoftware/jasdb

@Override
public void updateRecord(UUIDKey documentId, ClonableDataStream dataStream) throws JasDBStorageException {
  long updatedDocumentPointer = writer.updateRecord(RecordStreamUtil.toString(dataStream), () -> getRecordPointer(documentId), (oldp, newp) -> {
    if(oldp != newp) {
      Key newKey = documentId.cloneKey(false).addKey(keyInfo.getKeyNameMapper(), "RECORD_POINTER", new LongKey(newp));
      try {
        index.updateKey(documentId, newKey);
      } catch (JasDBStorageException e) {
        LOG.error("", e);
      }
    }
  });
}
com.oberasoftware.jasdb.writer.transactionalTransactionalRecordWriter

Most used methods

  • <init>
  • getRecordPointer
  • readAllRecords
  • readRecord
  • removeRecord
  • verify

Popular in Java

  • Finding current android device location
  • onRequestPermissionsResult (Fragment)
  • setContentView (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now