code
stringlengths
73
34.1k
label
stringclasses
1 value
protected void cancel() { int numAnimators = mCurrentAnimators.size(); for (int i = numAnimators - 1; i >= 0; i--) { Animator animator = mCurrentAnimators.get(i); animator.cancel(); } if (mListeners != null && mListeners.size() > 0) { ArrayList<Transit...
java
public BatchPoints point(final Point point) { point.getTags().putAll(this.tags); this.points.add(point); return this; }
java
public String lineProtocol() { StringBuilder sb = new StringBuilder(); for (Point point : this.points) { sb.append(point.lineProtocol(this.precision)).append("\n"); } return sb.toString(); }
java
public boolean isMergeAbleWith(final BatchPoints that) { return Objects.equals(database, that.database) && Objects.equals(retentionPolicy, that.retentionPolicy) && Objects.equals(tags, that.tags) && consistency == that.consistency; }
java
public boolean mergeIn(final BatchPoints that) { boolean mergeAble = isMergeAbleWith(that); if (mergeAble) { this.points.addAll(that.points); } return mergeAble; }
java
public Iterable<QueryResult> traverse(final InputStream is) { MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(is); return () -> { return new Iterator<QueryResult>() { @Override public boolean hasNext() { try { return unpacker.hasNext(); } catch (I...
java
public QueryResult parse(final InputStream is) { MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(is); return parse(unpacker); }
java
public static void checkPositiveNumber(final Number number, final String name) throws IllegalArgumentException { if (number == null || number.doubleValue() <= 0) { throw new IllegalArgumentException("Expecting a positive number for " + name); } }
java
public static void checkNotNegativeNumber(final Number number, final String name) throws IllegalArgumentException { if (number == null || number.doubleValue() < 0) { throw new IllegalArgumentException("Expecting a positive or zero number for " + name); } }
java
public static void checkDuration(final String duration, final String name) throws IllegalArgumentException { if (!duration.matches("(\\d+[wdmhs])+|inf")) { throw new IllegalArgumentException("Invalid InfluxDB duration: " + duration + " for " + name); } }
java
public BatchOptions jitterDuration(final int jitterDuration) { BatchOptions clone = getClone(); clone.jitterDuration = jitterDuration; return clone; }
java
public BatchOptions bufferLimit(final int bufferLimit) { BatchOptions clone = getClone(); clone.bufferLimit = bufferLimit; return clone; }
java
private Call<QueryResult> callQuery(final Query query) { Call<QueryResult> call; String db = query.getDatabase(); if (db == null) { db = this.database; } if (query instanceof BoundParameterQuery) { BoundParameterQuery boundParameterQuery = (BoundParameterQuery) query; call = ...
java
public static InfluxDBException buildExceptionForErrorState(final InputStream messagePackErrorBody) { try { MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(messagePackErrorBody); ImmutableMapValue mapVal = (ImmutableMapValue) unpacker.unpackValue(); return InfluxDBException.buildExceptio...
java
void put(final AbstractBatchEntry batchEntry) { try { this.queue.put(batchEntry); } catch (InterruptedException e) { throw new RuntimeException(e); } if (this.queue.size() >= this.actions) { this.scheduler.submit(new Runnable() { @Override public void run() { ...
java
public static Builder measurementByPOJO(final Class<?> clazz) { Objects.requireNonNull(clazz, "clazz"); throwExceptionIfMissingAnnotation(clazz, Measurement.class); String measurementName = findMeasurementName(clazz); return new Builder(measurementName); }
java
protected void restoreState(View view, Set<ViewCommand<View>> currentState) { if (mViewCommands.isEmpty()) { return; } mViewCommands.reapply(view, currentState); }
java
public void attachView(View view) { if (view == null) { throw new IllegalArgumentException("Mvp view must be not null"); } boolean isViewAdded = mViews.add(view); if (!isViewAdded) { return; } mInRestoreState.add(view); Set<ViewCommand<View>> currentState = mViewStates.get(view); currentState ...
java
public <T extends MvpPresenter> void add(String tag, T instance) { mPresenters.put(tag, instance); }
java
@SuppressWarnings("unused") public boolean isInRestoreState(View view) { //noinspection SimplifiableIfStatement if (mViewState != null) { return mViewState.isInRestoreState(view); } return false; }
java
@SuppressWarnings({"unchecked", "unused"}) public void setViewState(MvpViewState<View> viewState) { mViewStateAsView = (View) viewState; mViewState = (MvpViewState) viewState; }
java
private static boolean hasMoxyReflector() { if (hasMoxyReflector != null) { return hasMoxyReflector; } try { new MoxyReflector(); hasMoxyReflector = true; } catch (NoClassDefFoundError error) { hasMoxyReflector = false; } return hasMoxyReflector; }
java
public void onSaveInstanceState(Bundle outState) { if (mParentDelegate == null) { Bundle moxyDelegateBundle = new Bundle(); outState.putBundle(MOXY_DELEGATE_TAGS_KEY, moxyDelegateBundle); outState = moxyDelegateBundle; } outState.putAll(mBundle); outState.putString(mKeyTag, mDelegateTag); for (MvpD...
java
private static SortedMap<TypeElement, List<TypeElement>> getPresenterBinders(List<TypeElement> presentersContainers) { Map<TypeElement, TypeElement> extendingMap = new HashMap<>(); for (TypeElement presentersContainer : presentersContainers) { TypeMirror superclass = presentersContainer.getSuperclass(); Typ...
java
public void injectPresenter(MvpPresenter<?> presenter, String delegateTag) { Set<String> delegateTags = mConnections.get(presenter); if (delegateTags == null) { delegateTags = new HashSet<>(); mConnections.put(presenter, delegateTags); } delegateTags.add(delegateTag); Set<MvpPresenter> presenters = mT...
java
public boolean rejectPresenter(MvpPresenter<?> presenter, String delegateTag) { Set<MvpPresenter> presenters = mTags.get(delegateTag); if (presenters != null) { presenters.remove(presenter); } if (presenters == null || presenters.isEmpty()) { mTags.remove(delegateTag); } Set<String> delegateTags = mC...
java
public void bind(boolean wholeCore) { if (bound && assignedThread != null && assignedThread.isAlive()) throw new IllegalStateException("cpu " + cpuId + " already bound to " + assignedThread); if (areAssertionsEnabled()) boundHere = new Throwable("Bound here"); if (wholeC...
java
public static String toHexString(final BitSet set) { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter(out); final long[] longs = set.toLongArray(); for (long aLong : longs) { writer.write(Long.toHexString(aLong)); } ...
java
int[] getChunkSizes(Track track) { long[] referenceChunkStarts = fragmenter.sampleNumbers(track); int[] chunkSizes = new int[referenceChunkStarts.length]; for (int i = 0; i < referenceChunkStarts.length; i++) { long start = referenceChunkStarts[i] - 1; long end; ...
java
private void print(FileChannel fc, int level, long start, long end) throws IOException { fc.position(start); if(end <= 0) { end = start + fc.size(); System.out.println("Setting END to " + end); } while (end - fc.position() > 8) { long begin = fc.positi...
java
public ParsableBox parseBox(ReadableByteChannel byteChannel, String parentType) throws IOException { header.get().rewind().limit(8); int bytesRead = 0; int b; while ((b = byteChannel.read(header.get())) + bytesRead < 8) { if (b < 0) { throw new EOFException()...
java
public static List<long[]> getSyncSamplesTimestamps(Movie movie, Track track) { List<long[]> times = new LinkedList<long[]>(); for (Track currentTrack : movie.getTracks()) { if (currentTrack.getHandler().equals(track.getHandler())) { long[] currentTrackSyncSamples = currentTr...
java
public static int[] blowupCompositionTimes(List<CompositionTimeToSample.Entry> entries) { long numOfSamples = 0; for (CompositionTimeToSample.Entry entry : entries) { numOfSamples += entry.getCount(); } assert numOfSamples <= Integer.MAX_VALUE; int[] decodingTime = ne...
java
public static String readString(ByteBuffer byteBuffer) { ByteArrayOutputStream out = new ByteArrayOutputStream(); int read; while ((read = byteBuffer.get()) != 0) { out.write(read); } return Utf8.convert(out.toByteArray()); }
java
protected boolean isChunkReady(StreamingTrack streamingTrack, StreamingSample next) { long ts = nextSampleStartTime.get(streamingTrack); long cfst = nextChunkCreateStartTime.get(streamingTrack); return (ts >= cfst + 2 * streamingTrack.getTimescale()); // chunk interleave of 2 seconds ...
java
protected boolean isFragmentReady(StreamingTrack streamingTrack, StreamingSample next) { long ts = nextSampleStartTime.get(streamingTrack); long cfst = nextFragmentCreateStartTime.get(streamingTrack); if ((ts > cfst + 3 * streamingTrack.getTimescale())) { // mininum fragment length ...
java
protected long[] getSampleSizes(long startSample, long endSample, Track track, int sequenceNumber) { List<Sample> samples = getSamples(startSample, endSample, track); long[] sampleSizes = new long[samples.size()]; for (int i = 0; i < sampleSizes.length; i++) { sampleSizes[i] = sampl...
java
protected ParsableBox createMoof(long startSample, long endSample, Track track, int sequenceNumber) { MovieFragmentBox moof = new MovieFragmentBox(); createMfhd(startSample, endSample, track, sequenceNumber, moof); createTraf(startSample, endSample, track, sequenceNumber, moof); TrackRu...
java
protected ParsableBox createMvhd(Movie movie) { MovieHeaderBox mvhd = new MovieHeaderBox(); mvhd.setVersion(1); mvhd.setCreationTime(getDate()); mvhd.setModificationTime(getDate()); mvhd.setDuration(0);//no duration in moov for fragmented movies long movieTimeScale = movi...
java
public synchronized final void parseDetails() { LOG.debug("parsing details of {}", this.getType()); if (content != null) { ByteBuffer content = this.content; isParsed = true; content.rewind(); _parseDetails(content); if (content.remaining() > 0...
java
public long getSize() { long size = isParsed ? getContentSize() : content.limit(); size += (8 + // size|type (size >= ((1L << 32) - 8) ? 8 : 0) + // 32bit - 8 byte size and type (UserBox.TYPE.equals(getType()) ? 16 : 0)); size += (deadBytes == null ? 0 : deadBytes...
java
private boolean verify(ByteBuffer content) { ByteBuffer bb = ByteBuffer.allocate(l2i(getContentSize() + (deadBytes != null ? deadBytes.limit() : 0))); getContent(bb); if (deadBytes != null) { deadBytes.rewind(); while (deadBytes.remaining() > 0) { bb.put(d...
java
static int[] allTags() { int[] ints = new int[0xFE - 0x6A]; for (int i = 0x6A; i < 0xFE; i++) { final int pos = i - 0x6A; LOG.trace("pos: {}", pos); ints[pos] = i; } return ints; }
java
public String[] getAllTagNames() { String names[] = new String[tags.size()]; for (int i = 0; i < tags.size(); i++) { XtraTag tag = tags.elementAt(i); names[i] = tag.tagName; } return names; }
java
public String getFirstStringValue(String name) { Object objs[] = getValues(name); for (Object obj : objs) { if (obj instanceof String) { return (String) obj; } } return null; }
java
public Date getFirstDateValue(String name) { Object objs[] = getValues(name); for (Object obj : objs) { if (obj instanceof Date) { return (Date) obj; } } return null; }
java
public Long getFirstLongValue(String name) { Object objs[] = getValues(name); for (Object obj : objs) { if (obj instanceof Long) { return (Long) obj; } } return null; }
java
public Object[] getValues(String name) { XtraTag tag = getTagByName(name); Object values[]; if (tag != null) { values = new Object[tag.values.size()]; for (int i = 0; i < tag.values.size(); i++) { values[i] = tag.values.elementAt(i).getValueAsObject(); ...
java
public void setTagValues(String name, String values[]) { removeTag(name); XtraTag tag = new XtraTag(name); for (int i = 0; i < values.length; i++) { tag.values.addElement(new XtraValue(values[i])); } tags.addElement(tag); }
java
public void setTagValue(String name, Date date) { removeTag(name); XtraTag tag = new XtraTag(name); tag.values.addElement(new XtraValue(date)); tags.addElement(tag); }
java
public void setTagValue(String name, long value) { removeTag(name); XtraTag tag = new XtraTag(name); tag.values.addElement(new XtraValue(value)); tags.addElement(tag); }
java
public long[] blowup(int chunkCount) { long[] numberOfSamples = new long[chunkCount]; int j = 0; List<SampleToChunkBox.Entry> sampleToChunkEntries = new LinkedList<Entry>(entries); Collections.reverse(sampleToChunkEntries); Iterator<Entry> iterator = sampleToChunkEntries.iterator...
java
public static synchronized long[] blowupTimeToSamples(List<TimeToSampleBox.Entry> entries) { SoftReference<long[]> cacheEntry; if ((cacheEntry = cache.get(entries)) != null) { long[] cacheVal; if ((cacheVal = cacheEntry.get()) != null) { return cacheVal; ...
java
void register(Object listener) { Multimap<Class<?>, Subscriber> listenerMethods = findAllSubscribers(listener); for (Map.Entry<Class<?>, Collection<Subscriber>> entry : listenerMethods.asMap().entrySet()) { Class<?> eventType = entry.getKey(); Collection<Subscriber> eventMethodsInListener = entry.g...
java
public int deleteRow() { // build the delete string String deleteString = "DELETE FROM " + tableName + this.generatePKWhere(); PreparedStatement ps = null; // System.out.println("delete string "+deleteString); try { // fill the questio...
java
public String getPrimaryKeysString() { String result = ""; for (int i = 0; i < primaryKeys.length; i++) { if (result != "") { result += ", "; } result += primaryKeys[i]; } // end of for (int i=0; i<primaryKeys.length; i++) return...
java
public void insertNewRow() { // reset all fields for (int i = 0; i < komponente.length; i++) { komponente[i].clearContent(); } // end of for (int i=0; i<komponente.length; i++) // reset the field for the primary keys for (int i = 0; i < primaryKeys.length; i++) {...
java
public boolean saveChanges() { // the initial settings of the textfields counts with one // so a real change by the user needs as many changes as there are columns // System.out.print("Anderungen in den Feldern: "); // there are changes to the database // memorize all columns wh...
java
public boolean saveNewRow() { // check the fields of the primary keys whether one is empty boolean onePKempty = false; int tmp; PreparedStatement ps = null; for (tmp = 0; tmp < primaryKeys.length; tmp++) { if (komponente[pkColIndex[tmp]].getC...
java
public int searchRows(String[] words, boolean allWords, boolean ignoreCase, boolean noMatchWhole) { // System.out.print("search in " + tableName + " for: "); // for (int i=0; i < words.length; i++) { // System.out.print(words[i]+", "); // } // Sy...
java
private void disablePKFields() { for (int i = 0; i < primaryKeys.length; i++) { komponente[pkColIndex[i]].setEditable(false); } // end of for (int i=0; i<columns.length; i++) }
java
private void fillZChoice(ZaurusChoice zc, String tab, String col) { Statement stmt = null; try { if (cConn == null) { return; } stmt = cConn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM " + tab ...
java
private void fetchColumns() { Vector temp = new Vector(20); Vector tempType = new Vector(20); try { if (cConn == null) { return; } if (dbmeta == null) { dbmeta = cConn.getMetaData(); } ResultSet c...
java
private String generateWhere(String[] words, boolean allWords, boolean ignoreCase, boolean noMatchWhole) { String result = ""; // if all words must match use AND between the different conditions String join; if (allWords) { join = " AND "; ...
java
private int getColIndex(String name) { for (int i = 0; i < columns.length; i++) { if (name.equals(columns[i])) { return i; } // end of if (name.equals(columns[i])) } // end of for (int i=0; i<columns.length; i++) return -1; }
java
private int getColIndex(String colName, String tabName) { int ordPos = 0; try { if (cConn == null) { return -1; } if (dbmeta == null) { dbmeta = cConn.getMetaData(); } ResultSet colList = dbmeta.getColumns(nu...
java
private int getConstraintIndex(int colIndex) { for (int i = 0; i < imColIndex.length; i++) { for (int j = 0; j < imColIndex[i].length; j++) { if (colIndex == imColIndex[i][j]) { return i; } // end of if (col == imColIndex[i][j]) } ...
java
private void showAktRow() { try { pStmt.clearParameters(); for (int i = 0; i < primaryKeys.length; i++) { pStmt.setObject(i + 1, resultRowPKs[aktRowNr][i]); } // end of for (int i=0; i<primaryKeys.length; i++) ResultSet rs = pStmt.executeQuer...
java
private void voltConvertBinaryLiteralOperandsToBigint() { // Strange that CONCAT is an arithmetic operator. // You could imagine using it for VARBINARY, so // definitely don't convert its operands to BIGINT! assert(opType != OpTypes.CONCAT); for (int i = 0; i < nodes.length; ++i...
java
public int findColumn(String tableName, String columnName) { // The namedJoinColumnExpressions are ExpressionColumn objects // for columns named in USING conditions. Each range variable // has a possibly empty list of these. If two range variables are // operands of a join with a USING...
java
void addIndexCondition(Expression[] exprList, Index index, int colCount, boolean isJoin) { // VoltDB extension if (rangeIndex == index && isJoinIndex && (!isJoin) && (multiColumnCount > 0) && (colCount == 0)) { // This is one particular set of conditions wh...
java
public HsqlName getSubqueryTableName() { HsqlName hsqlName = new HsqlName(this, SqlInvariants.SYSTEM_SUBQUERY, false, SchemaObject.TABLE); hsqlName.schema = SqlInvariants.SYSTEM_SCHEMA_HSQLNAME; return hsqlName; }
java
static public HsqlName getAutoColumnName(int i) { if (i < autoColumnNames.length) { return autoColumnNames[i]; } return new HsqlName(staticManager, makeAutoColumnName("C_", i), 0, false); }
java
public String getString(String key) { String value = wrappedBundle.getString(key); if (value.length() < 1) { value = getStringFromFile(key); // For conciseness and sanity, get rid of all \r's so that \n // will definitively be our line breaks. if (value.in...
java
static private RefCapablePropertyResourceBundle getRef(String baseName, ResourceBundle rb, ClassLoader loader) { if (!(rb instanceof PropertyResourceBundle)) throw new MissingResourceException( "Found a Resource Bundle, but it is a " + rb.g...
java
private static boolean checkPureColumnIndex(Index index, int aggCol, List<AbstractExpression> filterExprs) { boolean found = false; // all left child of filterExprs must be of type TupleValueExpression in equality comparison for (AbstractExpression expr : filterExprs) { if (expr.ge...
java
public static Runnable writeHashinatorConfig( InstanceId instId, String path, String nonce, int hostId, HashinatorSnapshotData hashData, boolean isTruncationSnapshot) throws IOException { final File file = new VoltFile(path, constructHashinatorConfigFilena...
java
public static String parseNonceFromDigestFilename(String filename) { if (filename == null || !filename.endsWith(".digest")) { throw new IllegalArgumentException("Bad digest filename: " + filename); } return parseNonceFromSnapshotFilename(filename); }
java
public static String parseNonceFromHashinatorConfigFilename(String filename) { if (filename == null || !filename.endsWith(HASH_EXTENSION)) { throw new IllegalArgumentException("Bad hashinator config filename: " + filename); } return parseNonceFromSnapshotFilename(filename); }
java
public static String parseNonceFromSnapshotFilename(String filename) { if (filename == null) { throw new IllegalArgumentException("Bad snapshot filename: " + filename); } // For the snapshot catalog if (filename.endsWith(".jar")) { return filename.substring(0...
java
public static List<ByteBuffer> retrieveHashinatorConfigs( String path, String nonce, int maxConfigs, VoltLogger logger) throws IOException { VoltFile directory = new VoltFile(path); ArrayList<ByteBuffer> configs = new ArrayList<ByteBuffer>(); if (directory.list...
java
public static Runnable writeSnapshotCatalog(String path, String nonce, boolean isTruncationSnapshot) throws IOException { String filename = SnapshotUtil.constructCatalogFilenameForNonce(nonce); try { return VoltDB.instance().getCatalogContext().writeCatalogJarToFile(path, fil...
java
public static Runnable writeTerminusMarker(final String nonce, final NodeSettings paths, final VoltLogger logger) { final File f = new File(paths.getVoltDBRoot(), VoltDB.TERMINUS_MARKER); return new Runnable() { @Override public void run() { try(PrintWriter pw = n...
java
public static void retrieveSnapshotFiles( File directory, Map<String, Snapshot> namedSnapshotMap, FileFilter filter, boolean validate, SnapshotPathType stype, VoltLogger logger) { NamedSnapshots namedSnapshots = new NamedSnapshots(namedSna...
java
public static final String constructFilenameForTable(Table table, String fileNonce, SnapshotFormat format, int hostId) { String extension...
java
public static void requestSnapshot(final long clientHandle, final String path, final String nonce, final boolean blocking, final SnapshotFormat format, ...
java
public static ListenableFuture<SnapshotCompletionInterest.SnapshotCompletionEvent> watchSnapshot(final String nonce) { final SettableFuture<SnapshotCompletionInterest.SnapshotCompletionEvent> result = SettableFuture.create(); SnapshotCompletionInterest interest = new SnapshotComplet...
java
public static HashinatorSnapshotData retrieveHashinatorConfig( String path, String nonce, int hostId, VoltLogger logger) throws IOException { HashinatorSnapshotData hashData = null; String expectedFileName = constructHashinatorConfigFilenameForNonce(nonce, hostId); File[] files = new...
java
public static String getRealPath(SnapshotPathType stype, String path) { if (stype == SnapshotPathType.SNAP_CL) { return VoltDB.instance().getCommandLogSnapshotPath(); } else if (stype == SnapshotPathType.SNAP_AUTO) { return VoltDB.instance().getSnapshotPath(); } r...
java
public void close() throws SQLException { validate(); try { this.connection.rollback(); this.connection.clearWarnings(); this.connectionDefaults.setDefaults(this.connection); this.connection.reset(); fireCloseEvent(); } catch (SQLExce...
java
public void closePhysically() throws SQLException { SQLException exception = null; if (!isClosed && this.connection != null && !this.connection.isClosed()) { try { this.connection.close(); } catch (SQLException e) { //catch and h...
java
public void startSnapshotWithTargets(Collection<SnapshotDataTarget> targets, long now) { // TRAIL [SnapSave:9] 5 [all SP] Start snapshot by putting task into the site queue. //Basically asserts that there are no tasks with null targets at this point //getTarget checks and crashes for...
java
private List<BBContainer> getOutputBuffers(Collection<SnapshotTableTask> tableTasks, boolean noSchedule) { final int desired = tableTasks.size(); while (true) { int available = m_availableSnapshotBuffers.get(); //Limit the number of buffers used concurrently if (...
java
public void write(RowOutputInterface out, ResultMetaData meta) throws IOException { beforeFirst(); out.writeLong(id); out.writeInt(size); out.writeInt(0); // offset out.writeInt(size); while (hasNext()) { Object[] data = getNext(); ...
java
public static ClientInterface create( HostMessenger messenger, CatalogContext context, ReplicationRole replicationRole, Cartographer cartographer, InetAddress clientIntf, int clientPort, InetAddress adminIntf, int adminPort,...
java
public void initializeSnapshotDaemon(HostMessenger messenger, GlobalServiceElector gse) { m_snapshotDaemon.init(this, messenger, new Runnable() { @Override public void run() { bindAdapter(m_snapshotDaemonAdapter, null); } }, gse); }
java
public ClientInterfaceHandleManager bindAdapter(final Connection adapter, final ClientInterfaceRepairCallback repairCallback) { return bindAdapter(adapter, repairCallback, false); }
java
public void mayActivateSnapshotDaemon() { SnapshotSchedule schedule = m_catalogContext.get().database.getSnapshotschedule().get("default"); if (schedule != null) { final ListenableFuture<Void> future = m_snapshotDaemon.mayGoActiveOrInactive(schedule); future.addListener(n...
java
public void notifyOfCatalogUpdate() { m_catalogContext.set(VoltDB.instance().getCatalogContext()); /* * Update snapshot daemon settings. * * Don't do it if the system is still initializing (CL replay), * because snapshot daemon may call @SnapshotScan on activation and...
java
private final void checkForDeadConnections(final long now) { final ArrayList<Pair<Connection, Integer>> connectionsToRemove = new ArrayList<Pair<Connection, Integer>>(); for (final ClientInterfaceHandleManager cihm : m_cihm.values()) { // Internal connections don't implement calculatePending...
java