Truncates log entries with indexes {@code >= entryIndex}.

@return truncated log entries
@throws IllegalArgumentException If no entries are available to
truncate, if {@code entryIndex} is
greater than last log index or smaller
than snapshot index.
551012
public List<LogEntry> truncateEntriesFrom(long entryIndex) {
        if (entryIndex <= snapshotIndex()) {
            throw new IllegalArgumentException("Illegal index: " + entryIndex + ", snapshot index: " + snapshotIndex());
        }
        if (entryIndex > lastLogOrSnapshotIndex()) {
            throw new IllegalArgumentException("Illegal index: " + entryIndex + ", last log index: " + lastLogOrSnapshotIndex());
        }

        long startSequence = toSequence(entryIndex);
        assert startSequence >= logs.headSequence() : "Entry index: " + entryIndex + ", Head Seq: " + logs.headSequence();

        List<LogEntry> truncated = new ArrayList<LogEntry>();
        for (long ix = startSequence; ix <= logs.tailSequence(); ix++) {
            truncated.add(logs.read(ix));
        }
        logs.setTailSequence(startSequence - 1);

        return truncated;
    }
82850
public void truncate() throws IOException {
    getDatabase().checkSecurity(ODatabaseSecurityResources.CLASS, ORole.PERMISSION_UPDATE);

    getDatabase().getStorage().callInLock(new Callable<Object>() {
      public Object call() throws Exception {
        for (int id : clusterIds) {
          getDatabase().getStorage().getClusterById(id).truncate();
        }

        for (OIndex<?> index : getClassIndexes()) {
          index.clear();
        }
        return null;
      }
    }, true);
  }
1046499
public boolean deleteIndex() {

		boolean deleted = false;

		ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();
		TableIndexDao tableIndexDao = geoPackage.getTableIndexDao();
		try {
			// Delete geometry indices and table index
			if (tableIndexDao.isTableExists()) {
				deleted = tableIndexDao.deleteByIdCascade(tableName) > 0;
			}
			// Delete the extensions entry
			if (extensionsDao.isTableExists()) {
				deleted = extensionsDao.deleteByExtension(EXTENSION_NAME,
						tableName) > 0 || deleted;
			}
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to delete Table Index. GeoPackage: "
							+ geoPackage.getName() + ", Table: " + tableName, e);
		}

		return deleted;
	}
255825
private Journal.JournalEntry readInternal() throws IOException {
    if (mInputStream == null) {
      return null;
    }
    JournalEntry entry = mInputStream.mReader.readEntry();
    if (entry != null) {
      return entry;
    }
    if (mInputStream.mFile.isIncompleteLog()) {
      // Incomplete logs may end early.
      return null;
    } else {
      Preconditions.checkState(mInputStream.mFile.isCompletedLog(),
          "Expected log to be either checkpoint, incomplete, or complete");
      ProcessUtils.fatalError(LOG, "Journal entry %s was truncated", mNextSequenceNumber);
      return null;
    }
  }
833069
@Override
	public List<IXADataRecorder> readIncompleteTransactions() {
		List<IXADataRecorder> messageSequences = new ArrayList<IXADataRecorder>();
		// recover all loggers ....
		try {
			
			IXARecorderRecovery recorderRecovery= new XARecorderRecovery(this.loggerFactory);

			Set<IXADataRecorder> xaDataRecorders = recorderRecovery.getRecoveredXADataRecorders();

			for (Iterator<IXADataRecorder> iterator = xaDataRecorders.iterator(); iterator.hasNext();) {
				IXADataRecorder dataRecorder = iterator.next();

				if (!dataRecorder.isEmpty()) {
					messageSequences.add(dataRecorder);
				} else {
					dataRecorder.destroy();
				}

			}
			return messageSequences;
		} catch (Exception e) {
			throw new DelegatedRuntimeException(e);
		}
	}
391412
public Set<Map.Entry<E,Double>> entrySet() {
    return new AbstractSet<Map.Entry<E,Double>>() {
      @Override
      public Iterator<Entry<E, Double>> iterator() {
        return new Iterator<Entry<E,Double>>() {
          final Iterator<Entry<E,MutableInteger>> inner = map.entrySet().iterator();

          public boolean hasNext() {
            return inner.hasNext();
          }

          public Entry<E, Double> next() {
            return new Map.Entry<E,Double>() {
              final Entry<E,MutableInteger> e = inner.next();

              public E getKey() {
                return e.getKey();
              }

              public Double getValue() {
                return e.getValue().doubleValue();
              }

              public Double setValue(Double value) {
                final double old = e.getValue().doubleValue();
                e.getValue().set(value.intValue());
                totalCount = totalCount - (int)old + value.intValue();
                return old;
              }
            };
          }

          public void remove() {
            throw new UnsupportedOperationException();
          }
        };
      }

      @Override
      public int size() {
        return map.size();
      }
    };
  }
391278
protected List<Entry<V>> loadEntryFiles() {
    File[] files = getDirectory().listFiles();
    String prefix = getEntryLogPrefix();
    String suffix = getEntryLogSuffix();
    
    List<Entry<V>> entryList = new ArrayList<Entry<V>>();
    if(files == null) return entryList;
    
    for (File file : files) {
      String fileName = file.getName();
      if (fileName.startsWith(prefix) && fileName.endsWith(suffix)) {
        try {
          Entry<V> entry = _entryPool.next();
          entry.load(file);
          entryList.add(entry);
        } catch(Exception e) {
          String filePath = file.getAbsolutePath();
          _log.warn(filePath + " corrupted: length=" + file.length(), e);
          if(file.delete()) {
            _log.warn(filePath + " deleted");
          }
        }
      }
    }
    
    return entryList;
  }
432810
@Initialize(distributed = false)
    public void truncateIfNecesary() {
        if (truncateTable) {
            final UpdateableDatastoreConnection con = datastore.openConnection();
            try {
                final SchemaNavigator schemaNavigator = con.getSchemaNavigator();

                final Table table = schemaNavigator.convertToTable(schemaName, tableName);

                final UpdateableDataContext dc = con.getUpdateableDataContext();
                dc.executeUpdate(new UpdateScript() {
                    @Override
                    public void run(UpdateCallback callback) {
                        final RowDeletionBuilder delete = callback.deleteFrom(table);
                        if (logger.isInfoEnabled()) {
                            logger.info("Executing truncating DELETE operation: {}", delete.toSql());
                        }
                        delete.execute();
                    }
                });
            } finally {
                con.close();
            }
        }
    }
1199562
public static Truncate truncate(@NonNull String table) {
    return truncate(null, CqlIdentifier.fromCql(table));
  }
567427
public List<LogRecord> getView() {
        return new AbstractList<LogRecord>() {
            public LogRecord get(int index) {
                // flip the order
                synchronized (RingBufferLogHandler.this) {
                    return records[(start+(size-(index+1)))%records.length];
                }
            }

            public int size() {
                return size;
            }
        };
    }
253580
public Set<String> entries() {
        Set<String> es = this.entries;
        if (es == null) {
            // lazily scan the entries
            this.entries = scan();
        }
        return this.entries;
    }
927215
public void appendEntries(LogEntry... newEntries) {
        int lastTerm = lastLogOrSnapshotTerm();
        long lastIndex = lastLogOrSnapshotIndex();

        if (!checkAvailableCapacity(newEntries.length)) {
            throw new IllegalStateException("Not enough capacity! Capacity: " + logs.getCapacity()
                    + ", Size: " + logs.size() + ", New entries: " + newEntries.length);
        }

        for (LogEntry entry : newEntries) {
            if (entry.term() < lastTerm) {
                throw new IllegalArgumentException("Cannot append " + entry + " since its term is lower than last log term: "
                        + lastTerm);
            }
            if (entry.index() != lastIndex + 1) {
                throw new IllegalArgumentException("Cannot append " + entry
                        + " since its index is bigger than (lastLogIndex + 1): " + (lastIndex + 1));
            }
            logs.add(entry);
            lastIndex++;
            lastTerm = Math.max(lastTerm, entry.term());
        }
    }
245869
synchronized Collection<KeyValue> getAll(long index) {
        incrementLastAppliedIndex(index);

        Collection<KeyValue> copiedEntries = Lists.newArrayListWithCapacity(entries.size());
        for (Map.Entry<String, String> entry : entries.entrySet()) {
            copiedEntries.add(new KeyValue(entry.getKey(), entry.getValue()));
        }

        return copiedEntries;
    }
1264789
public List<RawEntry> toRawList(){
		if (t == null || t.size() == 0){
			return Collections.emptyList();
		}
		
		List<RawEntry> result = new ArrayList<RawEntry>(t.size());
		int lastDuration = 0;
		for (int i = 0; i < t.size(); i ++){
			long timestamp = t.get(i);
			int duration = -1;
			if (i < d.size()){
				duration = d.get(i);
			}
			if (duration == -1){
				duration = lastDuration;
			}
			lastDuration = duration;
			
			long timestampMillis;
			long durationMillis;
			if (u == null || u.equals("m")){
				timestampMillis = 1000L * 60 * timestamp;
				durationMillis = 1000L * 60 * duration;
			}else if (u.equals("s")){
				timestampMillis = 1000L * timestamp;
				durationMillis = 1000L * duration;
			}else if (u.equals("S")){
				timestampMillis = timestamp;
				durationMillis = duration;
			}else{
				throw new IllegalArgumentException("Unit not supported: " + u);
			}
			
			result.add(new RawEntry(timestampMillis, durationMillis,
					c == null || i >= c.size() ? null : c.get(i),
					s == null || i >= s.size() ? null : s.get(i),
					a == null || i >= a.size() ? null : a.get(i),
					m == null || i >= m.size() ? null : m.get(i),
					x == null || i >= x.size() ? null : x.get(i),
					n == null || i >= n.size() ? null : n.get(i),
					o == null || i >= o.size() ? null : o.get(i)
					));
			
		}
		return result;
	}
728644
public static Truncate truncate(@Nullable CqlIdentifier keyspace, @NonNull CqlIdentifier table) {
    return new DefaultTruncate(keyspace, table);
  }
1093859
public boolean containsLogEntry(long entryIndex) {
        long sequence = toSequence(entryIndex);
        return sequence >= logs.headSequence() && sequence <= logs.tailSequence();
    }
96960
public List<Entry> getEntries() {
        List<Entry> allEntries = new ArrayList<Entry>();

        if (root != null) {
            getEntries(root, allEntries);
        }

        return allEntries;
    }