repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/cache/OAbstractRecordCache.java | OAbstractRecordCache.startup | public void startup() {
underlying.startup();
OProfiler.getInstance().registerHookValue(profilerPrefix + "enabled", new OProfilerHookValue() {
public Object getValue() {
return isEnabled();
}
});
OProfiler.getInstance().registerHookValue(profilerPrefix + "current", new OProfilerHookValue() {
public Object getValue() {
return getSize();
}
});
OProfiler.getInstance().registerHookValue(profilerPrefix + "max", new OProfilerHookValue() {
public Object getValue() {
return getMaxSize();
}
});
} | java | public void startup() {
underlying.startup();
OProfiler.getInstance().registerHookValue(profilerPrefix + "enabled", new OProfilerHookValue() {
public Object getValue() {
return isEnabled();
}
});
OProfiler.getInstance().registerHookValue(profilerPrefix + "current", new OProfilerHookValue() {
public Object getValue() {
return getSize();
}
});
OProfiler.getInstance().registerHookValue(profilerPrefix + "max", new OProfilerHookValue() {
public Object getValue() {
return getMaxSize();
}
});
} | [
"public",
"void",
"startup",
"(",
")",
"{",
"underlying",
".",
"startup",
"(",
")",
";",
"OProfiler",
".",
"getInstance",
"(",
")",
".",
"registerHookValue",
"(",
"profilerPrefix",
"+",
"\"enabled\"",
",",
"new",
"OProfilerHookValue",
"(",
")",
"{",
"public"... | All operations running at cache initialization stage | [
"All",
"operations",
"running",
"at",
"cache",
"initialization",
"stage"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/cache/OAbstractRecordCache.java#L136-L156 | train |
loldevs/riotapi | spectator/src/main/java/net/boreeas/riotapi/spectator/GameEncryptionData.java | GameEncryptionData.getCipher | public Cipher getCipher() throws GeneralSecurityException {
Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "Blowfish"));
return cipher;
} | java | public Cipher getCipher() throws GeneralSecurityException {
Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "Blowfish"));
return cipher;
} | [
"public",
"Cipher",
"getCipher",
"(",
")",
"throws",
"GeneralSecurityException",
"{",
"Cipher",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"\"Blowfish/ECB/PKCS5Padding\"",
")",
";",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"DECRYPT_MODE",
",",
"new",
"S... | Creates a cipher for decrypting data with the specified key.
@return A Blowfish/ECB/PKCS5Padding cipher in decryption mode.
@throws GeneralSecurityException | [
"Creates",
"a",
"cipher",
"for",
"decrypting",
"data",
"with",
"the",
"specified",
"key",
"."
] | 0b8aac407aa5289845f249024f9732332855544f | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/spectator/src/main/java/net/boreeas/riotapi/spectator/GameEncryptionData.java#L41-L46 | train |
loldevs/riotapi | spectator/src/main/java/net/boreeas/riotapi/spectator/GameEncryptionData.java | GameEncryptionData.getEncryptionCipher | public Cipher getEncryptionCipher() throws GeneralSecurityException {
Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "Blowfish"));
return cipher;
} | java | public Cipher getEncryptionCipher() throws GeneralSecurityException {
Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "Blowfish"));
return cipher;
} | [
"public",
"Cipher",
"getEncryptionCipher",
"(",
")",
"throws",
"GeneralSecurityException",
"{",
"Cipher",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"\"Blowfish/ECB/PKCS5Padding\"",
")",
";",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"ENCRYPT_MODE",
",",
"... | Creates a cipher for encrypting data with the specified key.
@return A Blowfish/ECB/PKCS5Padding cipher in encryption mode.
@throws GeneralSecurityException | [
"Creates",
"a",
"cipher",
"for",
"encrypting",
"data",
"with",
"the",
"specified",
"key",
"."
] | 0b8aac407aa5289845f249024f9732332855544f | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/spectator/src/main/java/net/boreeas/riotapi/spectator/GameEncryptionData.java#L53-L58 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLDropClass.java | OCommandExecutorSQLDropClass.execute | public Object execute(final Map<Object, Object> iArgs) {
if (className == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final ODatabaseRecord database = getDatabase();
final OClass oClass = database.getMetadata().getSchema().getClass(className);
if (oClass == null)
return null;
for (final OIndex<?> oIndex : oClass.getClassIndexes()) {
database.getMetadata().getIndexManager().dropIndex(oIndex.getName());
}
final OClass superClass = oClass.getSuperClass();
final int[] clustersToIndex = oClass.getPolymorphicClusterIds();
final String[] clusterNames = new String[clustersToIndex.length];
for (int i = 0; i < clustersToIndex.length; i++) {
clusterNames[i] = database.getClusterNameById(clustersToIndex[i]);
}
final int clusterId = oClass.getDefaultClusterId();
((OSchemaProxy) database.getMetadata().getSchema()).dropClassInternal(className);
((OSchemaProxy) database.getMetadata().getSchema()).saveInternal();
database.getMetadata().getSchema().reload();
deleteDefaultCluster(clusterId);
if (superClass == null)
return true;
for (final OIndex<?> oIndex : superClass.getIndexes()) {
for (final String clusterName : clusterNames)
oIndex.getInternal().removeCluster(clusterName);
OLogManager.instance().info("Index %s is used in super class of %s and should be rebuilt.", oIndex.getName(), className);
oIndex.rebuild();
}
return true;
} | java | public Object execute(final Map<Object, Object> iArgs) {
if (className == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final ODatabaseRecord database = getDatabase();
final OClass oClass = database.getMetadata().getSchema().getClass(className);
if (oClass == null)
return null;
for (final OIndex<?> oIndex : oClass.getClassIndexes()) {
database.getMetadata().getIndexManager().dropIndex(oIndex.getName());
}
final OClass superClass = oClass.getSuperClass();
final int[] clustersToIndex = oClass.getPolymorphicClusterIds();
final String[] clusterNames = new String[clustersToIndex.length];
for (int i = 0; i < clustersToIndex.length; i++) {
clusterNames[i] = database.getClusterNameById(clustersToIndex[i]);
}
final int clusterId = oClass.getDefaultClusterId();
((OSchemaProxy) database.getMetadata().getSchema()).dropClassInternal(className);
((OSchemaProxy) database.getMetadata().getSchema()).saveInternal();
database.getMetadata().getSchema().reload();
deleteDefaultCluster(clusterId);
if (superClass == null)
return true;
for (final OIndex<?> oIndex : superClass.getIndexes()) {
for (final String clusterName : clusterNames)
oIndex.getInternal().removeCluster(clusterName);
OLogManager.instance().info("Index %s is used in super class of %s and should be rebuilt.", oIndex.getName(), className);
oIndex.rebuild();
}
return true;
} | [
"public",
"Object",
"execute",
"(",
"final",
"Map",
"<",
"Object",
",",
"Object",
">",
"iArgs",
")",
"{",
"if",
"(",
"className",
"==",
"null",
")",
"throw",
"new",
"OCommandExecutionException",
"(",
"\"Cannot execute the command because it has not been parsed yet\"",... | Execute the DROP CLASS. | [
"Execute",
"the",
"DROP",
"CLASS",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLDropClass.java#L77-L118 | train |
wuman/orientdb-android | commons/src/main/java/com/orientechnologies/common/collection/OCompositeKey.java | OCompositeKey.compareTo | public int compareTo(final OCompositeKey otherKey) {
final Iterator<Object> inIter = keys.iterator();
final Iterator<Object> outIter = otherKey.keys.iterator();
while (inIter.hasNext() && outIter.hasNext()) {
final Object inKey = inIter.next();
final Object outKey = outIter.next();
if (outKey instanceof OAlwaysGreaterKey)
return -1;
if (outKey instanceof OAlwaysLessKey)
return 1;
final int result = comparator.compare(inKey, outKey);
if (result != 0)
return result;
}
return 0;
} | java | public int compareTo(final OCompositeKey otherKey) {
final Iterator<Object> inIter = keys.iterator();
final Iterator<Object> outIter = otherKey.keys.iterator();
while (inIter.hasNext() && outIter.hasNext()) {
final Object inKey = inIter.next();
final Object outKey = outIter.next();
if (outKey instanceof OAlwaysGreaterKey)
return -1;
if (outKey instanceof OAlwaysLessKey)
return 1;
final int result = comparator.compare(inKey, outKey);
if (result != 0)
return result;
}
return 0;
} | [
"public",
"int",
"compareTo",
"(",
"final",
"OCompositeKey",
"otherKey",
")",
"{",
"final",
"Iterator",
"<",
"Object",
">",
"inIter",
"=",
"keys",
".",
"iterator",
"(",
")",
";",
"final",
"Iterator",
"<",
"Object",
">",
"outIter",
"=",
"otherKey",
".",
"... | Performs partial comparison of two composite keys.
Two objects will be equal if the common subset of their keys is equal. For example if first object contains two keys and second
contains four keys then only first two keys will be compared.
@param otherKey
Key to compare.
@return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified
object. | [
"Performs",
"partial",
"comparison",
"of",
"two",
"composite",
"keys",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/commons/src/main/java/com/orientechnologies/common/collection/OCompositeKey.java#L104-L124 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/command/OBasicCommandContext.java | OBasicCommandContext.getVariables | public Map<String, Object> getVariables() {
final HashMap<String, Object> map = new HashMap<String, Object>();
if (inherited != null)
map.putAll(inherited.getVariables());
if (variables != null)
map.putAll(variables);
return map;
} | java | public Map<String, Object> getVariables() {
final HashMap<String, Object> map = new HashMap<String, Object>();
if (inherited != null)
map.putAll(inherited.getVariables());
if (variables != null)
map.putAll(variables);
return map;
} | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"getVariables",
"(",
")",
"{",
"final",
"HashMap",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"if",
"(",
"inherited",
"!=",
... | Returns a read-only map with all the variables. | [
"Returns",
"a",
"read",
"-",
"only",
"map",
"with",
"all",
"the",
"variables",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/command/OBasicCommandContext.java#L46-L53 | train |
dmfs/jdav | src/org/dmfs/dav/rfc4918/PropStat.java | PropStat.getPropertyValue | @SuppressWarnings("unchecked")
public <T> T getPropertyValue(ElementDescriptor<T> property)
{
if (mProperties == null)
{
return null;
}
return (T) mProperties.get(property);
} | java | @SuppressWarnings("unchecked")
public <T> T getPropertyValue(ElementDescriptor<T> property)
{
if (mProperties == null)
{
return null;
}
return (T) mProperties.get(property);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"getPropertyValue",
"(",
"ElementDescriptor",
"<",
"T",
">",
"property",
")",
"{",
"if",
"(",
"mProperties",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"... | Returns the value of a property in this propstat element.
@param property
the {@link XmlElementDescriptor} of the property to return.
@return the value of the property or <code>null</code> if there is no property of this name. | [
"Returns",
"the",
"value",
"of",
"a",
"property",
"in",
"this",
"propstat",
"element",
"."
] | a619d85423210a283b3eb1fba9abda4fdc894969 | https://github.com/dmfs/jdav/blob/a619d85423210a283b3eb1fba9abda4fdc894969/src/org/dmfs/dav/rfc4918/PropStat.java#L185-L193 | train |
dmfs/jdav | src/org/dmfs/dav/rfc4791/MkCalendar.java | MkCalendar.clear | public <T> void clear(ElementDescriptor<T> property)
{
if (mSet != null)
{
mSet.remove(property);
}
} | java | public <T> void clear(ElementDescriptor<T> property)
{
if (mSet != null)
{
mSet.remove(property);
}
} | [
"public",
"<",
"T",
">",
"void",
"clear",
"(",
"ElementDescriptor",
"<",
"T",
">",
"property",
")",
"{",
"if",
"(",
"mSet",
"!=",
"null",
")",
"{",
"mSet",
".",
"remove",
"(",
"property",
")",
";",
"}",
"}"
] | Remove a property from the initial values.
@param property
The {@link ElementDescriptor} of the property. | [
"Remove",
"a",
"property",
"from",
"the",
"initial",
"values",
"."
] | a619d85423210a283b3eb1fba9abda4fdc894969 | https://github.com/dmfs/jdav/blob/a619d85423210a283b3eb1fba9abda4fdc894969/src/org/dmfs/dav/rfc4791/MkCalendar.java#L146-L152 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.java | ODatabaseDocumentTx.countClass | public long countClass(final String iClassName) {
final OClass cls = getMetadata().getSchema().getClass(iClassName);
if (cls == null)
throw new IllegalArgumentException("Class '" + iClassName + "' not found in database");
return cls.count();
} | java | public long countClass(final String iClassName) {
final OClass cls = getMetadata().getSchema().getClass(iClassName);
if (cls == null)
throw new IllegalArgumentException("Class '" + iClassName + "' not found in database");
return cls.count();
} | [
"public",
"long",
"countClass",
"(",
"final",
"String",
"iClassName",
")",
"{",
"final",
"OClass",
"cls",
"=",
"getMetadata",
"(",
")",
".",
"getSchema",
"(",
")",
".",
"getClass",
"(",
"iClassName",
")",
";",
"if",
"(",
"cls",
"==",
"null",
")",
"thro... | Returns the number of the records of the class iClassName. | [
"Returns",
"the",
"number",
"of",
"the",
"records",
"of",
"the",
"class",
"iClassName",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.java#L417-L424 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/binary/OBinarySerializerFactory.java | OBinarySerializerFactory.getObjectSerializer | public OBinarySerializer<?> getObjectSerializer(final byte identifier) {
OBinarySerializer<?> impl = serializerIdMap.get(identifier);
if (impl == null) {
final Class<? extends OBinarySerializer<?>> cls = serializerClassesIdMap.get(identifier);
if (cls != null)
try {
impl = cls.newInstance();
} catch (Exception e) {
OLogManager.instance().error(this, "Cannot create an instance of class %s invoking the empty constructor", cls);
}
}
return impl;
} | java | public OBinarySerializer<?> getObjectSerializer(final byte identifier) {
OBinarySerializer<?> impl = serializerIdMap.get(identifier);
if (impl == null) {
final Class<? extends OBinarySerializer<?>> cls = serializerClassesIdMap.get(identifier);
if (cls != null)
try {
impl = cls.newInstance();
} catch (Exception e) {
OLogManager.instance().error(this, "Cannot create an instance of class %s invoking the empty constructor", cls);
}
}
return impl;
} | [
"public",
"OBinarySerializer",
"<",
"?",
">",
"getObjectSerializer",
"(",
"final",
"byte",
"identifier",
")",
"{",
"OBinarySerializer",
"<",
"?",
">",
"impl",
"=",
"serializerIdMap",
".",
"get",
"(",
"identifier",
")",
";",
"if",
"(",
"impl",
"==",
"null",
... | Obtain OBinarySerializer instance by it's id.
@param identifier
is serializes identifier.
@return OBinarySerializer instance. | [
"Obtain",
"OBinarySerializer",
"instance",
"by",
"it",
"s",
"id",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/binary/OBinarySerializerFactory.java#L108-L120 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java | ODataLocal.addRecord | public long addRecord(final ORecordId iRid, final byte[] iContent) throws IOException {
if (iContent.length == 0)
// AVOID UNUSEFUL CREATION OF EMPTY RECORD: IT WILL BE CREATED AT FIRST UPDATE
return -1;
final int recordSize = iContent.length + RECORD_FIX_SIZE;
acquireExclusiveLock();
try {
final long[] newFilePosition = getFreeSpace(recordSize);
writeRecord(newFilePosition, iRid.clusterId, iRid.clusterPosition, iContent);
return getAbsolutePosition(newFilePosition);
} finally {
releaseExclusiveLock();
}
} | java | public long addRecord(final ORecordId iRid, final byte[] iContent) throws IOException {
if (iContent.length == 0)
// AVOID UNUSEFUL CREATION OF EMPTY RECORD: IT WILL BE CREATED AT FIRST UPDATE
return -1;
final int recordSize = iContent.length + RECORD_FIX_SIZE;
acquireExclusiveLock();
try {
final long[] newFilePosition = getFreeSpace(recordSize);
writeRecord(newFilePosition, iRid.clusterId, iRid.clusterPosition, iContent);
return getAbsolutePosition(newFilePosition);
} finally {
releaseExclusiveLock();
}
} | [
"public",
"long",
"addRecord",
"(",
"final",
"ORecordId",
"iRid",
",",
"final",
"byte",
"[",
"]",
"iContent",
")",
"throws",
"IOException",
"{",
"if",
"(",
"iContent",
".",
"length",
"==",
"0",
")",
"// AVOID UNUSEFUL CREATION OF EMPTY RECORD: IT WILL BE CREATED AT ... | Add the record content in file.
@param iContent
The content to write
@return The record offset.
@throws IOException | [
"Add",
"the",
"record",
"content",
"in",
"file",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java#L187-L205 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java | ODataLocal.getRecord | public byte[] getRecord(final long iPosition) throws IOException {
if (iPosition == -1)
return null;
acquireSharedLock();
try {
final long[] pos = getRelativePosition(iPosition);
final OFile file = files[(int) pos[0]];
final int recordSize = file.readInt(pos[1]);
if (recordSize <= 0)
// RECORD DELETED
return null;
if (pos[1] + RECORD_FIX_SIZE + recordSize > file.getFilledUpTo())
throw new OStorageException(
"Error on reading record from file '"
+ file.getName()
+ "', position "
+ iPosition
+ ", size "
+ OFileUtils.getSizeAsString(recordSize)
+ ": the record size is bigger then the file itself ("
+ OFileUtils.getSizeAsString(getFilledUpTo())
+ "). Probably the record is dirty due to a previous crash. It is strongly suggested to restore the database or export and reimport this one.");
final byte[] content = new byte[recordSize];
file.read(pos[1] + RECORD_FIX_SIZE, content, recordSize);
return content;
} finally {
releaseSharedLock();
}
} | java | public byte[] getRecord(final long iPosition) throws IOException {
if (iPosition == -1)
return null;
acquireSharedLock();
try {
final long[] pos = getRelativePosition(iPosition);
final OFile file = files[(int) pos[0]];
final int recordSize = file.readInt(pos[1]);
if (recordSize <= 0)
// RECORD DELETED
return null;
if (pos[1] + RECORD_FIX_SIZE + recordSize > file.getFilledUpTo())
throw new OStorageException(
"Error on reading record from file '"
+ file.getName()
+ "', position "
+ iPosition
+ ", size "
+ OFileUtils.getSizeAsString(recordSize)
+ ": the record size is bigger then the file itself ("
+ OFileUtils.getSizeAsString(getFilledUpTo())
+ "). Probably the record is dirty due to a previous crash. It is strongly suggested to restore the database or export and reimport this one.");
final byte[] content = new byte[recordSize];
file.read(pos[1] + RECORD_FIX_SIZE, content, recordSize);
return content;
} finally {
releaseSharedLock();
}
} | [
"public",
"byte",
"[",
"]",
"getRecord",
"(",
"final",
"long",
"iPosition",
")",
"throws",
"IOException",
"{",
"if",
"(",
"iPosition",
"==",
"-",
"1",
")",
"return",
"null",
";",
"acquireSharedLock",
"(",
")",
";",
"try",
"{",
"final",
"long",
"[",
"]"... | Returns the record content from file.
@throws IOException | [
"Returns",
"the",
"record",
"content",
"from",
"file",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java#L212-L246 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java | ODataLocal.getRecordSize | public int getRecordSize(final long iPosition) throws IOException {
acquireSharedLock();
try {
final long[] pos = getRelativePosition(iPosition);
final OFile file = files[(int) pos[0]];
return file.readInt(pos[1]);
} finally {
releaseSharedLock();
}
} | java | public int getRecordSize(final long iPosition) throws IOException {
acquireSharedLock();
try {
final long[] pos = getRelativePosition(iPosition);
final OFile file = files[(int) pos[0]];
return file.readInt(pos[1]);
} finally {
releaseSharedLock();
}
} | [
"public",
"int",
"getRecordSize",
"(",
"final",
"long",
"iPosition",
")",
"throws",
"IOException",
"{",
"acquireSharedLock",
"(",
")",
";",
"try",
"{",
"final",
"long",
"[",
"]",
"pos",
"=",
"getRelativePosition",
"(",
"iPosition",
")",
";",
"final",
"OFile"... | Returns the record size.
@throws IOException | [
"Returns",
"the",
"record",
"size",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java#L253-L265 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java | ODataLocal.setRecord | public long setRecord(final long iPosition, final ORecordId iRid, final byte[] iContent) throws IOException {
acquireExclusiveLock();
try {
long[] pos = getRelativePosition(iPosition);
final OFile file = files[(int) pos[0]];
final int recordSize = file.readInt(pos[1]);
final int contentLength = iContent != null ? iContent.length : 0;
if (contentLength == recordSize) {
// USE THE OLD SPACE SINCE SIZE ISN'T CHANGED
file.write(pos[1] + RECORD_FIX_SIZE, iContent);
OProfiler.getInstance().updateCounter(PROFILER_UPDATE_REUSED_ALL, +1);
return iPosition;
} else if (recordSize - contentLength > RECORD_FIX_SIZE + 50) {
// USE THE OLD SPACE BUT UPDATE THE CURRENT SIZE. IT'S PREFEREABLE TO USE THE SAME INSTEAD FINDING A BEST SUITED FOR IT TO
// AVOID CHANGES TO REF FILE AS WELL.
writeRecord(pos, iRid.clusterId, iRid.clusterPosition, iContent);
// CREATE A HOLE WITH THE DIFFERENCE OF SPACE
handleHole(iPosition + RECORD_FIX_SIZE + contentLength, recordSize - contentLength - RECORD_FIX_SIZE);
OProfiler.getInstance().updateCounter(PROFILER_UPDATE_REUSED_PARTIAL, +1);
} else {
// CREATE A HOLE FOR THE ENTIRE OLD RECORD
handleHole(iPosition, recordSize);
// USE A NEW SPACE
pos = getFreeSpace(contentLength + RECORD_FIX_SIZE);
writeRecord(pos, iRid.clusterId, iRid.clusterPosition, iContent);
OProfiler.getInstance().updateCounter(PROFILER_UPDATE_NOT_REUSED, +1);
}
return getAbsolutePosition(pos);
} finally {
releaseExclusiveLock();
}
} | java | public long setRecord(final long iPosition, final ORecordId iRid, final byte[] iContent) throws IOException {
acquireExclusiveLock();
try {
long[] pos = getRelativePosition(iPosition);
final OFile file = files[(int) pos[0]];
final int recordSize = file.readInt(pos[1]);
final int contentLength = iContent != null ? iContent.length : 0;
if (contentLength == recordSize) {
// USE THE OLD SPACE SINCE SIZE ISN'T CHANGED
file.write(pos[1] + RECORD_FIX_SIZE, iContent);
OProfiler.getInstance().updateCounter(PROFILER_UPDATE_REUSED_ALL, +1);
return iPosition;
} else if (recordSize - contentLength > RECORD_FIX_SIZE + 50) {
// USE THE OLD SPACE BUT UPDATE THE CURRENT SIZE. IT'S PREFEREABLE TO USE THE SAME INSTEAD FINDING A BEST SUITED FOR IT TO
// AVOID CHANGES TO REF FILE AS WELL.
writeRecord(pos, iRid.clusterId, iRid.clusterPosition, iContent);
// CREATE A HOLE WITH THE DIFFERENCE OF SPACE
handleHole(iPosition + RECORD_FIX_SIZE + contentLength, recordSize - contentLength - RECORD_FIX_SIZE);
OProfiler.getInstance().updateCounter(PROFILER_UPDATE_REUSED_PARTIAL, +1);
} else {
// CREATE A HOLE FOR THE ENTIRE OLD RECORD
handleHole(iPosition, recordSize);
// USE A NEW SPACE
pos = getFreeSpace(contentLength + RECORD_FIX_SIZE);
writeRecord(pos, iRid.clusterId, iRid.clusterPosition, iContent);
OProfiler.getInstance().updateCounter(PROFILER_UPDATE_NOT_REUSED, +1);
}
return getAbsolutePosition(pos);
} finally {
releaseExclusiveLock();
}
} | [
"public",
"long",
"setRecord",
"(",
"final",
"long",
"iPosition",
",",
"final",
"ORecordId",
"iRid",
",",
"final",
"byte",
"[",
"]",
"iContent",
")",
"throws",
"IOException",
"{",
"acquireExclusiveLock",
"(",
")",
";",
"try",
"{",
"long",
"[",
"]",
"pos",
... | Set the record content in file.
@param iPosition
The previous record's offset
@param iContent
The content to write
@return The new record offset or the same received as parameter is the old space was reused.
@throws IOException | [
"Set",
"the",
"record",
"content",
"in",
"file",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java#L292-L333 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java | ODataLocal.getHolesList | public List<ODataHoleInfo> getHolesList() {
acquireSharedLock();
try {
final List<ODataHoleInfo> holes = new ArrayList<ODataHoleInfo>();
final int tot = holeSegment.getHoles();
for (int i = 0; i < tot; ++i) {
final ODataHoleInfo h = holeSegment.getHole(i);
if (h != null)
holes.add(h);
}
return holes;
} finally {
releaseSharedLock();
}
} | java | public List<ODataHoleInfo> getHolesList() {
acquireSharedLock();
try {
final List<ODataHoleInfo> holes = new ArrayList<ODataHoleInfo>();
final int tot = holeSegment.getHoles();
for (int i = 0; i < tot; ++i) {
final ODataHoleInfo h = holeSegment.getHole(i);
if (h != null)
holes.add(h);
}
return holes;
} finally {
releaseSharedLock();
}
} | [
"public",
"List",
"<",
"ODataHoleInfo",
">",
"getHolesList",
"(",
")",
"{",
"acquireSharedLock",
"(",
")",
";",
"try",
"{",
"final",
"List",
"<",
"ODataHoleInfo",
">",
"holes",
"=",
"new",
"ArrayList",
"<",
"ODataHoleInfo",
">",
"(",
")",
";",
"final",
"... | Returns the list of holes as pair of position & ppos
@throws IOException | [
"Returns",
"the",
"list",
"of",
"holes",
"as",
"pair",
"of",
"position",
"&",
"ppos"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocal.java#L375-L393 | train |
amsa-code/risky | geo-analyzer/src/main/java/au/gov/amsa/geo/model/Bounds.java | Bounds.betweenLongitudes | private static boolean betweenLongitudes(double topLeftLon, double bottomRightLon, double lon) {
if (topLeftLon <= bottomRightLon)
return lon >= topLeftLon && lon <= bottomRightLon;
else
return lon >= topLeftLon || lon <= bottomRightLon;
} | java | private static boolean betweenLongitudes(double topLeftLon, double bottomRightLon, double lon) {
if (topLeftLon <= bottomRightLon)
return lon >= topLeftLon && lon <= bottomRightLon;
else
return lon >= topLeftLon || lon <= bottomRightLon;
} | [
"private",
"static",
"boolean",
"betweenLongitudes",
"(",
"double",
"topLeftLon",
",",
"double",
"bottomRightLon",
",",
"double",
"lon",
")",
"{",
"if",
"(",
"topLeftLon",
"<=",
"bottomRightLon",
")",
"return",
"lon",
">=",
"topLeftLon",
"&&",
"lon",
"<=",
"bo... | Returns true if and only if lon is between the longitudes topLeftLon and
bottomRightLon.
@param topLeftLon
must be between -180 and 180
@param bottomRightLon
must be between -180 and 180
@param lon
must be between -180 and 180
@return | [
"Returns",
"true",
"if",
"and",
"only",
"if",
"lon",
"is",
"between",
"the",
"longitudes",
"topLeftLon",
"and",
"bottomRightLon",
"."
] | 13649942aeddfdb9210eec072c605bc5d7a6daf3 | https://github.com/amsa-code/risky/blob/13649942aeddfdb9210eec072c605bc5d7a6daf3/geo-analyzer/src/main/java/au/gov/amsa/geo/model/Bounds.java#L68-L73 | train |
dmfs/jdav | src/org/dmfs/dav/rfc4918/Response.java | Response.getPropertyStatus | public int getPropertyStatus(ElementDescriptor<?> descriptor)
{
PropStat propStat = mPropStatByProperty.get(descriptor);
if (propStat == null)
{
return STATUS_NONE;
}
return propStat.getStatusCode();
} | java | public int getPropertyStatus(ElementDescriptor<?> descriptor)
{
PropStat propStat = mPropStatByProperty.get(descriptor);
if (propStat == null)
{
return STATUS_NONE;
}
return propStat.getStatusCode();
} | [
"public",
"int",
"getPropertyStatus",
"(",
"ElementDescriptor",
"<",
"?",
">",
"descriptor",
")",
"{",
"PropStat",
"propStat",
"=",
"mPropStatByProperty",
".",
"get",
"(",
"descriptor",
")",
";",
"if",
"(",
"propStat",
"==",
"null",
")",
"{",
"return",
"STAT... | Return the status of a specific property.
@param descriptor
The {@link XmlElementDescriptor} of the property.
@return The status of the property or {@link #STATUS_NONE} if the property was not found. | [
"Return",
"the",
"status",
"of",
"a",
"specific",
"property",
"."
] | a619d85423210a283b3eb1fba9abda4fdc894969 | https://github.com/dmfs/jdav/blob/a619d85423210a283b3eb1fba9abda4fdc894969/src/org/dmfs/dav/rfc4918/Response.java#L335-L344 | train |
dmfs/jdav | src/org/dmfs/dav/rfc4918/Response.java | Response.getPropertyValue | public <T> T getPropertyValue(ElementDescriptor<T> descriptor)
{
PropStat propStat = mPropStatByProperty.get(descriptor);
if (propStat == null)
{
return null;
}
return propStat.getPropertyValue(descriptor);
} | java | public <T> T getPropertyValue(ElementDescriptor<T> descriptor)
{
PropStat propStat = mPropStatByProperty.get(descriptor);
if (propStat == null)
{
return null;
}
return propStat.getPropertyValue(descriptor);
} | [
"public",
"<",
"T",
">",
"T",
"getPropertyValue",
"(",
"ElementDescriptor",
"<",
"T",
">",
"descriptor",
")",
"{",
"PropStat",
"propStat",
"=",
"mPropStatByProperty",
".",
"get",
"(",
"descriptor",
")",
";",
"if",
"(",
"propStat",
"==",
"null",
")",
"{",
... | Get the value of a specific property.
@param descriptor
The {@link XmlElementDescriptor} of the property to return.
@return The property value, may be <code>null</code> if the property was not present or didn't contain any value (because it had a non-
{@link HttpStatus#OK} status). | [
"Get",
"the",
"value",
"of",
"a",
"specific",
"property",
"."
] | a619d85423210a283b3eb1fba9abda4fdc894969 | https://github.com/dmfs/jdav/blob/a619d85423210a283b3eb1fba9abda4fdc894969/src/org/dmfs/dav/rfc4918/Response.java#L355-L364 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/index/OIndexes.java | OIndexes.getFactories | private static synchronized Set<OIndexFactory> getFactories() {
if (FACTORIES == null) {
final Iterator<OIndexFactory> ite = lookupProviderWithOrientClassLoader(OIndexFactory.class,orientClassLoader);
final Set<OIndexFactory> factories = new HashSet<OIndexFactory>();
while (ite.hasNext()) {
factories.add(ite.next());
}
FACTORIES = Collections.unmodifiableSet(factories);
}
return FACTORIES;
} | java | private static synchronized Set<OIndexFactory> getFactories() {
if (FACTORIES == null) {
final Iterator<OIndexFactory> ite = lookupProviderWithOrientClassLoader(OIndexFactory.class,orientClassLoader);
final Set<OIndexFactory> factories = new HashSet<OIndexFactory>();
while (ite.hasNext()) {
factories.add(ite.next());
}
FACTORIES = Collections.unmodifiableSet(factories);
}
return FACTORIES;
} | [
"private",
"static",
"synchronized",
"Set",
"<",
"OIndexFactory",
">",
"getFactories",
"(",
")",
"{",
"if",
"(",
"FACTORIES",
"==",
"null",
")",
"{",
"final",
"Iterator",
"<",
"OIndexFactory",
">",
"ite",
"=",
"lookupProviderWithOrientClassLoader",
"(",
"OIndexF... | Cache a set of all factories. we do not use the service loader directly
since it is not concurrent.
@return Set<OIndexFactory> | [
"Cache",
"a",
"set",
"of",
"all",
"factories",
".",
"we",
"do",
"not",
"use",
"the",
"service",
"loader",
"directly",
"since",
"it",
"is",
"not",
"concurrent",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/index/OIndexes.java#L69-L81 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/record/ORecordAbstract.java | ORecordAbstract.addListener | public void addListener(final ORecordListener iListener) {
if (_listeners == null)
_listeners = Collections.newSetFromMap(new WeakHashMap<ORecordListener, Boolean>());
_listeners.add(iListener);
} | java | public void addListener(final ORecordListener iListener) {
if (_listeners == null)
_listeners = Collections.newSetFromMap(new WeakHashMap<ORecordListener, Boolean>());
_listeners.add(iListener);
} | [
"public",
"void",
"addListener",
"(",
"final",
"ORecordListener",
"iListener",
")",
"{",
"if",
"(",
"_listeners",
"==",
"null",
")",
"_listeners",
"=",
"Collections",
".",
"newSetFromMap",
"(",
"new",
"WeakHashMap",
"<",
"ORecordListener",
",",
"Boolean",
">",
... | Add a listener to the current document to catch all the supported events.
@see ORecordListener
@param iListener
ODocumentListener implementation | [
"Add",
"a",
"listener",
"to",
"the",
"current",
"document",
"to",
"catch",
"all",
"the",
"supported",
"events",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/record/ORecordAbstract.java#L357-L362 | train |
soi-toolkit/soi-toolkit-mule | tools/soitoolkit-generator/soitoolkit-generator-eclipse-plugin/soitoolkit-generator-plugin/src/org/soitoolkit/tools/generator/plugin/createcomponent/CreateComponentUtil.java | CreateComponentUtil.getComponentProjectName | public static String getComponentProjectName(int componentType, String groupId, String artifactId) {
IModel m = ModelFactory.newModel(groupId, artifactId, null, null, MuleVersionEnum.MAIN_MULE_VERSION, null, null);
String projectFolderName = null;
ComponentEnum compEnum = ComponentEnum.get(componentType);
switch (compEnum) {
case INTEGRATION_COMPONENT:
projectFolderName = m.getIntegrationComponentProject();
break;
case INTEGRATION_TESTSTUBS_COMPONENT:
projectFolderName = m.getTeststubStandaloneProject();
break;
case SD_SCHEMA_COMPONENT:
projectFolderName = m.getSchemaProject();
break;
}
return projectFolderName;
} | java | public static String getComponentProjectName(int componentType, String groupId, String artifactId) {
IModel m = ModelFactory.newModel(groupId, artifactId, null, null, MuleVersionEnum.MAIN_MULE_VERSION, null, null);
String projectFolderName = null;
ComponentEnum compEnum = ComponentEnum.get(componentType);
switch (compEnum) {
case INTEGRATION_COMPONENT:
projectFolderName = m.getIntegrationComponentProject();
break;
case INTEGRATION_TESTSTUBS_COMPONENT:
projectFolderName = m.getTeststubStandaloneProject();
break;
case SD_SCHEMA_COMPONENT:
projectFolderName = m.getSchemaProject();
break;
}
return projectFolderName;
} | [
"public",
"static",
"String",
"getComponentProjectName",
"(",
"int",
"componentType",
",",
"String",
"groupId",
",",
"String",
"artifactId",
")",
"{",
"IModel",
"m",
"=",
"ModelFactory",
".",
"newModel",
"(",
"groupId",
",",
"artifactId",
",",
"null",
",",
"nu... | public static final int IM_SCHEMA_COMPONENT = 3; | [
"public",
"static",
"final",
"int",
"IM_SCHEMA_COMPONENT",
"=",
"3",
";"
] | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/tools/soitoolkit-generator/soitoolkit-generator-eclipse-plugin/soitoolkit-generator-plugin/src/org/soitoolkit/tools/generator/plugin/createcomponent/CreateComponentUtil.java#L31-L47 | train |
lightblue-platform/lightblue-migrator | facade/src/main/java/com/redhat/lightblue/migrator/facade/ConsistencyChecker.java | ConsistencyChecker.checkConsistency | protected boolean checkConsistency(Object o1, Object o2) {
return checkConsistency(o1, o2, null, null);
} | java | protected boolean checkConsistency(Object o1, Object o2) {
return checkConsistency(o1, o2, null, null);
} | [
"protected",
"boolean",
"checkConsistency",
"(",
"Object",
"o1",
",",
"Object",
"o2",
")",
"{",
"return",
"checkConsistency",
"(",
"o1",
",",
"o2",
",",
"null",
",",
"null",
")",
";",
"}"
] | convenience method for unit testing | [
"convenience",
"method",
"for",
"unit",
"testing"
] | ec20748557b40d1f7851e1816d1b76dae48d2027 | https://github.com/lightblue-platform/lightblue-migrator/blob/ec20748557b40d1f7851e1816d1b76dae48d2027/facade/src/main/java/com/redhat/lightblue/migrator/facade/ConsistencyChecker.java#L189-L191 | train |
lightblue-platform/lightblue-migrator | facade/src/main/java/com/redhat/lightblue/migrator/facade/ConsistencyChecker.java | ConsistencyChecker.checkConsistency | public boolean checkConsistency(final Object legacyEntity, final Object lightblueEntity, final String methodName, MethodCallStringifier callToLogInCaseOfInconsistency) {
if (legacyEntity == null && lightblueEntity == null) {
return true;
}
if (callToLogInCaseOfInconsistency == null) {
callToLogInCaseOfInconsistency = new LazyMethodCallStringifier();
}
try {
Timer p2j = new Timer("ConsistencyChecker's pojo2json conversion");
final JsonNode legacyJson = objectMapper.valueToTree(legacyEntity);
final JsonNode lightblueJson = objectMapper.valueToTree(lightblueEntity);
p2j.complete();
try {
Timer t = new Timer("checkConsistency (jiff)");
List<JsonDelta> deltas = jiff.computeDiff(legacyJson, lightblueJson);
boolean consistent = deltas.isEmpty();
long jiffConsistencyCheckTook = t.complete();
if (inconsistencyLog.isDebugEnabled()) {
inconsistencyLog.debug("Jiff consistency check took: " + jiffConsistencyCheckTook + " ms");
inconsistencyLog.debug("Jiff consistency check passed: true");
}
if (consistent) {
return true;
}
// TODO: this can be memory intensive too, but how else to check the size of responses?
String legacyJsonStr = objectMapper.writeValueAsString(legacyEntity);
String lightblueJsonStr = objectMapper.writeValueAsString(lightblueEntity);
// JSONCompare fails when comparing booleans, convert them to strings
if ("true".equals(legacyJsonStr) || "false".equals(legacyJsonStr)) {
legacyJsonStr = "\"" + legacyJsonStr + "\"";
}
if ("true".equals(lightblueJsonStr) || "false".equals(lightblueJsonStr)) {
lightblueJsonStr = "\"" + lightblueJsonStr + "\"";
}
if ("null".equals(legacyJsonStr) || "null".equals(lightblueJsonStr)) {
logInconsistency(Thread.currentThread().getName(), callToLogInCaseOfInconsistency.toString(), legacyJsonStr, lightblueJsonStr, "One object is null and the other isn't");
} else {
if (legacyJsonStr.length() >= maxJsonStrLengthForJsonCompare || lightblueJsonStr.length() >= maxJsonStrLengthForJsonCompare) {
inconsistencyLog.debug("Using jiff to produce inconsistency warning");
// it is not very detailed (will show only first inconsistency; will tell you which array element is inconsistent, but not how), but it's easy on resources
logInconsistencyUsingJiff(Thread.currentThread().getName(), legacyJsonStr, lightblueJsonStr, deltas, callToLogInCaseOfInconsistency, Boolean.valueOf(System.getProperty("lightblue.facade.consistencyChecker.blocking", "false")));
} else {
inconsistencyLog.debug("Using org.skyscreamer.jsonassert.JSONCompare to produce inconsistency warning");
// it's slow and can consume lots of memory, but produces nice diffs
logInconsistencyUsingJSONCompare(Thread.currentThread().getName(), legacyJsonStr, lightblueJsonStr, callToLogInCaseOfInconsistency, Boolean.valueOf(System.getProperty("lightblue.facade.consistencyChecker.blocking", "false")));
}
}
// inconsistent
return false;
} catch (IOException e) {
inconsistencyLog.error("Consistency check failed in " + implementationName + "." + callToLogInCaseOfInconsistency + "! Invalid JSON: legacyJson=" + legacyJson + ", lightblueJson=" + lightblueJson, e);
}
} catch (Exception e) {
inconsistencyLog.error("Consistency check failed in " + implementationName + "." + callToLogInCaseOfInconsistency + "! legacyEntity=" + legacyEntity + ", lightblueEntity=" + lightblueEntity, e);
}
return false;
} | java | public boolean checkConsistency(final Object legacyEntity, final Object lightblueEntity, final String methodName, MethodCallStringifier callToLogInCaseOfInconsistency) {
if (legacyEntity == null && lightblueEntity == null) {
return true;
}
if (callToLogInCaseOfInconsistency == null) {
callToLogInCaseOfInconsistency = new LazyMethodCallStringifier();
}
try {
Timer p2j = new Timer("ConsistencyChecker's pojo2json conversion");
final JsonNode legacyJson = objectMapper.valueToTree(legacyEntity);
final JsonNode lightblueJson = objectMapper.valueToTree(lightblueEntity);
p2j.complete();
try {
Timer t = new Timer("checkConsistency (jiff)");
List<JsonDelta> deltas = jiff.computeDiff(legacyJson, lightblueJson);
boolean consistent = deltas.isEmpty();
long jiffConsistencyCheckTook = t.complete();
if (inconsistencyLog.isDebugEnabled()) {
inconsistencyLog.debug("Jiff consistency check took: " + jiffConsistencyCheckTook + " ms");
inconsistencyLog.debug("Jiff consistency check passed: true");
}
if (consistent) {
return true;
}
// TODO: this can be memory intensive too, but how else to check the size of responses?
String legacyJsonStr = objectMapper.writeValueAsString(legacyEntity);
String lightblueJsonStr = objectMapper.writeValueAsString(lightblueEntity);
// JSONCompare fails when comparing booleans, convert them to strings
if ("true".equals(legacyJsonStr) || "false".equals(legacyJsonStr)) {
legacyJsonStr = "\"" + legacyJsonStr + "\"";
}
if ("true".equals(lightblueJsonStr) || "false".equals(lightblueJsonStr)) {
lightblueJsonStr = "\"" + lightblueJsonStr + "\"";
}
if ("null".equals(legacyJsonStr) || "null".equals(lightblueJsonStr)) {
logInconsistency(Thread.currentThread().getName(), callToLogInCaseOfInconsistency.toString(), legacyJsonStr, lightblueJsonStr, "One object is null and the other isn't");
} else {
if (legacyJsonStr.length() >= maxJsonStrLengthForJsonCompare || lightblueJsonStr.length() >= maxJsonStrLengthForJsonCompare) {
inconsistencyLog.debug("Using jiff to produce inconsistency warning");
// it is not very detailed (will show only first inconsistency; will tell you which array element is inconsistent, but not how), but it's easy on resources
logInconsistencyUsingJiff(Thread.currentThread().getName(), legacyJsonStr, lightblueJsonStr, deltas, callToLogInCaseOfInconsistency, Boolean.valueOf(System.getProperty("lightblue.facade.consistencyChecker.blocking", "false")));
} else {
inconsistencyLog.debug("Using org.skyscreamer.jsonassert.JSONCompare to produce inconsistency warning");
// it's slow and can consume lots of memory, but produces nice diffs
logInconsistencyUsingJSONCompare(Thread.currentThread().getName(), legacyJsonStr, lightblueJsonStr, callToLogInCaseOfInconsistency, Boolean.valueOf(System.getProperty("lightblue.facade.consistencyChecker.blocking", "false")));
}
}
// inconsistent
return false;
} catch (IOException e) {
inconsistencyLog.error("Consistency check failed in " + implementationName + "." + callToLogInCaseOfInconsistency + "! Invalid JSON: legacyJson=" + legacyJson + ", lightblueJson=" + lightblueJson, e);
}
} catch (Exception e) {
inconsistencyLog.error("Consistency check failed in " + implementationName + "." + callToLogInCaseOfInconsistency + "! legacyEntity=" + legacyEntity + ", lightblueEntity=" + lightblueEntity, e);
}
return false;
} | [
"public",
"boolean",
"checkConsistency",
"(",
"final",
"Object",
"legacyEntity",
",",
"final",
"Object",
"lightblueEntity",
",",
"final",
"String",
"methodName",
",",
"MethodCallStringifier",
"callToLogInCaseOfInconsistency",
")",
"{",
"if",
"(",
"legacyEntity",
"==",
... | Check that objects are equal using org.skyscreamer.jsonassert library.
@param legacyEntity object returned from legacy call
@param lightblueEntity object returned from lightblue call
@param methodName the method name
@param callToLogInCaseOfInconsistency the call including parameters
@return | [
"Check",
"that",
"objects",
"are",
"equal",
"using",
"org",
".",
"skyscreamer",
".",
"jsonassert",
"library",
"."
] | ec20748557b40d1f7851e1816d1b76dae48d2027 | https://github.com/lightblue-platform/lightblue-migrator/blob/ec20748557b40d1f7851e1816d1b76dae48d2027/facade/src/main/java/com/redhat/lightblue/migrator/facade/ConsistencyChecker.java#L202-L271 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLInsert.java | OCommandExecutorSQLInsert.execute | public Object execute(final Map<Object, Object> iArgs) {
if (newRecords == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final OCommandParameters commandParameters = new OCommandParameters(iArgs);
if (indexName != null) {
final OIndex<?> index = getDatabase().getMetadata().getIndexManager().getIndex(indexName);
if (index == null)
throw new OCommandExecutionException("Target index '" + indexName + "' not found");
// BIND VALUES
Map<String, Object> result = null;
for (Map<String, Object> candidate : newRecords) {
index.put(getIndexKeyValue(commandParameters, candidate), getIndexValue(commandParameters, candidate));
result = candidate;
}
// RETURN LAST ENTRY
return new ODocument(result);
} else {
// CREATE NEW DOCUMENTS
final List<ODocument> docs = new ArrayList<ODocument>();
for (Map<String, Object> candidate : newRecords) {
final ODocument doc = className != null ? new ODocument(className) : new ODocument();
OSQLHelper.bindParameters(doc, candidate, commandParameters);
if (clusterName != null) {
doc.save(clusterName);
} else {
doc.save();
}
docs.add(doc);
}
if (docs.size() == 1) {
return docs.get(0);
} else {
return docs;
}
}
} | java | public Object execute(final Map<Object, Object> iArgs) {
if (newRecords == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final OCommandParameters commandParameters = new OCommandParameters(iArgs);
if (indexName != null) {
final OIndex<?> index = getDatabase().getMetadata().getIndexManager().getIndex(indexName);
if (index == null)
throw new OCommandExecutionException("Target index '" + indexName + "' not found");
// BIND VALUES
Map<String, Object> result = null;
for (Map<String, Object> candidate : newRecords) {
index.put(getIndexKeyValue(commandParameters, candidate), getIndexValue(commandParameters, candidate));
result = candidate;
}
// RETURN LAST ENTRY
return new ODocument(result);
} else {
// CREATE NEW DOCUMENTS
final List<ODocument> docs = new ArrayList<ODocument>();
for (Map<String, Object> candidate : newRecords) {
final ODocument doc = className != null ? new ODocument(className) : new ODocument();
OSQLHelper.bindParameters(doc, candidate, commandParameters);
if (clusterName != null) {
doc.save(clusterName);
} else {
doc.save();
}
docs.add(doc);
}
if (docs.size() == 1) {
return docs.get(0);
} else {
return docs;
}
}
} | [
"public",
"Object",
"execute",
"(",
"final",
"Map",
"<",
"Object",
",",
"Object",
">",
"iArgs",
")",
"{",
"if",
"(",
"newRecords",
"==",
"null",
")",
"throw",
"new",
"OCommandExecutionException",
"(",
"\"Cannot execute the command because it has not been parsed yet\""... | Execute the INSERT and return the ODocument object created. | [
"Execute",
"the",
"INSERT",
"and",
"return",
"the",
"ODocument",
"object",
"created",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLInsert.java#L176-L218 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java | OGraphVertex.link | @SuppressWarnings("unchecked")
public OGraphEdge link(final OGraphVertex iTargetVertex, final String iClassName) {
if (iTargetVertex == null)
throw new IllegalArgumentException("Missed the target vertex");
// CREATE THE EDGE BETWEEN ME AND THE TARGET
final OGraphEdge edge = new OGraphEdge(database, iClassName, this, iTargetVertex);
getOutEdges().add(edge);
Set<ODocument> recordEdges = ((Set<ODocument>) document.field(OGraphDatabase.VERTEX_FIELD_OUT));
if (recordEdges == null) {
recordEdges = new HashSet<ODocument>();
document.field(OGraphDatabase.VERTEX_FIELD_OUT, recordEdges);
}
recordEdges.add(edge.getDocument());
document.setDirty();
// INSERT INTO THE INGOING EDGES OF TARGET
iTargetVertex.getInEdges().add(edge);
recordEdges = ((Set<ODocument>) iTargetVertex.getDocument().field(OGraphDatabase.VERTEX_FIELD_IN));
if (recordEdges == null) {
recordEdges = new HashSet<ODocument>();
iTargetVertex.getDocument().field(OGraphDatabase.VERTEX_FIELD_IN, recordEdges);
}
recordEdges.add(edge.getDocument());
iTargetVertex.getDocument().setDirty();
return edge;
} | java | @SuppressWarnings("unchecked")
public OGraphEdge link(final OGraphVertex iTargetVertex, final String iClassName) {
if (iTargetVertex == null)
throw new IllegalArgumentException("Missed the target vertex");
// CREATE THE EDGE BETWEEN ME AND THE TARGET
final OGraphEdge edge = new OGraphEdge(database, iClassName, this, iTargetVertex);
getOutEdges().add(edge);
Set<ODocument> recordEdges = ((Set<ODocument>) document.field(OGraphDatabase.VERTEX_FIELD_OUT));
if (recordEdges == null) {
recordEdges = new HashSet<ODocument>();
document.field(OGraphDatabase.VERTEX_FIELD_OUT, recordEdges);
}
recordEdges.add(edge.getDocument());
document.setDirty();
// INSERT INTO THE INGOING EDGES OF TARGET
iTargetVertex.getInEdges().add(edge);
recordEdges = ((Set<ODocument>) iTargetVertex.getDocument().field(OGraphDatabase.VERTEX_FIELD_IN));
if (recordEdges == null) {
recordEdges = new HashSet<ODocument>();
iTargetVertex.getDocument().field(OGraphDatabase.VERTEX_FIELD_IN, recordEdges);
}
recordEdges.add(edge.getDocument());
iTargetVertex.getDocument().setDirty();
return edge;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"OGraphEdge",
"link",
"(",
"final",
"OGraphVertex",
"iTargetVertex",
",",
"final",
"String",
"iClassName",
")",
"{",
"if",
"(",
"iTargetVertex",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentExcept... | Create a link between the current vertex and the target one. The link is of type iClassName.
@param iTargetVertex
Target vertex where to create the connection
@param iClassName
The name of the class to use for the Edge
@return The new edge created | [
"Create",
"a",
"link",
"between",
"the",
"current",
"vertex",
"and",
"the",
"target",
"one",
".",
"The",
"link",
"is",
"of",
"type",
"iClassName",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java#L90-L120 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java | OGraphVertex.unlink | public OGraphVertex unlink(final OGraphVertex iTargetVertex) {
if (iTargetVertex == null)
throw new IllegalArgumentException("Missed the target vertex");
unlink(database, document, iTargetVertex.getDocument());
return this;
} | java | public OGraphVertex unlink(final OGraphVertex iTargetVertex) {
if (iTargetVertex == null)
throw new IllegalArgumentException("Missed the target vertex");
unlink(database, document, iTargetVertex.getDocument());
return this;
} | [
"public",
"OGraphVertex",
"unlink",
"(",
"final",
"OGraphVertex",
"iTargetVertex",
")",
"{",
"if",
"(",
"iTargetVertex",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Missed the target vertex\"",
")",
";",
"unlink",
"(",
"database",
",",
"... | Remove the link between the current vertex and the target one.
@param iTargetVertex
Target vertex where to remove the connection
@return Current vertex (useful for fluent calls) | [
"Remove",
"the",
"link",
"between",
"the",
"current",
"vertex",
"and",
"the",
"target",
"one",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java#L140-L147 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java | OGraphVertex.hasInEdges | public boolean hasInEdges() {
final Set<ODocument> docs = document.field(OGraphDatabase.VERTEX_FIELD_IN);
return docs != null && !docs.isEmpty();
} | java | public boolean hasInEdges() {
final Set<ODocument> docs = document.field(OGraphDatabase.VERTEX_FIELD_IN);
return docs != null && !docs.isEmpty();
} | [
"public",
"boolean",
"hasInEdges",
"(",
")",
"{",
"final",
"Set",
"<",
"ODocument",
">",
"docs",
"=",
"document",
".",
"field",
"(",
"OGraphDatabase",
".",
"VERTEX_FIELD_IN",
")",
";",
"return",
"docs",
"!=",
"null",
"&&",
"!",
"docs",
".",
"isEmpty",
"(... | Returns true if the vertex has at least one incoming edge, otherwise false. | [
"Returns",
"true",
"if",
"the",
"vertex",
"has",
"at",
"least",
"one",
"incoming",
"edge",
"otherwise",
"false",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java#L152-L155 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java | OGraphVertex.hasOutEdges | public boolean hasOutEdges() {
final Set<ODocument> docs = document.field(OGraphDatabase.VERTEX_FIELD_OUT);
return docs != null && !docs.isEmpty();
} | java | public boolean hasOutEdges() {
final Set<ODocument> docs = document.field(OGraphDatabase.VERTEX_FIELD_OUT);
return docs != null && !docs.isEmpty();
} | [
"public",
"boolean",
"hasOutEdges",
"(",
")",
"{",
"final",
"Set",
"<",
"ODocument",
">",
"docs",
"=",
"document",
".",
"field",
"(",
"OGraphDatabase",
".",
"VERTEX_FIELD_OUT",
")",
";",
"return",
"docs",
"!=",
"null",
"&&",
"!",
"docs",
".",
"isEmpty",
... | Returns true if the vertex has at least one outgoing edge, otherwise false. | [
"Returns",
"true",
"if",
"the",
"vertex",
"has",
"at",
"least",
"one",
"outgoing",
"edge",
"otherwise",
"false",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java#L160-L163 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java | OGraphVertex.getInEdges | public Set<OGraphEdge> getInEdges(final String iEdgeLabel) {
Set<OGraphEdge> temp = in != null ? in.get() : null;
if (temp == null) {
if (iEdgeLabel == null)
temp = new HashSet<OGraphEdge>();
in = new SoftReference<Set<OGraphEdge>>(temp);
final Set<Object> docs = document.field(OGraphDatabase.VERTEX_FIELD_IN);
if (docs != null) {
// TRANSFORM ALL THE ARCS
for (Object o : docs) {
final ODocument doc = (ODocument) ((OIdentifiable) o).getRecord();
if (iEdgeLabel != null && !iEdgeLabel.equals(doc.field(OGraphDatabase.LABEL)))
continue;
temp.add((OGraphEdge) database.getUserObjectByRecord(doc, null));
}
}
} else if (iEdgeLabel != null) {
// FILTER THE EXISTENT COLLECTION
HashSet<OGraphEdge> filtered = new HashSet<OGraphEdge>();
for (OGraphEdge e : temp) {
if (iEdgeLabel.equals(e.getLabel()))
filtered.add(e);
}
temp = filtered;
}
return temp;
} | java | public Set<OGraphEdge> getInEdges(final String iEdgeLabel) {
Set<OGraphEdge> temp = in != null ? in.get() : null;
if (temp == null) {
if (iEdgeLabel == null)
temp = new HashSet<OGraphEdge>();
in = new SoftReference<Set<OGraphEdge>>(temp);
final Set<Object> docs = document.field(OGraphDatabase.VERTEX_FIELD_IN);
if (docs != null) {
// TRANSFORM ALL THE ARCS
for (Object o : docs) {
final ODocument doc = (ODocument) ((OIdentifiable) o).getRecord();
if (iEdgeLabel != null && !iEdgeLabel.equals(doc.field(OGraphDatabase.LABEL)))
continue;
temp.add((OGraphEdge) database.getUserObjectByRecord(doc, null));
}
}
} else if (iEdgeLabel != null) {
// FILTER THE EXISTENT COLLECTION
HashSet<OGraphEdge> filtered = new HashSet<OGraphEdge>();
for (OGraphEdge e : temp) {
if (iEdgeLabel.equals(e.getLabel()))
filtered.add(e);
}
temp = filtered;
}
return temp;
} | [
"public",
"Set",
"<",
"OGraphEdge",
">",
"getInEdges",
"(",
"final",
"String",
"iEdgeLabel",
")",
"{",
"Set",
"<",
"OGraphEdge",
">",
"temp",
"=",
"in",
"!=",
"null",
"?",
"in",
".",
"get",
"(",
")",
":",
"null",
";",
"if",
"(",
"temp",
"==",
"null... | Returns the incoming edges of current node having the requested label. If there are no edged, then an empty set is returned. | [
"Returns",
"the",
"incoming",
"edges",
"of",
"current",
"node",
"having",
"the",
"requested",
"label",
".",
"If",
"there",
"are",
"no",
"edged",
"then",
"an",
"empty",
"set",
"is",
"returned",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java#L175-L206 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java | OGraphVertex.browseOutEdgesVertexes | @SuppressWarnings("unchecked")
public Set<OGraphVertex> browseOutEdgesVertexes() {
final Set<OGraphVertex> resultset = new HashSet<OGraphVertex>();
Set<OGraphEdge> temp = out != null ? out.get() : null;
if (temp == null) {
final Set<OIdentifiable> docEdges = (Set<OIdentifiable>) document.field(OGraphDatabase.VERTEX_FIELD_OUT);
// TRANSFORM ALL THE EDGES
if (docEdges != null)
for (OIdentifiable d : docEdges) {
resultset.add((OGraphVertex) database.getUserObjectByRecord(
(ODocument) ((ODocument) d.getRecord()).field(OGraphDatabase.EDGE_FIELD_IN), null));
}
} else {
for (OGraphEdge edge : temp) {
resultset.add(edge.getIn());
}
}
return resultset;
} | java | @SuppressWarnings("unchecked")
public Set<OGraphVertex> browseOutEdgesVertexes() {
final Set<OGraphVertex> resultset = new HashSet<OGraphVertex>();
Set<OGraphEdge> temp = out != null ? out.get() : null;
if (temp == null) {
final Set<OIdentifiable> docEdges = (Set<OIdentifiable>) document.field(OGraphDatabase.VERTEX_FIELD_OUT);
// TRANSFORM ALL THE EDGES
if (docEdges != null)
for (OIdentifiable d : docEdges) {
resultset.add((OGraphVertex) database.getUserObjectByRecord(
(ODocument) ((ODocument) d.getRecord()).field(OGraphDatabase.EDGE_FIELD_IN), null));
}
} else {
for (OGraphEdge edge : temp) {
resultset.add(edge.getIn());
}
}
return resultset;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Set",
"<",
"OGraphVertex",
">",
"browseOutEdgesVertexes",
"(",
")",
"{",
"final",
"Set",
"<",
"OGraphVertex",
">",
"resultset",
"=",
"new",
"HashSet",
"<",
"OGraphVertex",
">",
"(",
")",
";",
"Se... | Returns the set of Vertexes from the outgoing edges. It avoids to unmarshall edges. | [
"Returns",
"the",
"set",
"of",
"Vertexes",
"from",
"the",
"outgoing",
"edges",
".",
"It",
"avoids",
"to",
"unmarshall",
"edges",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java#L254-L276 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java | OGraphVertex.browseInEdgesVertexes | @SuppressWarnings("unchecked")
public Set<OGraphVertex> browseInEdgesVertexes() {
final Set<OGraphVertex> resultset = new HashSet<OGraphVertex>();
Set<OGraphEdge> temp = in != null ? in.get() : null;
if (temp == null) {
final Set<ODocument> docEdges = (Set<ODocument>) document.field(OGraphDatabase.VERTEX_FIELD_IN);
// TRANSFORM ALL THE EDGES
if (docEdges != null)
for (ODocument d : docEdges) {
resultset.add((OGraphVertex) database.getUserObjectByRecord((ODocument) d.field(OGraphDatabase.EDGE_FIELD_OUT), null));
}
} else {
for (OGraphEdge edge : temp) {
resultset.add(edge.getOut());
}
}
return resultset;
} | java | @SuppressWarnings("unchecked")
public Set<OGraphVertex> browseInEdgesVertexes() {
final Set<OGraphVertex> resultset = new HashSet<OGraphVertex>();
Set<OGraphEdge> temp = in != null ? in.get() : null;
if (temp == null) {
final Set<ODocument> docEdges = (Set<ODocument>) document.field(OGraphDatabase.VERTEX_FIELD_IN);
// TRANSFORM ALL THE EDGES
if (docEdges != null)
for (ODocument d : docEdges) {
resultset.add((OGraphVertex) database.getUserObjectByRecord((ODocument) d.field(OGraphDatabase.EDGE_FIELD_OUT), null));
}
} else {
for (OGraphEdge edge : temp) {
resultset.add(edge.getOut());
}
}
return resultset;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Set",
"<",
"OGraphVertex",
">",
"browseInEdgesVertexes",
"(",
")",
"{",
"final",
"Set",
"<",
"OGraphVertex",
">",
"resultset",
"=",
"new",
"HashSet",
"<",
"OGraphVertex",
">",
"(",
")",
";",
"Set... | Returns the set of Vertexes from the incoming edges. It avoids to unmarshall edges. | [
"Returns",
"the",
"set",
"of",
"Vertexes",
"from",
"the",
"incoming",
"edges",
".",
"It",
"avoids",
"to",
"unmarshall",
"edges",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java#L281-L302 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java | OGraphVertex.unlink | public static void unlink(final ODatabaseGraphTx iDatabase, final ODocument iSourceVertex, final ODocument iTargetVertex) {
if (iTargetVertex == null)
throw new IllegalArgumentException("Missed the target vertex");
if (iDatabase.existsUserObjectByRID(iSourceVertex.getIdentity())) {
// WORK ALSO WITH IN MEMORY OBJECTS
final OGraphVertex vertex = (OGraphVertex) iDatabase.getUserObjectByRecord(iSourceVertex, null);
// REMOVE THE EDGE OBJECT
if (vertex.out != null) {
final Set<OGraphEdge> obj = vertex.out.get();
if (obj != null)
for (OGraphEdge e : obj)
if (e.getIn().getDocument().equals(iTargetVertex))
obj.remove(e);
}
}
if (iDatabase.existsUserObjectByRID(iTargetVertex.getIdentity())) {
// WORK ALSO WITH IN MEMORY OBJECTS
final OGraphVertex vertex = (OGraphVertex) iDatabase.getUserObjectByRecord(iTargetVertex, null);
// REMOVE THE EDGE OBJECT FROM THE TARGET VERTEX
if (vertex.in != null) {
final Set<OGraphEdge> obj = vertex.in.get();
if (obj != null)
for (OGraphEdge e : obj)
if (e.getOut().getDocument().equals(iSourceVertex))
obj.remove(e);
}
}
final List<ODocument> edges2Remove = new ArrayList<ODocument>();
// REMOVE THE EDGE DOCUMENT
ODocument edge = null;
Set<ODocument> docs = iSourceVertex.field(OGraphDatabase.VERTEX_FIELD_OUT);
if (docs != null) {
// USE A TEMP ARRAY TO AVOID CONCURRENT MODIFICATION TO THE ITERATOR
for (OIdentifiable d : docs) {
final ODocument doc = (ODocument) d.getRecord();
if (doc.field(OGraphDatabase.EDGE_FIELD_IN).equals(iTargetVertex)) {
edges2Remove.add(doc);
edge = doc;
}
}
for (ODocument d : edges2Remove)
docs.remove(d);
}
if (edge == null)
throw new OGraphException("Edge not found between the ougoing edges");
iSourceVertex.setDirty();
iSourceVertex.save();
docs = iTargetVertex.field(OGraphDatabase.VERTEX_FIELD_IN);
// REMOVE THE EDGE DOCUMENT FROM THE TARGET VERTEX
if (docs != null) {
edges2Remove.clear();
for (OIdentifiable d : docs) {
final ODocument doc = (ODocument) d.getRecord();
if (doc.field(OGraphDatabase.EDGE_FIELD_IN).equals(iTargetVertex))
edges2Remove.add(doc);
}
for (ODocument d : edges2Remove)
docs.remove(d);
}
iTargetVertex.setDirty();
iTargetVertex.save();
edge.delete();
} | java | public static void unlink(final ODatabaseGraphTx iDatabase, final ODocument iSourceVertex, final ODocument iTargetVertex) {
if (iTargetVertex == null)
throw new IllegalArgumentException("Missed the target vertex");
if (iDatabase.existsUserObjectByRID(iSourceVertex.getIdentity())) {
// WORK ALSO WITH IN MEMORY OBJECTS
final OGraphVertex vertex = (OGraphVertex) iDatabase.getUserObjectByRecord(iSourceVertex, null);
// REMOVE THE EDGE OBJECT
if (vertex.out != null) {
final Set<OGraphEdge> obj = vertex.out.get();
if (obj != null)
for (OGraphEdge e : obj)
if (e.getIn().getDocument().equals(iTargetVertex))
obj.remove(e);
}
}
if (iDatabase.existsUserObjectByRID(iTargetVertex.getIdentity())) {
// WORK ALSO WITH IN MEMORY OBJECTS
final OGraphVertex vertex = (OGraphVertex) iDatabase.getUserObjectByRecord(iTargetVertex, null);
// REMOVE THE EDGE OBJECT FROM THE TARGET VERTEX
if (vertex.in != null) {
final Set<OGraphEdge> obj = vertex.in.get();
if (obj != null)
for (OGraphEdge e : obj)
if (e.getOut().getDocument().equals(iSourceVertex))
obj.remove(e);
}
}
final List<ODocument> edges2Remove = new ArrayList<ODocument>();
// REMOVE THE EDGE DOCUMENT
ODocument edge = null;
Set<ODocument> docs = iSourceVertex.field(OGraphDatabase.VERTEX_FIELD_OUT);
if (docs != null) {
// USE A TEMP ARRAY TO AVOID CONCURRENT MODIFICATION TO THE ITERATOR
for (OIdentifiable d : docs) {
final ODocument doc = (ODocument) d.getRecord();
if (doc.field(OGraphDatabase.EDGE_FIELD_IN).equals(iTargetVertex)) {
edges2Remove.add(doc);
edge = doc;
}
}
for (ODocument d : edges2Remove)
docs.remove(d);
}
if (edge == null)
throw new OGraphException("Edge not found between the ougoing edges");
iSourceVertex.setDirty();
iSourceVertex.save();
docs = iTargetVertex.field(OGraphDatabase.VERTEX_FIELD_IN);
// REMOVE THE EDGE DOCUMENT FROM THE TARGET VERTEX
if (docs != null) {
edges2Remove.clear();
for (OIdentifiable d : docs) {
final ODocument doc = (ODocument) d.getRecord();
if (doc.field(OGraphDatabase.EDGE_FIELD_IN).equals(iTargetVertex))
edges2Remove.add(doc);
}
for (ODocument d : edges2Remove)
docs.remove(d);
}
iTargetVertex.setDirty();
iTargetVertex.save();
edge.delete();
} | [
"public",
"static",
"void",
"unlink",
"(",
"final",
"ODatabaseGraphTx",
"iDatabase",
",",
"final",
"ODocument",
"iSourceVertex",
",",
"final",
"ODocument",
"iTargetVertex",
")",
"{",
"if",
"(",
"iTargetVertex",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentEx... | Unlinks all the edges between iSourceVertex and iTargetVertex
@param iDatabase
@param iSourceVertex
@param iTargetVertex | [
"Unlinks",
"all",
"the",
"edges",
"between",
"iSourceVertex",
"and",
"iTargetVertex"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/db/graph/OGraphVertex.java#L395-L472 | train |
dmfs/jdav | src/org/dmfs/dav/rfc6578/SyncCollection.java | SyncCollection.limitNumberOfResults | public SyncCollection limitNumberOfResults(int limit)
{
if (limit > 0)
{
addLimit(WebDavSearch.NRESULTS, limit);
}
else
{
removeLimit(WebDavSearch.NRESULTS);
}
return this;
} | java | public SyncCollection limitNumberOfResults(int limit)
{
if (limit > 0)
{
addLimit(WebDavSearch.NRESULTS, limit);
}
else
{
removeLimit(WebDavSearch.NRESULTS);
}
return this;
} | [
"public",
"SyncCollection",
"limitNumberOfResults",
"(",
"int",
"limit",
")",
"{",
"if",
"(",
"limit",
">",
"0",
")",
"{",
"addLimit",
"(",
"WebDavSearch",
".",
"NRESULTS",
",",
"limit",
")",
";",
"}",
"else",
"{",
"removeLimit",
"(",
"WebDavSearch",
".",
... | Limit the number of results in the response, if supported by the server. A non-positive value will remove the limit.
<p>
<strong>Note:</strong> At present it's recommended to not use this feature. There are only a few servers that support it and some of them are broken and
may return wrong results.
</p>
@param limit
The maximum number of result in the response if this is a positive integer.
@return This instance. | [
"Limit",
"the",
"number",
"of",
"results",
"in",
"the",
"response",
"if",
"supported",
"by",
"the",
"server",
".",
"A",
"non",
"-",
"positive",
"value",
"will",
"remove",
"the",
"limit",
"."
] | a619d85423210a283b3eb1fba9abda4fdc894969 | https://github.com/dmfs/jdav/blob/a619d85423210a283b3eb1fba9abda4fdc894969/src/org/dmfs/dav/rfc6578/SyncCollection.java#L183-L194 | train |
dmfs/jdav | src/org/dmfs/dav/rfc6578/SyncCollection.java | SyncCollection.getNumberOfResultsLimit | public int getNumberOfResultsLimit()
{
if (mLimit == null)
{
return 0;
}
Integer limit = (Integer) mLimit.get(WebDavSearch.NRESULTS);
return limit == null ? 0 : limit;
} | java | public int getNumberOfResultsLimit()
{
if (mLimit == null)
{
return 0;
}
Integer limit = (Integer) mLimit.get(WebDavSearch.NRESULTS);
return limit == null ? 0 : limit;
} | [
"public",
"int",
"getNumberOfResultsLimit",
"(",
")",
"{",
"if",
"(",
"mLimit",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"Integer",
"limit",
"=",
"(",
"Integer",
")",
"mLimit",
".",
"get",
"(",
"WebDavSearch",
".",
"NRESULTS",
")",
";",
"return... | Returns the limit for the number of results in this request.
@return The limit or 0 if there is no limit. | [
"Returns",
"the",
"limit",
"for",
"the",
"number",
"of",
"results",
"in",
"this",
"request",
"."
] | a619d85423210a283b3eb1fba9abda4fdc894969 | https://github.com/dmfs/jdav/blob/a619d85423210a283b3eb1fba9abda4fdc894969/src/org/dmfs/dav/rfc6578/SyncCollection.java#L202-L210 | train |
dmfs/jdav | src/org/dmfs/dav/rfc6578/SyncCollection.java | SyncCollection.addLimit | private <T> void addLimit(ElementDescriptor<T> descriptor, T limit)
{
if (mLimit == null)
{
mLimit = new HashMap<ElementDescriptor<?>, Object>(6);
}
mLimit.put(descriptor, limit);
} | java | private <T> void addLimit(ElementDescriptor<T> descriptor, T limit)
{
if (mLimit == null)
{
mLimit = new HashMap<ElementDescriptor<?>, Object>(6);
}
mLimit.put(descriptor, limit);
} | [
"private",
"<",
"T",
">",
"void",
"addLimit",
"(",
"ElementDescriptor",
"<",
"T",
">",
"descriptor",
",",
"T",
"limit",
")",
"{",
"if",
"(",
"mLimit",
"==",
"null",
")",
"{",
"mLimit",
"=",
"new",
"HashMap",
"<",
"ElementDescriptor",
"<",
"?",
">",
"... | Add a limit to the request.
@param descriptor
The {@link ElementDescriptor} of the limit element.
@param limit
The limit value. | [
"Add",
"a",
"limit",
"to",
"the",
"request",
"."
] | a619d85423210a283b3eb1fba9abda4fdc894969 | https://github.com/dmfs/jdav/blob/a619d85423210a283b3eb1fba9abda4fdc894969/src/org/dmfs/dav/rfc6578/SyncCollection.java#L221-L228 | train |
loldevs/riotapi | spectator/src/main/java/net/boreeas/riotapi/spectator/MappedDataCache.java | MappedDataCache.put | public void put(K k, V v) {
cache.put(k, v);
acquireLock(k).countDown();
} | java | public void put(K k, V v) {
cache.put(k, v);
acquireLock(k).countDown();
} | [
"public",
"void",
"put",
"(",
"K",
"k",
",",
"V",
"v",
")",
"{",
"cache",
".",
"put",
"(",
"k",
",",
"v",
")",
";",
"acquireLock",
"(",
"k",
")",
".",
"countDown",
"(",
")",
";",
"}"
] | Caches the given mapping and releases all waiting locks.
@param k The key to store.
@param v The value to store. | [
"Caches",
"the",
"given",
"mapping",
"and",
"releases",
"all",
"waiting",
"locks",
"."
] | 0b8aac407aa5289845f249024f9732332855544f | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/spectator/src/main/java/net/boreeas/riotapi/spectator/MappedDataCache.java#L56-L59 | train |
loldevs/riotapi | spectator/src/main/java/net/boreeas/riotapi/spectator/MappedDataCache.java | MappedDataCache.get | public V get(K k) throws InterruptedException {
await(k);
return cache.get(k);
} | java | public V get(K k) throws InterruptedException {
await(k);
return cache.get(k);
} | [
"public",
"V",
"get",
"(",
"K",
"k",
")",
"throws",
"InterruptedException",
"{",
"await",
"(",
"k",
")",
";",
"return",
"cache",
".",
"get",
"(",
"k",
")",
";",
"}"
] | Retrieve the value associated with the given key, blocking as long as necessary.
@param k The key.
@return The value associated with the key.
@throws InterruptedException | [
"Retrieve",
"the",
"value",
"associated",
"with",
"the",
"given",
"key",
"blocking",
"as",
"long",
"as",
"necessary",
"."
] | 0b8aac407aa5289845f249024f9732332855544f | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/spectator/src/main/java/net/boreeas/riotapi/spectator/MappedDataCache.java#L67-L70 | train |
loldevs/riotapi | spectator/src/main/java/net/boreeas/riotapi/spectator/MappedDataCache.java | MappedDataCache.get | public V get(K k, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
await(k, timeout, unit);
return cache.get(k);
} | java | public V get(K k, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
await(k, timeout, unit);
return cache.get(k);
} | [
"public",
"V",
"get",
"(",
"K",
"k",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
",",
"TimeoutException",
"{",
"await",
"(",
"k",
",",
"timeout",
",",
"unit",
")",
";",
"return",
"cache",
".",
"get",
"(",
"k"... | Retrieve the value associated with the given key, blocking as long as necessary up to the specified maximum.
@param k The key.
@param timeout The length of the timeout.
@param unit The time unit of the timeout.
@return The value associated with the key.
@throws InterruptedException
@throws TimeoutException | [
"Retrieve",
"the",
"value",
"associated",
"with",
"the",
"given",
"key",
"blocking",
"as",
"long",
"as",
"necessary",
"up",
"to",
"the",
"specified",
"maximum",
"."
] | 0b8aac407aa5289845f249024f9732332855544f | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/spectator/src/main/java/net/boreeas/riotapi/spectator/MappedDataCache.java#L81-L85 | train |
loldevs/riotapi | spectator/src/main/java/net/boreeas/riotapi/spectator/MappedDataCache.java | MappedDataCache.await | public void await(K k, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
if (!acquireLock(k).await(timeout, unit)) {
throw new TimeoutException("Wait time for retrieving value for key " + k + " exceeded " + timeout + " " + unit);
}
} | java | public void await(K k, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
if (!acquireLock(k).await(timeout, unit)) {
throw new TimeoutException("Wait time for retrieving value for key " + k + " exceeded " + timeout + " " + unit);
}
} | [
"public",
"void",
"await",
"(",
"K",
"k",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
",",
"TimeoutException",
"{",
"if",
"(",
"!",
"acquireLock",
"(",
"k",
")",
".",
"await",
"(",
"timeout",
",",
"unit",
")",
... | Waits until the key has been assigned a value, up to the specified maximum.
@param k THe key to wait for.
@param timeout The maximum time to wait.
@param unit The time unit of the timeout.
@throws InterruptedException
@throws TimeoutException | [
"Waits",
"until",
"the",
"key",
"has",
"been",
"assigned",
"a",
"value",
"up",
"to",
"the",
"specified",
"maximum",
"."
] | 0b8aac407aa5289845f249024f9732332855544f | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/spectator/src/main/java/net/boreeas/riotapi/spectator/MappedDataCache.java#L104-L108 | train |
soi-toolkit/soi-toolkit-mule | commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/sftp/SftpUtil.java | SftpUtil.initEndpointDirectories | public static void initEndpointDirectories(MuleContext muleContext, String[] serviceNames, String[] endpointNames) throws Exception {
// Stop all named services (either Flows or services
List<Lifecycle> services = new ArrayList<Lifecycle>();
for (String serviceName : serviceNames) {
try {
Lifecycle service = muleContext.getRegistry().lookupObject(serviceName);
// logServiceStatus(service);
// service.stop();
// logServiceStatus(service);
services.add(service);
} catch (Exception e) {
logger.error("Error '" + e.getMessage()
+ "' occured while stopping the service " + serviceName
+ ". Perhaps the service did not exist in the config?");
throw e;
}
}
// Now init the directory for each named endpoint, one by one
for (String endpointName : endpointNames) {
initEndpointDirectory(muleContext, endpointName);
}
// We are done, startup the services again so that the test can begin...
for (@SuppressWarnings("unused") Lifecycle service : services) {
// logServiceStatus(service);
// service.start();
// logServiceStatus(service);
}
} | java | public static void initEndpointDirectories(MuleContext muleContext, String[] serviceNames, String[] endpointNames) throws Exception {
// Stop all named services (either Flows or services
List<Lifecycle> services = new ArrayList<Lifecycle>();
for (String serviceName : serviceNames) {
try {
Lifecycle service = muleContext.getRegistry().lookupObject(serviceName);
// logServiceStatus(service);
// service.stop();
// logServiceStatus(service);
services.add(service);
} catch (Exception e) {
logger.error("Error '" + e.getMessage()
+ "' occured while stopping the service " + serviceName
+ ". Perhaps the service did not exist in the config?");
throw e;
}
}
// Now init the directory for each named endpoint, one by one
for (String endpointName : endpointNames) {
initEndpointDirectory(muleContext, endpointName);
}
// We are done, startup the services again so that the test can begin...
for (@SuppressWarnings("unused") Lifecycle service : services) {
// logServiceStatus(service);
// service.start();
// logServiceStatus(service);
}
} | [
"public",
"static",
"void",
"initEndpointDirectories",
"(",
"MuleContext",
"muleContext",
",",
"String",
"[",
"]",
"serviceNames",
",",
"String",
"[",
"]",
"endpointNames",
")",
"throws",
"Exception",
"{",
"// Stop all named services (either Flows or services",
"List",
... | Initiates a list of sftp-endpoint-directories. Ensures that affected
services are stopped during the initiation.
@param serviceNames
@param endpointNames
@param muleContext
@throws Exception | [
"Initiates",
"a",
"list",
"of",
"sftp",
"-",
"endpoint",
"-",
"directories",
".",
"Ensures",
"that",
"affected",
"services",
"are",
"stopped",
"during",
"the",
"initiation",
"."
] | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/sftp/SftpUtil.java#L69-L99 | train |
soi-toolkit/soi-toolkit-mule | commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/sftp/SftpUtil.java | SftpUtil.getSftpClient | static protected SftpClient getSftpClient(MuleContext muleContext,
String endpointName) throws IOException {
ImmutableEndpoint endpoint = getImmutableEndpoint(muleContext,
endpointName);
try {
SftpClient sftpClient = SftpConnectionFactory.createClient(endpoint);
return sftpClient;
} catch (Exception e) {
throw new RuntimeException("Login failed", e);
}
/*
EndpointURI endpointURI = endpoint.getEndpointURI();
SftpClient sftpClient = new SftpClient(endpointURI.getHost());
SftpConnector sftpConnector = (SftpConnector) endpoint.getConnector();
if (sftpConnector.getIdentityFile() != null) {
try {
sftpClient.login(endpointURI.getUser(),
sftpConnector.getIdentityFile(),
sftpConnector.getPassphrase());
} catch (Exception e) {
throw new RuntimeException("Login failed", e);
}
} else {
try {
sftpClient.login(endpointURI.getUser(),
endpointURI.getPassword());
} catch (Exception e) {
throw new RuntimeException("Login failed", e);
}
}
return sftpClient;
*/
} | java | static protected SftpClient getSftpClient(MuleContext muleContext,
String endpointName) throws IOException {
ImmutableEndpoint endpoint = getImmutableEndpoint(muleContext,
endpointName);
try {
SftpClient sftpClient = SftpConnectionFactory.createClient(endpoint);
return sftpClient;
} catch (Exception e) {
throw new RuntimeException("Login failed", e);
}
/*
EndpointURI endpointURI = endpoint.getEndpointURI();
SftpClient sftpClient = new SftpClient(endpointURI.getHost());
SftpConnector sftpConnector = (SftpConnector) endpoint.getConnector();
if (sftpConnector.getIdentityFile() != null) {
try {
sftpClient.login(endpointURI.getUser(),
sftpConnector.getIdentityFile(),
sftpConnector.getPassphrase());
} catch (Exception e) {
throw new RuntimeException("Login failed", e);
}
} else {
try {
sftpClient.login(endpointURI.getUser(),
endpointURI.getPassword());
} catch (Exception e) {
throw new RuntimeException("Login failed", e);
}
}
return sftpClient;
*/
} | [
"static",
"protected",
"SftpClient",
"getSftpClient",
"(",
"MuleContext",
"muleContext",
",",
"String",
"endpointName",
")",
"throws",
"IOException",
"{",
"ImmutableEndpoint",
"endpoint",
"=",
"getImmutableEndpoint",
"(",
"muleContext",
",",
"endpointName",
")",
";",
... | Returns a SftpClient that is logged in to the sftp server that the
endpoint is configured against.
@param muleContext
@param endpointName
@return
@throws IOException | [
"Returns",
"a",
"SftpClient",
"that",
"is",
"logged",
"in",
"to",
"the",
"sftp",
"server",
"that",
"the",
"endpoint",
"is",
"configured",
"against",
"."
] | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/sftp/SftpUtil.java#L208-L244 | train |
soi-toolkit/soi-toolkit-mule | commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/sftp/SftpUtil.java | SftpUtil.recursiveDelete | static protected void recursiveDelete(MuleContext muleContext, SftpClient sftpClient, String endpointName, String relativePath) throws IOException {
EndpointURI endpointURI = getImmutableEndpoint(muleContext, endpointName).getEndpointURI();
String path = endpointURI.getPath() + relativePath;
try {
// Ensure that we can delete the current directory and the below
// directories (if write is not permitted then delete is either)
sftpClient.chmod(path, 00700);
sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(path));
// Delete all sub-directories
String[] directories = sftpClient.listDirectories();
for (String directory : directories) {
recursiveDelete(muleContext, sftpClient, endpointName,
relativePath + "/" + directory);
}
// Needs to change the directory back after the recursiveDelete
sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(path));
// Delete all files
String[] files = sftpClient.listFiles();
for (String file : files) {
sftpClient.deleteFile(file);
}
// Delete the directory
try {
sftpClient.deleteDirectory(path);
} catch (Exception e) {
if (logger.isDebugEnabled())
logger.debug("Failed delete directory " + path, e);
}
} catch (Exception e) {
if (logger.isDebugEnabled())
logger.debug("Failed to recursivly delete directory " + path, e);
}
} | java | static protected void recursiveDelete(MuleContext muleContext, SftpClient sftpClient, String endpointName, String relativePath) throws IOException {
EndpointURI endpointURI = getImmutableEndpoint(muleContext, endpointName).getEndpointURI();
String path = endpointURI.getPath() + relativePath;
try {
// Ensure that we can delete the current directory and the below
// directories (if write is not permitted then delete is either)
sftpClient.chmod(path, 00700);
sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(path));
// Delete all sub-directories
String[] directories = sftpClient.listDirectories();
for (String directory : directories) {
recursiveDelete(muleContext, sftpClient, endpointName,
relativePath + "/" + directory);
}
// Needs to change the directory back after the recursiveDelete
sftpClient.changeWorkingDirectory(sftpClient.getAbsolutePath(path));
// Delete all files
String[] files = sftpClient.listFiles();
for (String file : files) {
sftpClient.deleteFile(file);
}
// Delete the directory
try {
sftpClient.deleteDirectory(path);
} catch (Exception e) {
if (logger.isDebugEnabled())
logger.debug("Failed delete directory " + path, e);
}
} catch (Exception e) {
if (logger.isDebugEnabled())
logger.debug("Failed to recursivly delete directory " + path, e);
}
} | [
"static",
"protected",
"void",
"recursiveDelete",
"(",
"MuleContext",
"muleContext",
",",
"SftpClient",
"sftpClient",
",",
"String",
"endpointName",
",",
"String",
"relativePath",
")",
"throws",
"IOException",
"{",
"EndpointURI",
"endpointURI",
"=",
"getImmutableEndpoin... | Deletes a directory with all its files and sub-directories. The reason it
do a "chmod 700" before the delete is that some tests changes the
permission, and thus we have to restore the right to delete it...
@param muleClient
@param endpointName
@param relativePath
@throws IOException | [
"Deletes",
"a",
"directory",
"with",
"all",
"its",
"files",
"and",
"sub",
"-",
"directories",
".",
"The",
"reason",
"it",
"do",
"a",
"chmod",
"700",
"before",
"the",
"delete",
"is",
"that",
"some",
"tests",
"changes",
"the",
"permission",
"and",
"thus",
... | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/sftp/SftpUtil.java#L263-L302 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java | OMVRBTreeEntryPersistent.save | public OMVRBTreeEntryPersistent<K, V> save() throws OSerializationException {
if (!dataProvider.isEntryDirty())
return this;
final boolean isNew = dataProvider.getIdentity().isNew();
// FOR EACH NEW LINK, SAVE BEFORE
if (left != null && left.dataProvider.getIdentity().isNew()) {
if (isNew) {
// TEMPORARY INCORRECT SAVE FOR GETTING AN ID. WILL BE SET DIRTY AGAIN JUST AFTER
left.dataProvider.save();
} else
left.save();
}
if (right != null && right.dataProvider.getIdentity().isNew()) {
if (isNew) {
// TEMPORARY INCORRECT SAVE FOR GETTING AN ID. WILL BE SET DIRTY AGAIN JUST AFTER
right.dataProvider.save();
} else
right.save();
}
if (parent != null && parent.dataProvider.getIdentity().isNew()) {
if (isNew) {
// TEMPORARY INCORRECT SAVE FOR GETTING AN ID. WILL BE SET DIRTY AGAIN JUST AFTER
parent.dataProvider.save();
} else
parent.save();
}
dataProvider.save();
// if (parent != null)
// if (!parent.record.getIdentity().equals(parentRid))
// OLogManager.instance().error(this,
// "[save]: Tree node %s has parentRid '%s' different by the rid of the assigned parent node: %s", record.getIdentity(),
// parentRid, parent.record.getIdentity());
checkEntryStructure();
if (pTree.searchNodeInCache(dataProvider.getIdentity()) != this) {
// UPDATE THE CACHE
pTree.addNodeInMemory(this);
}
return this;
} | java | public OMVRBTreeEntryPersistent<K, V> save() throws OSerializationException {
if (!dataProvider.isEntryDirty())
return this;
final boolean isNew = dataProvider.getIdentity().isNew();
// FOR EACH NEW LINK, SAVE BEFORE
if (left != null && left.dataProvider.getIdentity().isNew()) {
if (isNew) {
// TEMPORARY INCORRECT SAVE FOR GETTING AN ID. WILL BE SET DIRTY AGAIN JUST AFTER
left.dataProvider.save();
} else
left.save();
}
if (right != null && right.dataProvider.getIdentity().isNew()) {
if (isNew) {
// TEMPORARY INCORRECT SAVE FOR GETTING AN ID. WILL BE SET DIRTY AGAIN JUST AFTER
right.dataProvider.save();
} else
right.save();
}
if (parent != null && parent.dataProvider.getIdentity().isNew()) {
if (isNew) {
// TEMPORARY INCORRECT SAVE FOR GETTING AN ID. WILL BE SET DIRTY AGAIN JUST AFTER
parent.dataProvider.save();
} else
parent.save();
}
dataProvider.save();
// if (parent != null)
// if (!parent.record.getIdentity().equals(parentRid))
// OLogManager.instance().error(this,
// "[save]: Tree node %s has parentRid '%s' different by the rid of the assigned parent node: %s", record.getIdentity(),
// parentRid, parent.record.getIdentity());
checkEntryStructure();
if (pTree.searchNodeInCache(dataProvider.getIdentity()) != this) {
// UPDATE THE CACHE
pTree.addNodeInMemory(this);
}
return this;
} | [
"public",
"OMVRBTreeEntryPersistent",
"<",
"K",
",",
"V",
">",
"save",
"(",
")",
"throws",
"OSerializationException",
"{",
"if",
"(",
"!",
"dataProvider",
".",
"isEntryDirty",
"(",
")",
")",
"return",
"this",
";",
"final",
"boolean",
"isNew",
"=",
"dataProvi... | Assures that all the links versus parent, left and right are consistent. | [
"Assures",
"that",
"all",
"the",
"links",
"versus",
"parent",
"left",
"and",
"right",
"are",
"consistent",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java#L156-L201 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java | OMVRBTreeEntryPersistent.delete | public OMVRBTreeEntryPersistent<K, V> delete() throws IOException {
if (dataProvider != null) {
pTree.removeNodeFromMemory(this);
pTree.removeEntry(dataProvider.getIdentity());
// EARLY LOAD LEFT AND DELETE IT RECURSIVELY
if (getLeft() != null)
((OMVRBTreeEntryPersistent<K, V>) getLeft()).delete();
// EARLY LOAD RIGHT AND DELETE IT RECURSIVELY
if (getRight() != null)
((OMVRBTreeEntryPersistent<K, V>) getRight()).delete();
// DELETE MYSELF
dataProvider.removeIdentityChangedListener(this);
dataProvider.delete();
clear();
}
return this;
} | java | public OMVRBTreeEntryPersistent<K, V> delete() throws IOException {
if (dataProvider != null) {
pTree.removeNodeFromMemory(this);
pTree.removeEntry(dataProvider.getIdentity());
// EARLY LOAD LEFT AND DELETE IT RECURSIVELY
if (getLeft() != null)
((OMVRBTreeEntryPersistent<K, V>) getLeft()).delete();
// EARLY LOAD RIGHT AND DELETE IT RECURSIVELY
if (getRight() != null)
((OMVRBTreeEntryPersistent<K, V>) getRight()).delete();
// DELETE MYSELF
dataProvider.removeIdentityChangedListener(this);
dataProvider.delete();
clear();
}
return this;
} | [
"public",
"OMVRBTreeEntryPersistent",
"<",
"K",
",",
"V",
">",
"delete",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"dataProvider",
"!=",
"null",
")",
"{",
"pTree",
".",
"removeNodeFromMemory",
"(",
"this",
")",
";",
"pTree",
".",
"removeEntry",
"(... | Delete all the nodes recursively. IF they are not loaded in memory, load all the tree.
@throws IOException | [
"Delete",
"all",
"the",
"nodes",
"recursively",
".",
"IF",
"they",
"are",
"not",
"loaded",
"in",
"memory",
"load",
"all",
"the",
"tree",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java#L208-L228 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java | OMVRBTreeEntryPersistent.disconnect | protected int disconnect(final boolean iForceDirty, final int iLevel) {
if (dataProvider == null)
// DIRTY NODE, JUST REMOVE IT
return 1;
int totalDisconnected = 0;
final ORID rid = dataProvider.getIdentity();
boolean disconnectedFromParent = false;
if (parent != null) {
// DISCONNECT RECURSIVELY THE PARENT NODE
if (canDisconnectFrom(parent) || iForceDirty) {
if (parent.left == this) {
parent.left = null;
} else if (parent.right == this) {
parent.right = null;
} else
OLogManager.instance().warn(this,
"Node " + rid + " has the parent (" + parent + ") unlinked to itself. It links to " + parent);
totalDisconnected += parent.disconnect(iForceDirty, iLevel + 1);
parent = null;
disconnectedFromParent = true;
}
} else {
disconnectedFromParent = true;
}
boolean disconnectedFromLeft = false;
if (left != null) {
// DISCONNECT RECURSIVELY THE LEFT NODE
if (canDisconnectFrom(left) || iForceDirty) {
if (left.parent == this)
left.parent = null;
else
OLogManager.instance().warn(this,
"Node " + rid + " has the left (" + left + ") unlinked to itself. It links to " + left.parent);
totalDisconnected += left.disconnect(iForceDirty, iLevel + 1);
left = null;
disconnectedFromLeft = true;
}
} else {
disconnectedFromLeft = true;
}
boolean disconnectedFromRight = false;
if (right != null) {
// DISCONNECT RECURSIVELY THE RIGHT NODE
if (canDisconnectFrom(right) || iForceDirty) {
if (right.parent == this)
right.parent = null;
else
OLogManager.instance().warn(this,
"Node " + rid + " has the right (" + right + ") unlinked to itself. It links to " + right.parent);
totalDisconnected += right.disconnect(iForceDirty, iLevel + 1);
right = null;
disconnectedFromRight = true;
}
} else {
disconnectedFromLeft = true;
}
if (disconnectedFromParent && disconnectedFromLeft && disconnectedFromRight)
if ((!dataProvider.isEntryDirty() && !dataProvider.getIdentity().isTemporary() || iForceDirty)
&& !pTree.isNodeEntryPoint(this)) {
totalDisconnected++;
pTree.removeNodeFromMemory(this);
clear();
}
return totalDisconnected;
} | java | protected int disconnect(final boolean iForceDirty, final int iLevel) {
if (dataProvider == null)
// DIRTY NODE, JUST REMOVE IT
return 1;
int totalDisconnected = 0;
final ORID rid = dataProvider.getIdentity();
boolean disconnectedFromParent = false;
if (parent != null) {
// DISCONNECT RECURSIVELY THE PARENT NODE
if (canDisconnectFrom(parent) || iForceDirty) {
if (parent.left == this) {
parent.left = null;
} else if (parent.right == this) {
parent.right = null;
} else
OLogManager.instance().warn(this,
"Node " + rid + " has the parent (" + parent + ") unlinked to itself. It links to " + parent);
totalDisconnected += parent.disconnect(iForceDirty, iLevel + 1);
parent = null;
disconnectedFromParent = true;
}
} else {
disconnectedFromParent = true;
}
boolean disconnectedFromLeft = false;
if (left != null) {
// DISCONNECT RECURSIVELY THE LEFT NODE
if (canDisconnectFrom(left) || iForceDirty) {
if (left.parent == this)
left.parent = null;
else
OLogManager.instance().warn(this,
"Node " + rid + " has the left (" + left + ") unlinked to itself. It links to " + left.parent);
totalDisconnected += left.disconnect(iForceDirty, iLevel + 1);
left = null;
disconnectedFromLeft = true;
}
} else {
disconnectedFromLeft = true;
}
boolean disconnectedFromRight = false;
if (right != null) {
// DISCONNECT RECURSIVELY THE RIGHT NODE
if (canDisconnectFrom(right) || iForceDirty) {
if (right.parent == this)
right.parent = null;
else
OLogManager.instance().warn(this,
"Node " + rid + " has the right (" + right + ") unlinked to itself. It links to " + right.parent);
totalDisconnected += right.disconnect(iForceDirty, iLevel + 1);
right = null;
disconnectedFromRight = true;
}
} else {
disconnectedFromLeft = true;
}
if (disconnectedFromParent && disconnectedFromLeft && disconnectedFromRight)
if ((!dataProvider.isEntryDirty() && !dataProvider.getIdentity().isTemporary() || iForceDirty)
&& !pTree.isNodeEntryPoint(this)) {
totalDisconnected++;
pTree.removeNodeFromMemory(this);
clear();
}
return totalDisconnected;
} | [
"protected",
"int",
"disconnect",
"(",
"final",
"boolean",
"iForceDirty",
",",
"final",
"int",
"iLevel",
")",
"{",
"if",
"(",
"dataProvider",
"==",
"null",
")",
"// DIRTY NODE, JUST REMOVE IT\r",
"return",
"1",
";",
"int",
"totalDisconnected",
"=",
"0",
";",
"... | Disconnect the current node from others.
@param iForceDirty
Force disconnection also if the record it's dirty
@param iLevel
@return count of nodes that has been disconnected | [
"Disconnect",
"the",
"current",
"node",
"from",
"others",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java#L238-L312 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java | OMVRBTreeEntryPersistent.setValue | public V setValue(final V iValue) {
V oldValue = getValue();
int index = tree.getPageIndex();
if (dataProvider.setValueAt(index, iValue))
markDirty();
return oldValue;
} | java | public V setValue(final V iValue) {
V oldValue = getValue();
int index = tree.getPageIndex();
if (dataProvider.setValueAt(index, iValue))
markDirty();
return oldValue;
} | [
"public",
"V",
"setValue",
"(",
"final",
"V",
"iValue",
")",
"{",
"V",
"oldValue",
"=",
"getValue",
"(",
")",
";",
"int",
"index",
"=",
"tree",
".",
"getPageIndex",
"(",
")",
";",
"if",
"(",
"dataProvider",
".",
"setValueAt",
"(",
"index",
",",
"iVal... | Invalidate serialized Value associated in order to be re-marshalled on the next node storing. | [
"Invalidate",
"serialized",
"Value",
"associated",
"in",
"order",
"to",
"be",
"re",
"-",
"marshalled",
"on",
"the",
"next",
"node",
"storing",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java#L551-L559 | train |
wuman/orientdb-android | enterprise/src/main/java/com/orientechnologies/orient/enterprise/channel/binary/OChannelBinaryProtocol.java | OChannelBinaryProtocol.readIdentifiable | public static OIdentifiable readIdentifiable(final OChannelBinaryClient network) throws IOException {
final int classId = network.readShort();
if (classId == RECORD_NULL)
return null;
if (classId == RECORD_RID) {
return network.readRID();
} else {
final ORecordInternal<?> record = Orient.instance().getRecordFactoryManager().newInstance(network.readByte());
if (record instanceof ORecordSchemaAware<?>)
((ORecordSchemaAware<?>) record).fill(network.readRID(), network.readInt(), network.readBytes(), false);
else
// DISCARD CLASS ID
record.fill(network.readRID(), network.readInt(), network.readBytes(), false);
return record;
}
} | java | public static OIdentifiable readIdentifiable(final OChannelBinaryClient network) throws IOException {
final int classId = network.readShort();
if (classId == RECORD_NULL)
return null;
if (classId == RECORD_RID) {
return network.readRID();
} else {
final ORecordInternal<?> record = Orient.instance().getRecordFactoryManager().newInstance(network.readByte());
if (record instanceof ORecordSchemaAware<?>)
((ORecordSchemaAware<?>) record).fill(network.readRID(), network.readInt(), network.readBytes(), false);
else
// DISCARD CLASS ID
record.fill(network.readRID(), network.readInt(), network.readBytes(), false);
return record;
}
} | [
"public",
"static",
"OIdentifiable",
"readIdentifiable",
"(",
"final",
"OChannelBinaryClient",
"network",
")",
"throws",
"IOException",
"{",
"final",
"int",
"classId",
"=",
"network",
".",
"readShort",
"(",
")",
";",
"if",
"(",
"classId",
"==",
"RECORD_NULL",
")... | SENT AS SHORT AS FIRST PACKET AFTER SOCKET CONNECTION | [
"SENT",
"AS",
"SHORT",
"AS",
"FIRST",
"PACKET",
"AFTER",
"SOCKET",
"CONNECTION"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/enterprise/src/main/java/com/orientechnologies/orient/enterprise/channel/binary/OChannelBinaryProtocol.java#L93-L111 | train |
lightblue-platform/lightblue-migrator | migrator/src/main/java/com/redhat/lightblue/migrator/Utils.java | Utils.getDocumentIdMap | public static Map<Identity, JsonNode> getDocumentIdMap(List<JsonNode> list, List<String> identityFields) {
Map<Identity, JsonNode> map = new HashMap<>();
if (list != null) {
LOGGER.debug("Getting doc IDs for {} docs, fields={}", list.size(), identityFields);
for (JsonNode node : list) {
Identity id = new Identity(node, identityFields);
LOGGER.debug("ID={}", id);
map.put(id, node);
}
}
return map;
} | java | public static Map<Identity, JsonNode> getDocumentIdMap(List<JsonNode> list, List<String> identityFields) {
Map<Identity, JsonNode> map = new HashMap<>();
if (list != null) {
LOGGER.debug("Getting doc IDs for {} docs, fields={}", list.size(), identityFields);
for (JsonNode node : list) {
Identity id = new Identity(node, identityFields);
LOGGER.debug("ID={}", id);
map.put(id, node);
}
}
return map;
} | [
"public",
"static",
"Map",
"<",
"Identity",
",",
"JsonNode",
">",
"getDocumentIdMap",
"(",
"List",
"<",
"JsonNode",
">",
"list",
",",
"List",
"<",
"String",
">",
"identityFields",
")",
"{",
"Map",
"<",
"Identity",
",",
"JsonNode",
">",
"map",
"=",
"new",... | Build an id-doc map from a list of docs | [
"Build",
"an",
"id",
"-",
"doc",
"map",
"from",
"a",
"list",
"of",
"docs"
] | ec20748557b40d1f7851e1816d1b76dae48d2027 | https://github.com/lightblue-platform/lightblue-migrator/blob/ec20748557b40d1f7851e1816d1b76dae48d2027/migrator/src/main/java/com/redhat/lightblue/migrator/Utils.java#L76-L87 | train |
lightblue-platform/lightblue-migrator | migrator/src/main/java/com/redhat/lightblue/migrator/Utils.java | Utils.fastCompareDocs | public static boolean fastCompareDocs(JsonNode sourceDocument, JsonNode destinationDocument, List<String> exclusionPaths, boolean ignoreTimestampMSDiffs) {
try {
JsonDiff diff = new JsonDiff();
diff.setOption(JsonDiff.Option.ARRAY_ORDER_INSIGNIFICANT);
diff.setOption(JsonDiff.Option.RETURN_LEAVES_ONLY);
diff.setFilter(new AbstractFieldFilter() {
public boolean includeField(List<String> fieldName) {
return !fieldName.get(fieldName.size() - 1).endsWith("#");
}
});
List<JsonDelta> list = diff.computeDiff(sourceDocument, destinationDocument);
for (JsonDelta x : list) {
String field = x.getField();
if (!isExcluded(exclusionPaths, field)) {
if (reallyDifferent(x.getNode1(), x.getNode2(), ignoreTimestampMSDiffs)) {
return true;
}
}
}
} catch (Exception e) {
LOGGER.error("Cannot compare docs:{}", e, e);
}
return false;
} | java | public static boolean fastCompareDocs(JsonNode sourceDocument, JsonNode destinationDocument, List<String> exclusionPaths, boolean ignoreTimestampMSDiffs) {
try {
JsonDiff diff = new JsonDiff();
diff.setOption(JsonDiff.Option.ARRAY_ORDER_INSIGNIFICANT);
diff.setOption(JsonDiff.Option.RETURN_LEAVES_ONLY);
diff.setFilter(new AbstractFieldFilter() {
public boolean includeField(List<String> fieldName) {
return !fieldName.get(fieldName.size() - 1).endsWith("#");
}
});
List<JsonDelta> list = diff.computeDiff(sourceDocument, destinationDocument);
for (JsonDelta x : list) {
String field = x.getField();
if (!isExcluded(exclusionPaths, field)) {
if (reallyDifferent(x.getNode1(), x.getNode2(), ignoreTimestampMSDiffs)) {
return true;
}
}
}
} catch (Exception e) {
LOGGER.error("Cannot compare docs:{}", e, e);
}
return false;
} | [
"public",
"static",
"boolean",
"fastCompareDocs",
"(",
"JsonNode",
"sourceDocument",
",",
"JsonNode",
"destinationDocument",
",",
"List",
"<",
"String",
">",
"exclusionPaths",
",",
"boolean",
"ignoreTimestampMSDiffs",
")",
"{",
"try",
"{",
"JsonDiff",
"diff",
"=",
... | Compare two docs fast if they are the same, excluding exclusions
@return true if documents are different | [
"Compare",
"two",
"docs",
"fast",
"if",
"they",
"are",
"the",
"same",
"excluding",
"exclusions"
] | ec20748557b40d1f7851e1816d1b76dae48d2027 | https://github.com/lightblue-platform/lightblue-migrator/blob/ec20748557b40d1f7851e1816d1b76dae48d2027/migrator/src/main/java/com/redhat/lightblue/migrator/Utils.java#L132-L155 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocalHole.java | ODataLocalHole.createHole | public synchronized void createHole(final long iRecordOffset, final int iRecordSize) throws IOException {
final long timer = OProfiler.getInstance().startChrono();
// IN MEMORY
final int recycledPosition;
final ODataHoleInfo hole;
if (!freeHoles.isEmpty()) {
// RECYCLE THE FIRST FREE HOLE
recycledPosition = freeHoles.remove(0);
hole = availableHolesList.get(recycledPosition);
hole.dataOffset = iRecordOffset;
hole.size = iRecordSize;
} else {
// APPEND A NEW ONE
recycledPosition = getHoles();
hole = new ODataHoleInfo(iRecordSize, iRecordOffset, recycledPosition);
availableHolesList.add(hole);
file.allocateSpace(RECORD_SIZE);
}
availableHolesBySize.put(hole, hole);
availableHolesByPosition.put(hole, hole);
if (maxHoleSize < iRecordSize)
maxHoleSize = iRecordSize;
// TO FILE
final long p = recycledPosition * RECORD_SIZE;
file.writeLong(p, iRecordOffset);
file.writeInt(p + OBinaryProtocol.SIZE_LONG, iRecordSize);
OProfiler.getInstance().stopChrono(PROFILER_DATA_HOLE_CREATE, timer);
} | java | public synchronized void createHole(final long iRecordOffset, final int iRecordSize) throws IOException {
final long timer = OProfiler.getInstance().startChrono();
// IN MEMORY
final int recycledPosition;
final ODataHoleInfo hole;
if (!freeHoles.isEmpty()) {
// RECYCLE THE FIRST FREE HOLE
recycledPosition = freeHoles.remove(0);
hole = availableHolesList.get(recycledPosition);
hole.dataOffset = iRecordOffset;
hole.size = iRecordSize;
} else {
// APPEND A NEW ONE
recycledPosition = getHoles();
hole = new ODataHoleInfo(iRecordSize, iRecordOffset, recycledPosition);
availableHolesList.add(hole);
file.allocateSpace(RECORD_SIZE);
}
availableHolesBySize.put(hole, hole);
availableHolesByPosition.put(hole, hole);
if (maxHoleSize < iRecordSize)
maxHoleSize = iRecordSize;
// TO FILE
final long p = recycledPosition * RECORD_SIZE;
file.writeLong(p, iRecordOffset);
file.writeInt(p + OBinaryProtocol.SIZE_LONG, iRecordSize);
OProfiler.getInstance().stopChrono(PROFILER_DATA_HOLE_CREATE, timer);
} | [
"public",
"synchronized",
"void",
"createHole",
"(",
"final",
"long",
"iRecordOffset",
",",
"final",
"int",
"iRecordSize",
")",
"throws",
"IOException",
"{",
"final",
"long",
"timer",
"=",
"OProfiler",
".",
"getInstance",
"(",
")",
".",
"startChrono",
"(",
")"... | Appends the hole to the end of the segment.
@throws IOException | [
"Appends",
"the",
"hole",
"to",
"the",
"end",
"of",
"the",
"segment",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocalHole.java#L98-L130 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocalHole.java | ODataLocalHole.getHole | public synchronized ODataHoleInfo getHole(final int iPosition) {
final ODataHoleInfo hole = availableHolesList.get(iPosition);
if (hole.dataOffset == -1)
return null;
return hole;
} | java | public synchronized ODataHoleInfo getHole(final int iPosition) {
final ODataHoleInfo hole = availableHolesList.get(iPosition);
if (hole.dataOffset == -1)
return null;
return hole;
} | [
"public",
"synchronized",
"ODataHoleInfo",
"getHole",
"(",
"final",
"int",
"iPosition",
")",
"{",
"final",
"ODataHoleInfo",
"hole",
"=",
"availableHolesList",
".",
"get",
"(",
"iPosition",
")",
";",
"if",
"(",
"hole",
".",
"dataOffset",
"==",
"-",
"1",
")",
... | Fills the holes information into OPhysicalPosition object given as parameter.
@return true, if it's a valid hole, otherwise false
@throws IOException | [
"Fills",
"the",
"holes",
"information",
"into",
"OPhysicalPosition",
"object",
"given",
"as",
"parameter",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocalHole.java#L216-L221 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocalHole.java | ODataLocalHole.updateHole | public synchronized void updateHole(final ODataHoleInfo iHole, final long iNewDataOffset, final int iNewRecordSize)
throws IOException {
final long timer = OProfiler.getInstance().startChrono();
final boolean offsetChanged = iNewDataOffset != iHole.dataOffset;
final boolean sizeChanged = iNewRecordSize != iHole.size;
if (maxHoleSize < iNewRecordSize)
maxHoleSize = iNewRecordSize;
// IN MEMORY
if (offsetChanged)
availableHolesByPosition.remove(iHole);
if (sizeChanged)
availableHolesBySize.remove(iHole);
if (offsetChanged)
iHole.dataOffset = iNewDataOffset;
if (sizeChanged)
iHole.size = iNewRecordSize;
if (offsetChanged)
availableHolesByPosition.put(iHole, iHole);
if (sizeChanged)
availableHolesBySize.put(iHole, iHole);
// TO FILE
final long holePosition = iHole.holeOffset * RECORD_SIZE;
if (offsetChanged)
file.writeLong(holePosition, iNewDataOffset);
if (sizeChanged)
file.writeInt(holePosition + OBinaryProtocol.SIZE_LONG, iNewRecordSize);
OProfiler.getInstance().stopChrono(PROFILER_DATA_HOLE_UPDATE, timer);
} | java | public synchronized void updateHole(final ODataHoleInfo iHole, final long iNewDataOffset, final int iNewRecordSize)
throws IOException {
final long timer = OProfiler.getInstance().startChrono();
final boolean offsetChanged = iNewDataOffset != iHole.dataOffset;
final boolean sizeChanged = iNewRecordSize != iHole.size;
if (maxHoleSize < iNewRecordSize)
maxHoleSize = iNewRecordSize;
// IN MEMORY
if (offsetChanged)
availableHolesByPosition.remove(iHole);
if (sizeChanged)
availableHolesBySize.remove(iHole);
if (offsetChanged)
iHole.dataOffset = iNewDataOffset;
if (sizeChanged)
iHole.size = iNewRecordSize;
if (offsetChanged)
availableHolesByPosition.put(iHole, iHole);
if (sizeChanged)
availableHolesBySize.put(iHole, iHole);
// TO FILE
final long holePosition = iHole.holeOffset * RECORD_SIZE;
if (offsetChanged)
file.writeLong(holePosition, iNewDataOffset);
if (sizeChanged)
file.writeInt(holePosition + OBinaryProtocol.SIZE_LONG, iNewRecordSize);
OProfiler.getInstance().stopChrono(PROFILER_DATA_HOLE_UPDATE, timer);
} | [
"public",
"synchronized",
"void",
"updateHole",
"(",
"final",
"ODataHoleInfo",
"iHole",
",",
"final",
"long",
"iNewDataOffset",
",",
"final",
"int",
"iNewRecordSize",
")",
"throws",
"IOException",
"{",
"final",
"long",
"timer",
"=",
"OProfiler",
".",
"getInstance"... | Update hole data
@param iUpdateFromMemory
@throws IOException | [
"Update",
"hole",
"data"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocalHole.java#L230-L264 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocalHole.java | ODataLocalHole.deleteHole | public synchronized void deleteHole(int iHolePosition) throws IOException {
// IN MEMORY
final ODataHoleInfo hole = availableHolesList.get(iHolePosition);
availableHolesBySize.remove(hole);
availableHolesByPosition.remove(hole);
hole.dataOffset = -1;
freeHoles.add(iHolePosition);
// TO FILE
iHolePosition = iHolePosition * RECORD_SIZE;
file.writeLong(iHolePosition, -1);
} | java | public synchronized void deleteHole(int iHolePosition) throws IOException {
// IN MEMORY
final ODataHoleInfo hole = availableHolesList.get(iHolePosition);
availableHolesBySize.remove(hole);
availableHolesByPosition.remove(hole);
hole.dataOffset = -1;
freeHoles.add(iHolePosition);
// TO FILE
iHolePosition = iHolePosition * RECORD_SIZE;
file.writeLong(iHolePosition, -1);
} | [
"public",
"synchronized",
"void",
"deleteHole",
"(",
"int",
"iHolePosition",
")",
"throws",
"IOException",
"{",
"// IN MEMORY\r",
"final",
"ODataHoleInfo",
"hole",
"=",
"availableHolesList",
".",
"get",
"(",
"iHolePosition",
")",
";",
"availableHolesBySize",
".",
"r... | Delete the hole
@param iRemoveAlsoFromMemory
@throws IOException | [
"Delete",
"the",
"hole"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/ODataLocalHole.java#L273-L285 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/iterator/graph/OGraphElementIterator.java | OGraphElementIterator.getObject | protected T getObject() {
final T object;
if (reusedObject != null) {
// REUSE THE SAME RECORD AFTER HAVING RESETTED IT
object = reusedObject;
object.reset();
} else
// CREATE A NEW ONE
object = (T) database.newInstance(className);
return object;
} | java | protected T getObject() {
final T object;
if (reusedObject != null) {
// REUSE THE SAME RECORD AFTER HAVING RESETTED IT
object = reusedObject;
object.reset();
} else
// CREATE A NEW ONE
object = (T) database.newInstance(className);
return object;
} | [
"protected",
"T",
"getObject",
"(",
")",
"{",
"final",
"T",
"object",
";",
"if",
"(",
"reusedObject",
"!=",
"null",
")",
"{",
"// REUSE THE SAME RECORD AFTER HAVING RESETTED IT\r",
"object",
"=",
"reusedObject",
";",
"object",
".",
"reset",
"(",
")",
";",
"}",... | Returns the object to use for the operation.
@return | [
"Returns",
"the",
"object",
"to",
"use",
"for",
"the",
"operation",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/iterator/graph/OGraphElementIterator.java#L111-L121 | train |
loldevs/riotapi | xmpp/src/main/java/net/boreeas/xmpp/XmppClient.java | XmppClient.sha1 | @SneakyThrows(IOException.class)
public static String sha1(String input) throws NoSuchAlgorithmException {
MessageDigest mDigest = MessageDigest.getInstance("SHA1");
byte[] result = mDigest.digest(input.getBytes("UTF-8"));
String resultString = String.format("%040x", new BigInteger(1, result));
return resultString;
} | java | @SneakyThrows(IOException.class)
public static String sha1(String input) throws NoSuchAlgorithmException {
MessageDigest mDigest = MessageDigest.getInstance("SHA1");
byte[] result = mDigest.digest(input.getBytes("UTF-8"));
String resultString = String.format("%040x", new BigInteger(1, result));
return resultString;
} | [
"@",
"SneakyThrows",
"(",
"IOException",
".",
"class",
")",
"public",
"static",
"String",
"sha1",
"(",
"String",
"input",
")",
"throws",
"NoSuchAlgorithmException",
"{",
"MessageDigest",
"mDigest",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"SHA1\"",
")",
... | Calculates the SHA1 Digest of a given input.
@param input the input
@return the string
@throws NoSuchAlgorithmException the no such algorithm exception | [
"Calculates",
"the",
"SHA1",
"Digest",
"of",
"a",
"given",
"input",
"."
] | 0b8aac407aa5289845f249024f9732332855544f | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/xmpp/src/main/java/net/boreeas/xmpp/XmppClient.java#L151-L157 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/tx/OTransactionNoTx.java | OTransactionNoTx.saveRecord | public void saveRecord(final ORecordInternal<?> iRecord, final String iClusterName, final OPERATION_MODE iMode,
final ORecordCallback<? extends Number> iCallback) {
try {
database.executeSaveRecord(iRecord, iClusterName, iRecord.getVersion(), iRecord.getRecordType(), true, iMode, iCallback);
} catch (Exception e) {
// REMOVE IT FROM THE CACHE TO AVOID DIRTY RECORDS
final ORecordId rid = (ORecordId) iRecord.getIdentity();
if (rid.isValid())
database.getLevel1Cache().freeRecord(rid);
if (e instanceof RuntimeException)
throw (RuntimeException) e;
throw new OException(e);
}
} | java | public void saveRecord(final ORecordInternal<?> iRecord, final String iClusterName, final OPERATION_MODE iMode,
final ORecordCallback<? extends Number> iCallback) {
try {
database.executeSaveRecord(iRecord, iClusterName, iRecord.getVersion(), iRecord.getRecordType(), true, iMode, iCallback);
} catch (Exception e) {
// REMOVE IT FROM THE CACHE TO AVOID DIRTY RECORDS
final ORecordId rid = (ORecordId) iRecord.getIdentity();
if (rid.isValid())
database.getLevel1Cache().freeRecord(rid);
if (e instanceof RuntimeException)
throw (RuntimeException) e;
throw new OException(e);
}
} | [
"public",
"void",
"saveRecord",
"(",
"final",
"ORecordInternal",
"<",
"?",
">",
"iRecord",
",",
"final",
"String",
"iClusterName",
",",
"final",
"OPERATION_MODE",
"iMode",
",",
"final",
"ORecordCallback",
"<",
"?",
"extends",
"Number",
">",
"iCallback",
")",
"... | Update the record.
@param iCallback | [
"Update",
"the",
"record",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/tx/OTransactionNoTx.java#L69-L83 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/tx/OTransactionNoTx.java | OTransactionNoTx.deleteRecord | public void deleteRecord(final ORecordInternal<?> iRecord, final OPERATION_MODE iMode) {
if (!iRecord.getIdentity().isPersistent())
return;
try {
database.executeDeleteRecord(iRecord, iRecord.getVersion(), true, true, iMode);
} catch (Exception e) {
// REMOVE IT FROM THE CACHE TO AVOID DIRTY RECORDS
final ORecordId rid = (ORecordId) iRecord.getIdentity();
if (rid.isValid())
database.getLevel1Cache().freeRecord(rid);
if (e instanceof RuntimeException)
throw (RuntimeException) e;
throw new OException(e);
}
} | java | public void deleteRecord(final ORecordInternal<?> iRecord, final OPERATION_MODE iMode) {
if (!iRecord.getIdentity().isPersistent())
return;
try {
database.executeDeleteRecord(iRecord, iRecord.getVersion(), true, true, iMode);
} catch (Exception e) {
// REMOVE IT FROM THE CACHE TO AVOID DIRTY RECORDS
final ORecordId rid = (ORecordId) iRecord.getIdentity();
if (rid.isValid())
database.getLevel1Cache().freeRecord(rid);
if (e instanceof RuntimeException)
throw (RuntimeException) e;
throw new OException(e);
}
} | [
"public",
"void",
"deleteRecord",
"(",
"final",
"ORecordInternal",
"<",
"?",
">",
"iRecord",
",",
"final",
"OPERATION_MODE",
"iMode",
")",
"{",
"if",
"(",
"!",
"iRecord",
".",
"getIdentity",
"(",
")",
".",
"isPersistent",
"(",
")",
")",
"return",
";",
"t... | Deletes the record. | [
"Deletes",
"the",
"record",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/tx/OTransactionNoTx.java#L88-L104 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java | OCommandRequestTextAbstract.execute | @SuppressWarnings("unchecked")
public <RET> RET execute(final Object... iArgs) {
setParameters(iArgs);
return (RET) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().command(this);
} | java | @SuppressWarnings("unchecked")
public <RET> RET execute(final Object... iArgs) {
setParameters(iArgs);
return (RET) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().command(this);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"RET",
">",
"RET",
"execute",
"(",
"final",
"Object",
"...",
"iArgs",
")",
"{",
"setParameters",
"(",
"iArgs",
")",
";",
"return",
"(",
"RET",
")",
"ODatabaseRecordThreadLocal",
".",
"INSTANC... | Delegates the execution to the configured command executor. | [
"Delegates",
"the",
"execution",
"to",
"the",
"configured",
"command",
"executor",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java#L57-L61 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/index/OIndexMVRBTreeAbstract.java | OIndexMVRBTreeAbstract.getEntriesBetween | public Collection<ODocument> getEntriesBetween(final Object iRangeFrom, final Object iRangeTo) {
return getEntriesBetween(iRangeFrom, iRangeTo, true);
} | java | public Collection<ODocument> getEntriesBetween(final Object iRangeFrom, final Object iRangeTo) {
return getEntriesBetween(iRangeFrom, iRangeTo, true);
} | [
"public",
"Collection",
"<",
"ODocument",
">",
"getEntriesBetween",
"(",
"final",
"Object",
"iRangeFrom",
",",
"final",
"Object",
"iRangeTo",
")",
"{",
"return",
"getEntriesBetween",
"(",
"iRangeFrom",
",",
"iRangeTo",
",",
"true",
")",
";",
"}"
] | Returns a set of documents with key between the range passed as parameter. Range bounds are included.
@param iRangeFrom
Starting range
@param iRangeTo
Ending range
@see #getEntriesBetween(Object, Object, boolean)
@return | [
"Returns",
"a",
"set",
"of",
"documents",
"with",
"key",
"between",
"the",
"range",
"passed",
"as",
"parameter",
".",
"Range",
"bounds",
"are",
"included",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/index/OIndexMVRBTreeAbstract.java#L287-L289 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/index/OIndexMVRBTreeAbstract.java | OIndexMVRBTreeAbstract.rebuild | public long rebuild(final OProgressListener iProgressListener) {
long documentIndexed = 0;
final boolean intentInstalled = getDatabase().declareIntent(new OIntentMassiveInsert());
acquireExclusiveLock();
try {
try {
map.clear();
} catch (Exception e) {
// IGNORE EXCEPTION: IF THE REBUILD WAS LAUNCHED IN CASE OF RID INVALID CLEAR ALWAYS GOES IN ERROR
}
int documentNum = 0;
long documentTotal = 0;
for (final String cluster : clustersToIndex)
documentTotal += getDatabase().countClusterElements(cluster);
if (iProgressListener != null)
iProgressListener.onBegin(this, documentTotal);
for (final String clusterName : clustersToIndex)
try {
for (final ORecord<?> record : getDatabase().browseCluster(clusterName)) {
if (record instanceof ODocument) {
final ODocument doc = (ODocument) record;
if (indexDefinition == null)
throw new OConfigurationException("Index '" + name + "' cannot be rebuilt because has no a valid definition ("
+ indexDefinition + ")");
final Object fieldValue = indexDefinition.getDocumentValueToIndex(doc);
if (fieldValue != null) {
if (fieldValue instanceof Collection) {
for (final Object fieldValueItem : (Collection<?>) fieldValue) {
put(fieldValueItem, doc);
}
} else
put(fieldValue, doc);
++documentIndexed;
}
}
documentNum++;
if (iProgressListener != null)
iProgressListener.onProgress(this, documentNum, documentNum * 100f / documentTotal);
}
} catch (NoSuchElementException e) {
// END OF CLUSTER REACHED, IGNORE IT
}
lazySave();
if (iProgressListener != null)
iProgressListener.onCompletition(this, true);
} catch (final Exception e) {
if (iProgressListener != null)
iProgressListener.onCompletition(this, false);
try {
map.clear();
} catch (Exception e2) {
// IGNORE EXCEPTION: IF THE REBUILD WAS LAUNCHED IN CASE OF RID INVALID CLEAR ALWAYS GOES IN ERROR
}
throw new OIndexException("Error on rebuilding the index for clusters: " + clustersToIndex, e);
} finally {
if (intentInstalled)
getDatabase().declareIntent(null);
releaseExclusiveLock();
}
return documentIndexed;
} | java | public long rebuild(final OProgressListener iProgressListener) {
long documentIndexed = 0;
final boolean intentInstalled = getDatabase().declareIntent(new OIntentMassiveInsert());
acquireExclusiveLock();
try {
try {
map.clear();
} catch (Exception e) {
// IGNORE EXCEPTION: IF THE REBUILD WAS LAUNCHED IN CASE OF RID INVALID CLEAR ALWAYS GOES IN ERROR
}
int documentNum = 0;
long documentTotal = 0;
for (final String cluster : clustersToIndex)
documentTotal += getDatabase().countClusterElements(cluster);
if (iProgressListener != null)
iProgressListener.onBegin(this, documentTotal);
for (final String clusterName : clustersToIndex)
try {
for (final ORecord<?> record : getDatabase().browseCluster(clusterName)) {
if (record instanceof ODocument) {
final ODocument doc = (ODocument) record;
if (indexDefinition == null)
throw new OConfigurationException("Index '" + name + "' cannot be rebuilt because has no a valid definition ("
+ indexDefinition + ")");
final Object fieldValue = indexDefinition.getDocumentValueToIndex(doc);
if (fieldValue != null) {
if (fieldValue instanceof Collection) {
for (final Object fieldValueItem : (Collection<?>) fieldValue) {
put(fieldValueItem, doc);
}
} else
put(fieldValue, doc);
++documentIndexed;
}
}
documentNum++;
if (iProgressListener != null)
iProgressListener.onProgress(this, documentNum, documentNum * 100f / documentTotal);
}
} catch (NoSuchElementException e) {
// END OF CLUSTER REACHED, IGNORE IT
}
lazySave();
if (iProgressListener != null)
iProgressListener.onCompletition(this, true);
} catch (final Exception e) {
if (iProgressListener != null)
iProgressListener.onCompletition(this, false);
try {
map.clear();
} catch (Exception e2) {
// IGNORE EXCEPTION: IF THE REBUILD WAS LAUNCHED IN CASE OF RID INVALID CLEAR ALWAYS GOES IN ERROR
}
throw new OIndexException("Error on rebuilding the index for clusters: " + clustersToIndex, e);
} finally {
if (intentInstalled)
getDatabase().declareIntent(null);
releaseExclusiveLock();
}
return documentIndexed;
} | [
"public",
"long",
"rebuild",
"(",
"final",
"OProgressListener",
"iProgressListener",
")",
"{",
"long",
"documentIndexed",
"=",
"0",
";",
"final",
"boolean",
"intentInstalled",
"=",
"getDatabase",
"(",
")",
".",
"declareIntent",
"(",
"new",
"OIntentMassiveInsert",
... | Populates the index with all the existent records. Uses the massive insert intent to speed up and keep the consumed memory low. | [
"Populates",
"the",
"index",
"with",
"all",
"the",
"existent",
"records",
".",
"Uses",
"the",
"massive",
"insert",
"intent",
"to",
"speed",
"up",
"and",
"keep",
"the",
"consumed",
"memory",
"low",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/index/OIndexMVRBTreeAbstract.java#L351-L430 | train |
wuman/orientdb-android | enterprise/src/main/java/com/orientechnologies/orient/enterprise/channel/binary/OChannelBinaryClient.java | OChannelBinaryClient.isConnected | public boolean isConnected() {
if (socket != null && socket.isConnected() && !socket.isInputShutdown() && !socket.isOutputShutdown())
return true;
return false;
} | java | public boolean isConnected() {
if (socket != null && socket.isConnected() && !socket.isInputShutdown() && !socket.isOutputShutdown())
return true;
return false;
} | [
"public",
"boolean",
"isConnected",
"(",
")",
"{",
"if",
"(",
"socket",
"!=",
"null",
"&&",
"socket",
".",
"isConnected",
"(",
")",
"&&",
"!",
"socket",
".",
"isInputShutdown",
"(",
")",
"&&",
"!",
"socket",
".",
"isOutputShutdown",
"(",
")",
")",
"ret... | Tells if the channel is connected.
@return true if it's connected, otherwise false. | [
"Tells",
"if",
"the",
"channel",
"is",
"connected",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/enterprise/src/main/java/com/orientechnologies/orient/enterprise/channel/binary/OChannelBinaryClient.java#L88-L92 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectProxyMethodHandler.java | OObjectProxyMethodHandler.detach | public void detach(Object self) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
for (String fieldName : doc.fieldNames()) {
Object value = getValue(self, fieldName, false, null);
if (value instanceof OLazyObjectMultivalueElement)
((OLazyObjectMultivalueElement) value).detach();
OObjectEntitySerializer.setFieldValue(getField(fieldName, self.getClass()), self, value);
}
OObjectEntitySerializer.setIdField(self.getClass(), self, doc.getIdentity());
OObjectEntitySerializer.setVersionField(self.getClass(), self, doc.getVersion());
} | java | public void detach(Object self) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
for (String fieldName : doc.fieldNames()) {
Object value = getValue(self, fieldName, false, null);
if (value instanceof OLazyObjectMultivalueElement)
((OLazyObjectMultivalueElement) value).detach();
OObjectEntitySerializer.setFieldValue(getField(fieldName, self.getClass()), self, value);
}
OObjectEntitySerializer.setIdField(self.getClass(), self, doc.getIdentity());
OObjectEntitySerializer.setVersionField(self.getClass(), self, doc.getVersion());
} | [
"public",
"void",
"detach",
"(",
"Object",
"self",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"for",
"(",
"String",
"fieldName",
":",
"doc",
".",
"fieldNames",
"(",
")",
")",
"{",
"Object",
"valu... | Method that detaches all fields contained in the document to the given object
@param self
:- The object containing this handler instance
@throws InvocationTargetException
@throws IllegalAccessException
@throws NoSuchMethodException | [
"Method",
"that",
"detaches",
"all",
"fields",
"contained",
"in",
"the",
"document",
"to",
"the",
"given",
"object"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectProxyMethodHandler.java#L110-L119 | train |
wuman/orientdb-android | object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectProxyMethodHandler.java | OObjectProxyMethodHandler.attach | public void attach(Object self) throws IllegalArgumentException, IllegalAccessException, NoSuchMethodException,
InvocationTargetException {
for (Class<?> currentClass = self.getClass(); currentClass != Object.class;) {
if (Proxy.class.isAssignableFrom(currentClass)) {
currentClass = currentClass.getSuperclass();
continue;
}
for (Field f : currentClass.getDeclaredFields()) {
Object value = OObjectEntitySerializer.getFieldValue(f, self);
value = setValue(self, f.getName(), value);
OObjectEntitySerializer.setFieldValue(f, self, value);
}
currentClass = currentClass.getSuperclass();
if (currentClass == null || currentClass.equals(ODocument.class))
// POJO EXTENDS ODOCUMENT: SPECIAL CASE: AVOID TO CONSIDER
// ODOCUMENT FIELDS
currentClass = Object.class;
}
} | java | public void attach(Object self) throws IllegalArgumentException, IllegalAccessException, NoSuchMethodException,
InvocationTargetException {
for (Class<?> currentClass = self.getClass(); currentClass != Object.class;) {
if (Proxy.class.isAssignableFrom(currentClass)) {
currentClass = currentClass.getSuperclass();
continue;
}
for (Field f : currentClass.getDeclaredFields()) {
Object value = OObjectEntitySerializer.getFieldValue(f, self);
value = setValue(self, f.getName(), value);
OObjectEntitySerializer.setFieldValue(f, self, value);
}
currentClass = currentClass.getSuperclass();
if (currentClass == null || currentClass.equals(ODocument.class))
// POJO EXTENDS ODOCUMENT: SPECIAL CASE: AVOID TO CONSIDER
// ODOCUMENT FIELDS
currentClass = Object.class;
}
} | [
"public",
"void",
"attach",
"(",
"Object",
"self",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalAccessException",
",",
"NoSuchMethodException",
",",
"InvocationTargetException",
"{",
"for",
"(",
"Class",
"<",
"?",
">",
"currentClass",
"=",
"self",
".",
... | Method that attaches all data contained in the object to the associated document
@param self
:- The object containing this handler instance
@throws IllegalAccessException
@throws IllegalArgumentException
@throws InvocationTargetException
@throws NoSuchMethodException | [
"Method",
"that",
"attaches",
"all",
"data",
"contained",
"in",
"the",
"object",
"to",
"the",
"associated",
"document"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectProxyMethodHandler.java#L132-L151 | train |
Putnami/putnami-web-toolkit | core/src/main/java/fr/putnami/pwt/core/theme/client/DefaultIE8ThemeController.java | DefaultIE8ThemeController.ensureRespondJsScriptElement | private void ensureRespondJsScriptElement() {
if (this.respondJsScript == null) {
this.respondJsScript = Document.get().createScriptElement();
this.respondJsScript.setSrc(GWT.getModuleBaseForStaticFiles() + DefaultIE8ThemeController.RESPOND_JS_LOCATION);
this.respondJsScript.setType("text/javascript");
}
} | java | private void ensureRespondJsScriptElement() {
if (this.respondJsScript == null) {
this.respondJsScript = Document.get().createScriptElement();
this.respondJsScript.setSrc(GWT.getModuleBaseForStaticFiles() + DefaultIE8ThemeController.RESPOND_JS_LOCATION);
this.respondJsScript.setType("text/javascript");
}
} | [
"private",
"void",
"ensureRespondJsScriptElement",
"(",
")",
"{",
"if",
"(",
"this",
".",
"respondJsScript",
"==",
"null",
")",
"{",
"this",
".",
"respondJsScript",
"=",
"Document",
".",
"get",
"(",
")",
".",
"createScriptElement",
"(",
")",
";",
"this",
"... | Ensure respond js script element. | [
"Ensure",
"respond",
"js",
"script",
"element",
"."
] | 129aa781d1bda508e579d194693ca3034b4d470b | https://github.com/Putnami/putnami-web-toolkit/blob/129aa781d1bda508e579d194693ca3034b4d470b/core/src/main/java/fr/putnami/pwt/core/theme/client/DefaultIE8ThemeController.java#L50-L56 | train |
NetsOSS/embedded-jetty | src/main/java/eu/nets/oss/jetty/EmbeddedSpringWsBuilder.java | EmbeddedSpringWsBuilder.createMessageDispatcherServlet | public static MessageDispatcherServlet createMessageDispatcherServlet(Class... contextConfigLocation) {
StringBuilder items = new StringBuilder();
for (Class aClass : contextConfigLocation) {
items.append( aClass.getName());
items.append(",");
}
MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
messageDispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);
messageDispatcherServlet.setContextConfigLocation(removeEnd(items.toString(), "," ));
messageDispatcherServlet.setTransformWsdlLocations(true);
return messageDispatcherServlet;
} | java | public static MessageDispatcherServlet createMessageDispatcherServlet(Class... contextConfigLocation) {
StringBuilder items = new StringBuilder();
for (Class aClass : contextConfigLocation) {
items.append( aClass.getName());
items.append(",");
}
MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
messageDispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);
messageDispatcherServlet.setContextConfigLocation(removeEnd(items.toString(), "," ));
messageDispatcherServlet.setTransformWsdlLocations(true);
return messageDispatcherServlet;
} | [
"public",
"static",
"MessageDispatcherServlet",
"createMessageDispatcherServlet",
"(",
"Class",
"...",
"contextConfigLocation",
")",
"{",
"StringBuilder",
"items",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Class",
"aClass",
":",
"contextConfigLocation",
... | Creates a spring-ws message dispatcher servlet
@param contextConfigLocation The spring configuration classes
@return A message dispatcher servlet based on the supplied configuration | [
"Creates",
"a",
"spring",
"-",
"ws",
"message",
"dispatcher",
"servlet"
] | c2535867ad4887c4a43a8aa7f95b711ff54c8542 | https://github.com/NetsOSS/embedded-jetty/blob/c2535867ad4887c4a43a8aa7f95b711ff54c8542/src/main/java/eu/nets/oss/jetty/EmbeddedSpringWsBuilder.java#L20-L31 | train |
amsa-code/risky | ais/src/main/java/au/gov/amsa/ais/Communications.java | Communications.getReceivedStations | @VisibleForTesting
static Integer getReceivedStations(AisExtractor extractor, int slotTimeout,
int startIndex) {
if (slotTimeout == 3 || slotTimeout == 5 || slotTimeout == 7)
return extractor.getValue(startIndex + 5, startIndex + 19);
else
return null;
} | java | @VisibleForTesting
static Integer getReceivedStations(AisExtractor extractor, int slotTimeout,
int startIndex) {
if (slotTimeout == 3 || slotTimeout == 5 || slotTimeout == 7)
return extractor.getValue(startIndex + 5, startIndex + 19);
else
return null;
} | [
"@",
"VisibleForTesting",
"static",
"Integer",
"getReceivedStations",
"(",
"AisExtractor",
"extractor",
",",
"int",
"slotTimeout",
",",
"int",
"startIndex",
")",
"{",
"if",
"(",
"slotTimeout",
"==",
"3",
"||",
"slotTimeout",
"==",
"5",
"||",
"slotTimeout",
"==",... | Returns received stations as per 1371-4.pdf.
@param extractor
@param slotTimeout
@param startIndex
@return | [
"Returns",
"received",
"stations",
"as",
"per",
"1371",
"-",
"4",
".",
"pdf",
"."
] | 13649942aeddfdb9210eec072c605bc5d7a6daf3 | https://github.com/amsa-code/risky/blob/13649942aeddfdb9210eec072c605bc5d7a6daf3/ais/src/main/java/au/gov/amsa/ais/Communications.java#L48-L55 | train |
amsa-code/risky | ais/src/main/java/au/gov/amsa/ais/Communications.java | Communications.getHourUtc | private static Integer getHourUtc(AisExtractor extractor, int slotTimeout,
int startIndex) {
if (slotTimeout == 1) {
// skip the msb bit
int hours = extractor.getValue(startIndex + 5, startIndex + 10);
return hours;
} else
return null;
} | java | private static Integer getHourUtc(AisExtractor extractor, int slotTimeout,
int startIndex) {
if (slotTimeout == 1) {
// skip the msb bit
int hours = extractor.getValue(startIndex + 5, startIndex + 10);
return hours;
} else
return null;
} | [
"private",
"static",
"Integer",
"getHourUtc",
"(",
"AisExtractor",
"extractor",
",",
"int",
"slotTimeout",
",",
"int",
"startIndex",
")",
"{",
"if",
"(",
"slotTimeout",
"==",
"1",
")",
"{",
"// skip the msb bit",
"int",
"hours",
"=",
"extractor",
".",
"getValu... | Returns hour UTC as per 1371-4.pdf.
@param extractor
@param slotTimeout
@param startIndex
@return | [
"Returns",
"hour",
"UTC",
"as",
"per",
"1371",
"-",
"4",
".",
"pdf",
"."
] | 13649942aeddfdb9210eec072c605bc5d7a6daf3 | https://github.com/amsa-code/risky/blob/13649942aeddfdb9210eec072c605bc5d7a6daf3/ais/src/main/java/au/gov/amsa/ais/Communications.java#L82-L90 | train |
amsa-code/risky | ais/src/main/java/au/gov/amsa/ais/Communications.java | Communications.getMinuteUtc | private static Integer getMinuteUtc(AisExtractor extractor,
int slotTimeout, int startIndex) {
if (slotTimeout == 1) {
// skip the msb bit
int minutes = extractor.getValue(startIndex + 10, startIndex + 17);
return minutes;
} else
return null;
} | java | private static Integer getMinuteUtc(AisExtractor extractor,
int slotTimeout, int startIndex) {
if (slotTimeout == 1) {
// skip the msb bit
int minutes = extractor.getValue(startIndex + 10, startIndex + 17);
return minutes;
} else
return null;
} | [
"private",
"static",
"Integer",
"getMinuteUtc",
"(",
"AisExtractor",
"extractor",
",",
"int",
"slotTimeout",
",",
"int",
"startIndex",
")",
"{",
"if",
"(",
"slotTimeout",
"==",
"1",
")",
"{",
"// skip the msb bit",
"int",
"minutes",
"=",
"extractor",
".",
"get... | Returns minute UTC as per 1371-4.pdf.
@param extractor
@param slotTimeout
@param startIndex
@return | [
"Returns",
"minute",
"UTC",
"as",
"per",
"1371",
"-",
"4",
".",
"pdf",
"."
] | 13649942aeddfdb9210eec072c605bc5d7a6daf3 | https://github.com/amsa-code/risky/blob/13649942aeddfdb9210eec072c605bc5d7a6daf3/ais/src/main/java/au/gov/amsa/ais/Communications.java#L100-L108 | train |
amsa-code/risky | ais/src/main/java/au/gov/amsa/ais/Communications.java | Communications.getSlotOffset | private static Integer getSlotOffset(AisExtractor extractor,
int slotTimeout, int startIndex) {
if (slotTimeout == 0)
return extractor.getValue(startIndex + 5, startIndex + 19);
else
return null;
} | java | private static Integer getSlotOffset(AisExtractor extractor,
int slotTimeout, int startIndex) {
if (slotTimeout == 0)
return extractor.getValue(startIndex + 5, startIndex + 19);
else
return null;
} | [
"private",
"static",
"Integer",
"getSlotOffset",
"(",
"AisExtractor",
"extractor",
",",
"int",
"slotTimeout",
",",
"int",
"startIndex",
")",
"{",
"if",
"(",
"slotTimeout",
"==",
"0",
")",
"return",
"extractor",
".",
"getValue",
"(",
"startIndex",
"+",
"5",
"... | Returns slot offset as per 1371-4.pdf.
@param extractor
@param slotTimeout
@param startIndex
@return | [
"Returns",
"slot",
"offset",
"as",
"per",
"1371",
"-",
"4",
".",
"pdf",
"."
] | 13649942aeddfdb9210eec072c605bc5d7a6daf3 | https://github.com/amsa-code/risky/blob/13649942aeddfdb9210eec072c605bc5d7a6daf3/ais/src/main/java/au/gov/amsa/ais/Communications.java#L118-L124 | train |
amsa-code/risky | ais/src/main/java/au/gov/amsa/ais/AisExtractor.java | AisExtractor.getValue | public synchronized int getValue(int from, int to) {
try {
// is synchronized so that values of bitSet and calculated can be
// lazily
// calculated and safely published (thread safe).
SixBit.convertSixBitToBits(message, padBits, bitSet, calculated, from, to);
return (int) SixBit.getValue(from, to, bitSet);
} catch (SixBitException | ArrayIndexOutOfBoundsException e) {
throw new AisParseException(e);
}
} | java | public synchronized int getValue(int from, int to) {
try {
// is synchronized so that values of bitSet and calculated can be
// lazily
// calculated and safely published (thread safe).
SixBit.convertSixBitToBits(message, padBits, bitSet, calculated, from, to);
return (int) SixBit.getValue(from, to, bitSet);
} catch (SixBitException | ArrayIndexOutOfBoundsException e) {
throw new AisParseException(e);
}
} | [
"public",
"synchronized",
"int",
"getValue",
"(",
"int",
"from",
",",
"int",
"to",
")",
"{",
"try",
"{",
"// is synchronized so that values of bitSet and calculated can be",
"// lazily",
"// calculated and safely published (thread safe).",
"SixBit",
".",
"convertSixBitToBits",
... | Returns an unsigned integer value using the bits from character position
start to position stop in the decoded message.
@param from
@param to
@return | [
"Returns",
"an",
"unsigned",
"integer",
"value",
"using",
"the",
"bits",
"from",
"character",
"position",
"start",
"to",
"position",
"stop",
"in",
"the",
"decoded",
"message",
"."
] | 13649942aeddfdb9210eec072c605bc5d7a6daf3 | https://github.com/amsa-code/risky/blob/13649942aeddfdb9210eec072c605bc5d7a6daf3/ais/src/main/java/au/gov/amsa/ais/AisExtractor.java#L62-L72 | train |
amsa-code/risky | ais/src/main/java/au/gov/amsa/ais/AisExtractor.java | AisExtractor.getSignedValue | public synchronized int getSignedValue(int from, int to) {
try {
// is synchronized so that values of bitSet and calculated can be
// lazily
// calculated and safely published (thread safe).
SixBit.convertSixBitToBits(message, padBits, bitSet, calculated, from, to);
return (int) SixBit.getSignedValue(from, to, bitSet);
} catch (SixBitException e) {
throw new AisParseException(e);
}
} | java | public synchronized int getSignedValue(int from, int to) {
try {
// is synchronized so that values of bitSet and calculated can be
// lazily
// calculated and safely published (thread safe).
SixBit.convertSixBitToBits(message, padBits, bitSet, calculated, from, to);
return (int) SixBit.getSignedValue(from, to, bitSet);
} catch (SixBitException e) {
throw new AisParseException(e);
}
} | [
"public",
"synchronized",
"int",
"getSignedValue",
"(",
"int",
"from",
",",
"int",
"to",
")",
"{",
"try",
"{",
"// is synchronized so that values of bitSet and calculated can be",
"// lazily",
"// calculated and safely published (thread safe).",
"SixBit",
".",
"convertSixBitToB... | Returns a signed integer value using the bits from character position
start to position stop in the decoded message.
@param from
@param to
@return | [
"Returns",
"a",
"signed",
"integer",
"value",
"using",
"the",
"bits",
"from",
"character",
"position",
"start",
"to",
"position",
"stop",
"in",
"the",
"decoded",
"message",
"."
] | 13649942aeddfdb9210eec072c605bc5d7a6daf3 | https://github.com/amsa-code/risky/blob/13649942aeddfdb9210eec072c605bc5d7a6daf3/ais/src/main/java/au/gov/amsa/ais/AisExtractor.java#L82-L92 | train |
wealthfront/kawala | kawala-common/src/main/java/com/kaching/platform/common/reflect/ReflectUtils.java | ReflectUtils.getField | public static Object getField(Object obj, String name) {
try {
Class<? extends Object> klass = obj.getClass();
do {
try {
Field field = klass.getDeclaredField(name);
field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException e) {
klass = klass.getSuperclass();
}
} while (klass != null);
throw new RuntimeException(); // true no such field exception
} catch (SecurityException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java | public static Object getField(Object obj, String name) {
try {
Class<? extends Object> klass = obj.getClass();
do {
try {
Field field = klass.getDeclaredField(name);
field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException e) {
klass = klass.getSuperclass();
}
} while (klass != null);
throw new RuntimeException(); // true no such field exception
} catch (SecurityException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"Object",
"getField",
"(",
"Object",
"obj",
",",
"String",
"name",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
"extends",
"Object",
">",
"klass",
"=",
"obj",
".",
"getClass",
"(",
")",
";",
"do",
"{",
"try",
"{",
"Field",
"field",
... | Gets a field from an object.
@param obj object from which to read the field
@param name the field name to read | [
"Gets",
"a",
"field",
"from",
"an",
"object",
"."
] | acf24b7a9ef6e2f0fc1e862d44cfa4dcc4da8f6e | https://github.com/wealthfront/kawala/blob/acf24b7a9ef6e2f0fc1e862d44cfa4dcc4da8f6e/kawala-common/src/main/java/com/kaching/platform/common/reflect/ReflectUtils.java#L30-L50 | train |
amsa-code/risky | geo-analyzer/src/main/java/au/gov/amsa/util/navigation/Position.java | Position.getDistanceToKm | public final double getDistanceToKm(Position position) {
double lat1 = toRadians(lat);
double lat2 = toRadians(position.lat);
double lon1 = toRadians(lon);
double lon2 = toRadians(position.lon);
double deltaLon = lon2 - lon1;
double cosLat2 = cos(lat2);
double cosLat1 = cos(lat1);
double sinLat1 = sin(lat1);
double sinLat2 = sin(lat2);
double cosDeltaLon = cos(deltaLon);
double top = sqrt(sqr(cosLat2 * sin(deltaLon))
+ sqr(cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon));
double bottom = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
double distance = radiusEarthKm * atan2(top, bottom);
return abs(distance);
} | java | public final double getDistanceToKm(Position position) {
double lat1 = toRadians(lat);
double lat2 = toRadians(position.lat);
double lon1 = toRadians(lon);
double lon2 = toRadians(position.lon);
double deltaLon = lon2 - lon1;
double cosLat2 = cos(lat2);
double cosLat1 = cos(lat1);
double sinLat1 = sin(lat1);
double sinLat2 = sin(lat2);
double cosDeltaLon = cos(deltaLon);
double top = sqrt(sqr(cosLat2 * sin(deltaLon))
+ sqr(cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon));
double bottom = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
double distance = radiusEarthKm * atan2(top, bottom);
return abs(distance);
} | [
"public",
"final",
"double",
"getDistanceToKm",
"(",
"Position",
"position",
")",
"{",
"double",
"lat1",
"=",
"toRadians",
"(",
"lat",
")",
";",
"double",
"lat2",
"=",
"toRadians",
"(",
"position",
".",
"lat",
")",
";",
"double",
"lon1",
"=",
"toRadians",
... | returns distance between two WGS84 positions according to Vincenty's
formula from Wikipedia
@param position
@return | [
"returns",
"distance",
"between",
"two",
"WGS84",
"positions",
"according",
"to",
"Vincenty",
"s",
"formula",
"from",
"Wikipedia"
] | 13649942aeddfdb9210eec072c605bc5d7a6daf3 | https://github.com/amsa-code/risky/blob/13649942aeddfdb9210eec072c605bc5d7a6daf3/geo-analyzer/src/main/java/au/gov/amsa/util/navigation/Position.java#L270-L286 | train |
amsa-code/risky | geo-analyzer/src/main/java/au/gov/amsa/util/navigation/Position.java | Position.getDistanceKmToPath | public final double getDistanceKmToPath(Position p1, Position p2) {
double d = radiusEarthKm
* asin(sin(getDistanceToKm(p1) / radiusEarthKm)
* sin(toRadians(getBearingDegrees(p1)
- p1.getBearingDegrees(p2))));
return abs(d);
} | java | public final double getDistanceKmToPath(Position p1, Position p2) {
double d = radiusEarthKm
* asin(sin(getDistanceToKm(p1) / radiusEarthKm)
* sin(toRadians(getBearingDegrees(p1)
- p1.getBearingDegrees(p2))));
return abs(d);
} | [
"public",
"final",
"double",
"getDistanceKmToPath",
"(",
"Position",
"p1",
",",
"Position",
"p2",
")",
"{",
"double",
"d",
"=",
"radiusEarthKm",
"*",
"asin",
"(",
"sin",
"(",
"getDistanceToKm",
"(",
"p1",
")",
"/",
"radiusEarthKm",
")",
"*",
"sin",
"(",
... | calculates the distance of a point to the great circle path between p1
and p2.
Formula from: http://www.movable-type.co.uk/scripts/latlong.html
@param p1
@param p2
@return | [
"calculates",
"the",
"distance",
"of",
"a",
"point",
"to",
"the",
"great",
"circle",
"path",
"between",
"p1",
"and",
"p2",
"."
] | 13649942aeddfdb9210eec072c605bc5d7a6daf3 | https://github.com/amsa-code/risky/blob/13649942aeddfdb9210eec072c605bc5d7a6daf3/geo-analyzer/src/main/java/au/gov/amsa/util/navigation/Position.java#L341-L347 | train |
soi-toolkit/soi-toolkit-mule | tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/model/ModelFactory.java | ModelFactory.setModelClass | @SuppressWarnings("unchecked")
public static void setModelClass(Class<?> modelClass) throws IllegalArgumentException {
if (!DefaultModelImpl.class.isAssignableFrom(modelClass)) {
throw new IllegalArgumentException("Modelclass, " + modelClass.getName() + ", is not a subtype of " + DefaultModelImpl.class.getName());
}
ModelFactory.modelClass = (Class<DefaultModelImpl>)modelClass;
} | java | @SuppressWarnings("unchecked")
public static void setModelClass(Class<?> modelClass) throws IllegalArgumentException {
if (!DefaultModelImpl.class.isAssignableFrom(modelClass)) {
throw new IllegalArgumentException("Modelclass, " + modelClass.getName() + ", is not a subtype of " + DefaultModelImpl.class.getName());
}
ModelFactory.modelClass = (Class<DefaultModelImpl>)modelClass;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"void",
"setModelClass",
"(",
"Class",
"<",
"?",
">",
"modelClass",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"!",
"DefaultModelImpl",
".",
"class",
".",
"isAssignableFrom",
... | Register a custom model class, must be a subclass to DefaultModelImpl.
@param modelClass
@throws IllegalArgumentException if supplied class is not a subclass of DefaultModelImpl | [
"Register",
"a",
"custom",
"model",
"class",
"must",
"be",
"a",
"subclass",
"to",
"DefaultModelImpl",
"."
] | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/model/ModelFactory.java#L49-L55 | train |
soi-toolkit/soi-toolkit-mule | tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/model/ModelFactory.java | ModelFactory.resetModelClass | public static void resetModelClass() {
ModelFactory.modelClass = DefaultModelImpl.class;
System.err.println("[INFO] Reset model-class: " + ModelFactory.modelClass.getName());
} | java | public static void resetModelClass() {
ModelFactory.modelClass = DefaultModelImpl.class;
System.err.println("[INFO] Reset model-class: " + ModelFactory.modelClass.getName());
} | [
"public",
"static",
"void",
"resetModelClass",
"(",
")",
"{",
"ModelFactory",
".",
"modelClass",
"=",
"DefaultModelImpl",
".",
"class",
";",
"System",
".",
"err",
".",
"println",
"(",
"\"[INFO] Reset model-class: \"",
"+",
"ModelFactory",
".",
"modelClass",
".",
... | Reset model class to the default class.
@param modelClass
@throws IllegalArgumentException if supplied class is not a subclass of DefaultModelImpl | [
"Reset",
"model",
"class",
"to",
"the",
"default",
"class",
"."
] | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/model/ModelFactory.java#L81-L84 | train |
soi-toolkit/soi-toolkit-mule | tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/model/ModelFactory.java | ModelFactory.newModel | public static IModel newModel(String groupId, String artifactId, String version, String service, MuleVersionEnum muleVersion, TransportEnum inboundTransport, TransportEnum outboundTransport, TransformerEnum transformerType) {
return doCreateNewModel(groupId, artifactId, version, service, muleVersion, null, null, inboundTransport, outboundTransport, transformerType, null, null);
} | java | public static IModel newModel(String groupId, String artifactId, String version, String service, MuleVersionEnum muleVersion, TransportEnum inboundTransport, TransportEnum outboundTransport, TransformerEnum transformerType) {
return doCreateNewModel(groupId, artifactId, version, service, muleVersion, null, null, inboundTransport, outboundTransport, transformerType, null, null);
} | [
"public",
"static",
"IModel",
"newModel",
"(",
"String",
"groupId",
",",
"String",
"artifactId",
",",
"String",
"version",
",",
"String",
"service",
",",
"MuleVersionEnum",
"muleVersion",
",",
"TransportEnum",
"inboundTransport",
",",
"TransportEnum",
"outboundTranspo... | Constructor-method to use when services with inbound and outbound services
@param groupId
@param artifactId
@param version
@param service
@return the new model instance | [
"Constructor",
"-",
"method",
"to",
"use",
"when",
"services",
"with",
"inbound",
"and",
"outbound",
"services"
] | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/model/ModelFactory.java#L95-L97 | train |
wuman/orientdb-android | nativeos/src/main/java/com/orientechnologies/nio/MemoryLocker.java | MemoryLocker.lockMemory | public static void lockMemory(boolean useSystemJNADisabled) {
if (useSystemJNADisabled)
disableUsingSystemJNA();
try {
int errorCode = MemoryLockerLinux.INSTANCE.mlockall(MemoryLockerLinux.LOCK_CURRENT_MEMORY);
if (errorCode != 0) {
final String errorMessage;
int lastError = Native.getLastError();
switch (lastError) {
case MemoryLockerLinux.EPERM:
errorMessage = "The calling process does not have the appropriate privilege to perform the requested operation(EPERM).";
break;
case MemoryLockerLinux.EAGAIN:
errorMessage = "Some or all of the memory identified by the operation could not be locked when the call was made(EAGAIN).";
break;
case MemoryLockerLinux.ENOMEM:
errorMessage = "Unable to lock JVM memory. This can result in part of the JVM being swapped out, especially if mmapping of files enabled. Increase RLIMIT_MEMLOCK or run OrientDB server as root(ENOMEM).";
break;
case MemoryLockerLinux.EINVAL:
errorMessage = "The flags argument is zero, or includes unimplemented flags(EINVAL).";
break;
case MemoryLockerLinux.ENOSYS:
errorMessage = "The implementation does not support this memory locking interface(ENOSYS).";
break;
default:
errorMessage = "Unexpected exception with code " + lastError + ".";
break;
}
OLogManager.instance().error(null, "[MemoryLocker.lockMemory] Error occurred while locking memory: %s", errorMessage);
} else {
OLogManager.instance().info(null, "[MemoryLocker.lockMemory] Memory locked successfully!");
}
} catch (UnsatisfiedLinkError e) {
OLogManager.instance().config(null,
"[MemoryLocker.lockMemory] Cannot lock virtual memory. It seems that you OS (%s) doesn't support this feature",
System.getProperty("os.name"));
}
} | java | public static void lockMemory(boolean useSystemJNADisabled) {
if (useSystemJNADisabled)
disableUsingSystemJNA();
try {
int errorCode = MemoryLockerLinux.INSTANCE.mlockall(MemoryLockerLinux.LOCK_CURRENT_MEMORY);
if (errorCode != 0) {
final String errorMessage;
int lastError = Native.getLastError();
switch (lastError) {
case MemoryLockerLinux.EPERM:
errorMessage = "The calling process does not have the appropriate privilege to perform the requested operation(EPERM).";
break;
case MemoryLockerLinux.EAGAIN:
errorMessage = "Some or all of the memory identified by the operation could not be locked when the call was made(EAGAIN).";
break;
case MemoryLockerLinux.ENOMEM:
errorMessage = "Unable to lock JVM memory. This can result in part of the JVM being swapped out, especially if mmapping of files enabled. Increase RLIMIT_MEMLOCK or run OrientDB server as root(ENOMEM).";
break;
case MemoryLockerLinux.EINVAL:
errorMessage = "The flags argument is zero, or includes unimplemented flags(EINVAL).";
break;
case MemoryLockerLinux.ENOSYS:
errorMessage = "The implementation does not support this memory locking interface(ENOSYS).";
break;
default:
errorMessage = "Unexpected exception with code " + lastError + ".";
break;
}
OLogManager.instance().error(null, "[MemoryLocker.lockMemory] Error occurred while locking memory: %s", errorMessage);
} else {
OLogManager.instance().info(null, "[MemoryLocker.lockMemory] Memory locked successfully!");
}
} catch (UnsatisfiedLinkError e) {
OLogManager.instance().config(null,
"[MemoryLocker.lockMemory] Cannot lock virtual memory. It seems that you OS (%s) doesn't support this feature",
System.getProperty("os.name"));
}
} | [
"public",
"static",
"void",
"lockMemory",
"(",
"boolean",
"useSystemJNADisabled",
")",
"{",
"if",
"(",
"useSystemJNADisabled",
")",
"disableUsingSystemJNA",
"(",
")",
";",
"try",
"{",
"int",
"errorCode",
"=",
"MemoryLockerLinux",
".",
"INSTANCE",
".",
"mlockall",
... | This method locks memory to prevent swapping. This method provide information about success or problems with locking memory.
You can reed console output to know if memory locked successfully or not. If system error occurred such as permission any
specific exception will be thrown.
@param useSystemJNADisabled
if this parameter is true only bundled JNA will be used. | [
"This",
"method",
"locks",
"memory",
"to",
"prevent",
"swapping",
".",
"This",
"method",
"provide",
"information",
"about",
"success",
"or",
"problems",
"with",
"locking",
"memory",
".",
"You",
"can",
"reed",
"console",
"output",
"to",
"know",
"if",
"memory",
... | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/nativeos/src/main/java/com/orientechnologies/nio/MemoryLocker.java#L61-L101 | train |
wuman/orientdb-android | commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java | OMVRBTreeEntry.getFirstInMemory | public OMVRBTreeEntry<K, V> getFirstInMemory() {
OMVRBTreeEntry<K, V> node = this;
OMVRBTreeEntry<K, V> prev = this;
while (node != null) {
prev = node;
node = node.getPreviousInMemory();
}
return prev;
} | java | public OMVRBTreeEntry<K, V> getFirstInMemory() {
OMVRBTreeEntry<K, V> node = this;
OMVRBTreeEntry<K, V> prev = this;
while (node != null) {
prev = node;
node = node.getPreviousInMemory();
}
return prev;
} | [
"public",
"OMVRBTreeEntry",
"<",
"K",
",",
"V",
">",
"getFirstInMemory",
"(",
")",
"{",
"OMVRBTreeEntry",
"<",
"K",
",",
"V",
">",
"node",
"=",
"this",
";",
"OMVRBTreeEntry",
"<",
"K",
",",
"V",
">",
"prev",
"=",
"this",
";",
"while",
"(",
"node",
... | Returns the first Entry only by traversing the memory, or null if no such. | [
"Returns",
"the",
"first",
"Entry",
"only",
"by",
"traversing",
"the",
"memory",
"or",
"null",
"if",
"no",
"such",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java#L59-L69 | train |
wuman/orientdb-android | commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java | OMVRBTreeEntry.getPreviousInMemory | public OMVRBTreeEntry<K, V> getPreviousInMemory() {
OMVRBTreeEntry<K, V> t = this;
OMVRBTreeEntry<K, V> p = null;
if (t.getLeftInMemory() != null) {
p = t.getLeftInMemory();
while (p.getRightInMemory() != null)
p = p.getRightInMemory();
} else {
p = t.getParentInMemory();
while (p != null && t == p.getLeftInMemory()) {
t = p;
p = p.getParentInMemory();
}
}
return p;
} | java | public OMVRBTreeEntry<K, V> getPreviousInMemory() {
OMVRBTreeEntry<K, V> t = this;
OMVRBTreeEntry<K, V> p = null;
if (t.getLeftInMemory() != null) {
p = t.getLeftInMemory();
while (p.getRightInMemory() != null)
p = p.getRightInMemory();
} else {
p = t.getParentInMemory();
while (p != null && t == p.getLeftInMemory()) {
t = p;
p = p.getParentInMemory();
}
}
return p;
} | [
"public",
"OMVRBTreeEntry",
"<",
"K",
",",
"V",
">",
"getPreviousInMemory",
"(",
")",
"{",
"OMVRBTreeEntry",
"<",
"K",
",",
"V",
">",
"t",
"=",
"this",
";",
"OMVRBTreeEntry",
"<",
"K",
",",
"V",
">",
"p",
"=",
"null",
";",
"if",
"(",
"t",
".",
"g... | Returns the previous of the current Entry only by traversing the memory, or null if no such. | [
"Returns",
"the",
"previous",
"of",
"the",
"current",
"Entry",
"only",
"by",
"traversing",
"the",
"memory",
"or",
"null",
"if",
"no",
"such",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java#L74-L91 | train |
wuman/orientdb-android | commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java | OMVRBTreeEntry.linearSearch | private V linearSearch(final K iKey) {
V value = null;
int i = 0;
tree.pageItemComparator = -1;
for (int s = getSize(); i < s; ++i) {
if (tree.comparator != null)
tree.pageItemComparator = tree.comparator.compare(getKeyAt(i), iKey);
else
tree.pageItemComparator = ((Comparable<? super K>) getKeyAt(i)).compareTo(iKey);
if (tree.pageItemComparator == 0) {
// FOUND: SET THE INDEX AND RETURN THE NODE
tree.pageItemFound = true;
value = getValueAt(i);
break;
} else if (tree.pageItemComparator > 0)
break;
}
tree.pageIndex = i;
return value;
} | java | private V linearSearch(final K iKey) {
V value = null;
int i = 0;
tree.pageItemComparator = -1;
for (int s = getSize(); i < s; ++i) {
if (tree.comparator != null)
tree.pageItemComparator = tree.comparator.compare(getKeyAt(i), iKey);
else
tree.pageItemComparator = ((Comparable<? super K>) getKeyAt(i)).compareTo(iKey);
if (tree.pageItemComparator == 0) {
// FOUND: SET THE INDEX AND RETURN THE NODE
tree.pageItemFound = true;
value = getValueAt(i);
break;
} else if (tree.pageItemComparator > 0)
break;
}
tree.pageIndex = i;
return value;
} | [
"private",
"V",
"linearSearch",
"(",
"final",
"K",
"iKey",
")",
"{",
"V",
"value",
"=",
"null",
";",
"int",
"i",
"=",
"0",
";",
"tree",
".",
"pageItemComparator",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"s",
"=",
"getSize",
"(",
")",
";",
"i",
"... | Linear search inside the node
@param iKey
Key to search
@return Value if found, otherwise null and the tree.pageIndex updated with the closest-after-first position valid for further
inserts. | [
"Linear",
"search",
"inside",
"the",
"node"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java#L208-L230 | train |
wuman/orientdb-android | commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java | OMVRBTreeEntry.binarySearch | private V binarySearch(final K iKey) {
int low = 0;
int high = getSize() - 1;
int mid = 0;
while (low <= high) {
mid = (low + high) >>> 1;
Object midVal = getKeyAt(mid);
if (tree.comparator != null)
tree.pageItemComparator = tree.comparator.compare((K) midVal, iKey);
else
tree.pageItemComparator = ((Comparable<? super K>) midVal).compareTo(iKey);
if (tree.pageItemComparator == 0) {
// FOUND: SET THE INDEX AND RETURN THE NODE
tree.pageItemFound = true;
tree.pageIndex = mid;
return getValueAt(tree.pageIndex);
}
if (low == high)
break;
if (tree.pageItemComparator < 0)
low = mid + 1;
else
high = mid;
}
tree.pageIndex = mid;
return null;
} | java | private V binarySearch(final K iKey) {
int low = 0;
int high = getSize() - 1;
int mid = 0;
while (low <= high) {
mid = (low + high) >>> 1;
Object midVal = getKeyAt(mid);
if (tree.comparator != null)
tree.pageItemComparator = tree.comparator.compare((K) midVal, iKey);
else
tree.pageItemComparator = ((Comparable<? super K>) midVal).compareTo(iKey);
if (tree.pageItemComparator == 0) {
// FOUND: SET THE INDEX AND RETURN THE NODE
tree.pageItemFound = true;
tree.pageIndex = mid;
return getValueAt(tree.pageIndex);
}
if (low == high)
break;
if (tree.pageItemComparator < 0)
low = mid + 1;
else
high = mid;
}
tree.pageIndex = mid;
return null;
} | [
"private",
"V",
"binarySearch",
"(",
"final",
"K",
"iKey",
")",
"{",
"int",
"low",
"=",
"0",
";",
"int",
"high",
"=",
"getSize",
"(",
")",
"-",
"1",
";",
"int",
"mid",
"=",
"0",
";",
"while",
"(",
"low",
"<=",
"high",
")",
"{",
"mid",
"=",
"(... | Binary search inside the node
@param iKey
Key to search
@return Value if found, otherwise null and the tree.pageIndex updated with the closest-after-first position valid for further
inserts. | [
"Binary",
"search",
"inside",
"the",
"node"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java#L240-L272 | train |
wuman/orientdb-android | commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java | OMVRBTreeEntry.compareTo | public int compareTo(final OMVRBTreeEntry<K, V> o) {
if (o == null)
return 1;
if (o == this)
return 0;
if (getSize() == 0)
return -1;
if (o.getSize() == 0)
return 1;
if (tree.comparator != null)
return tree.comparator.compare(getFirstKey(), o.getFirstKey());
return ((Comparable<K>) getFirstKey()).compareTo(o.getFirstKey());
} | java | public int compareTo(final OMVRBTreeEntry<K, V> o) {
if (o == null)
return 1;
if (o == this)
return 0;
if (getSize() == 0)
return -1;
if (o.getSize() == 0)
return 1;
if (tree.comparator != null)
return tree.comparator.compare(getFirstKey(), o.getFirstKey());
return ((Comparable<K>) getFirstKey()).compareTo(o.getFirstKey());
} | [
"public",
"int",
"compareTo",
"(",
"final",
"OMVRBTreeEntry",
"<",
"K",
",",
"V",
">",
"o",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"return",
"1",
";",
"if",
"(",
"o",
"==",
"this",
")",
"return",
"0",
";",
"if",
"(",
"getSize",
"(",
")",
... | Compares two nodes by their first keys. | [
"Compares",
"two",
"nodes",
"by",
"their",
"first",
"keys",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/commons/src/main/java/com/orientechnologies/common/collection/OMVRBTreeEntry.java#L307-L320 | train |
lightblue-platform/lightblue-migrator | migrator/src/main/java/com/redhat/lightblue/migrator/ConsistencyCheckerController.java | ConsistencyCheckerController.parsePeriod | public static long parsePeriod(String periodStr) {
PeriodFormatter fmt = PeriodFormat.getDefault();
Period p = fmt.parsePeriod(periodStr);
return p.toStandardDuration().getMillis();
} | java | public static long parsePeriod(String periodStr) {
PeriodFormatter fmt = PeriodFormat.getDefault();
Period p = fmt.parsePeriod(periodStr);
return p.toStandardDuration().getMillis();
} | [
"public",
"static",
"long",
"parsePeriod",
"(",
"String",
"periodStr",
")",
"{",
"PeriodFormatter",
"fmt",
"=",
"PeriodFormat",
".",
"getDefault",
"(",
")",
";",
"Period",
"p",
"=",
"fmt",
".",
"parsePeriod",
"(",
"periodStr",
")",
";",
"return",
"p",
".",... | Returns the period in msecs | [
"Returns",
"the",
"period",
"in",
"msecs"
] | ec20748557b40d1f7851e1816d1b76dae48d2027 | https://github.com/lightblue-platform/lightblue-migrator/blob/ec20748557b40d1f7851e1816d1b76dae48d2027/migrator/src/main/java/com/redhat/lightblue/migrator/ConsistencyCheckerController.java#L55-L59 | train |
lightblue-platform/lightblue-migrator | migrator/src/main/java/com/redhat/lightblue/migrator/ConsistencyCheckerController.java | ConsistencyCheckerController.getEndDate | public Date getEndDate(Date startDate, long period) {
long now = getNow().getTime();
long endDate = startDate.getTime() + period;
if (now - period > endDate) {
return new Date(endDate);
} else {
return null;
}
} | java | public Date getEndDate(Date startDate, long period) {
long now = getNow().getTime();
long endDate = startDate.getTime() + period;
if (now - period > endDate) {
return new Date(endDate);
} else {
return null;
}
} | [
"public",
"Date",
"getEndDate",
"(",
"Date",
"startDate",
",",
"long",
"period",
")",
"{",
"long",
"now",
"=",
"getNow",
"(",
")",
".",
"getTime",
"(",
")",
";",
"long",
"endDate",
"=",
"startDate",
".",
"getTime",
"(",
")",
"+",
"period",
";",
"if",... | Returns the end date given the start date end the period. The end date is
startDate+period, but only if endDate is at least one period ago. That
is, we always leave the last incomplete period unprocessed.
Override this to control the job generation algorithm | [
"Returns",
"the",
"end",
"date",
"given",
"the",
"start",
"date",
"end",
"the",
"period",
".",
"The",
"end",
"date",
"is",
"startDate",
"+",
"period",
"but",
"only",
"if",
"endDate",
"is",
"at",
"least",
"one",
"period",
"ago",
".",
"That",
"is",
"we",... | ec20748557b40d1f7851e1816d1b76dae48d2027 | https://github.com/lightblue-platform/lightblue-migrator/blob/ec20748557b40d1f7851e1816d1b76dae48d2027/migrator/src/main/java/com/redhat/lightblue/migrator/ConsistencyCheckerController.java#L68-L76 | train |
lightblue-platform/lightblue-migrator | migrator/src/main/java/com/redhat/lightblue/migrator/ConsistencyCheckerController.java | ConsistencyCheckerController.createJobs | protected List<MigrationJob> createJobs(Date startDate, Date endDate, ActiveExecution ae) throws Exception {
List<MigrationJob> ret = new ArrayList<MigrationJob>();
LOGGER.debug("Creating the migrator to setup new jobs");
// We setup a new migration job
MigrationJob mj = new MigrationJob();
mj.setConfigurationName(getMigrationConfiguration().getConfigurationName());
mj.setScheduledDate(getNow());
mj.setGenerated(true);
mj.setStatus(MigrationJob.STATE_AVAILABLE);
mj.setConsistencyChecker(new MigrationJob.ConsistencyChecker());
mj.getConsistencyChecker().setJobRangeBegin(ClientConstants.getDateFormat().format(startDate));
mj.getConsistencyChecker().setJobRangeEnd(ClientConstants.getDateFormat().format(endDate));
mj.getConsistencyChecker().setConfigurationName(mj.getConfigurationName());
Migrator migrator = createMigrator(mj, ae);
mj.setQuery(migrator.createRangeQuery(startDate, endDate));
// At this point, mj.query contains the range query
LOGGER.debug("Migration job query:{}", mj.getQuery());
ret.add(mj);
return ret;
} | java | protected List<MigrationJob> createJobs(Date startDate, Date endDate, ActiveExecution ae) throws Exception {
List<MigrationJob> ret = new ArrayList<MigrationJob>();
LOGGER.debug("Creating the migrator to setup new jobs");
// We setup a new migration job
MigrationJob mj = new MigrationJob();
mj.setConfigurationName(getMigrationConfiguration().getConfigurationName());
mj.setScheduledDate(getNow());
mj.setGenerated(true);
mj.setStatus(MigrationJob.STATE_AVAILABLE);
mj.setConsistencyChecker(new MigrationJob.ConsistencyChecker());
mj.getConsistencyChecker().setJobRangeBegin(ClientConstants.getDateFormat().format(startDate));
mj.getConsistencyChecker().setJobRangeEnd(ClientConstants.getDateFormat().format(endDate));
mj.getConsistencyChecker().setConfigurationName(mj.getConfigurationName());
Migrator migrator = createMigrator(mj, ae);
mj.setQuery(migrator.createRangeQuery(startDate, endDate));
// At this point, mj.query contains the range query
LOGGER.debug("Migration job query:{}", mj.getQuery());
ret.add(mj);
return ret;
} | [
"protected",
"List",
"<",
"MigrationJob",
">",
"createJobs",
"(",
"Date",
"startDate",
",",
"Date",
"endDate",
",",
"ActiveExecution",
"ae",
")",
"throws",
"Exception",
"{",
"List",
"<",
"MigrationJob",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"MigrationJob",... | Create a migration job or jobs to process records created between the
given dates. startDate is inclusive, end date is exclusive | [
"Create",
"a",
"migration",
"job",
"or",
"jobs",
"to",
"process",
"records",
"created",
"between",
"the",
"given",
"dates",
".",
"startDate",
"is",
"inclusive",
"end",
"date",
"is",
"exclusive"
] | ec20748557b40d1f7851e1816d1b76dae48d2027 | https://github.com/lightblue-platform/lightblue-migrator/blob/ec20748557b40d1f7851e1816d1b76dae48d2027/migrator/src/main/java/com/redhat/lightblue/migrator/ConsistencyCheckerController.java#L90-L109 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java | OMMapManagerNew.searchAmongExisting | private OMMapBufferEntry[] searchAmongExisting(OFileMMap file, final OMMapBufferEntry[] fileEntries, final long beginOffset,
final int size) {
if (fileEntries.length == 0) {
return EMPTY_BUFFER_ENTRIES;
}
final OMMapBufferEntry lastEntry = fileEntries[fileEntries.length - 1];
if (lastEntry.beginOffset + lastEntry.size <= beginOffset) {
return EMPTY_BUFFER_ENTRIES;
}
final LastMMapEntrySearchInfo entrySearchInfo = mapEntrySearchInfo.get(file);
final int beginSearchPosition;
final int endSearchPosition;
if (entrySearchInfo == null) {
beginSearchPosition = 0;
endSearchPosition = fileEntries.length - 1;
} else {
if (entrySearchInfo.requestedPosition <= beginOffset) {
beginSearchPosition = entrySearchInfo.foundMmapIndex;
endSearchPosition = fileEntries.length - 1;
} else {
beginSearchPosition = 0;
endSearchPosition = entrySearchInfo.foundMmapIndex;
}
}
final int resultFirstPosition;
if (endSearchPosition - beginSearchPosition > BINARY_SEARCH_THRESHOLD)
resultFirstPosition = binarySearch(fileEntries, beginOffset, beginSearchPosition, endSearchPosition);
else
resultFirstPosition = linearSearch(fileEntries, beginOffset, beginSearchPosition, endSearchPosition);
if (beginSearchPosition < 0)
return EMPTY_BUFFER_ENTRIES;
int resultLastPosition = fileEntries.length - 1;
for (int i = resultFirstPosition; i <= resultLastPosition; i++) {
final OMMapBufferEntry entry = fileEntries[i];
if (entry.beginOffset + entry.size >= beginOffset + size) {
resultLastPosition = i;
break;
}
}
final int length = resultLastPosition - resultFirstPosition + 1;
final OMMapBufferEntry[] foundEntries = new OMMapBufferEntry[length];
if (length > 0) {
System.arraycopy(fileEntries, resultFirstPosition, foundEntries, 0, length);
mapEntrySearchInfo.put(file, new LastMMapEntrySearchInfo(resultFirstPosition, beginOffset));
}
return foundEntries;
} | java | private OMMapBufferEntry[] searchAmongExisting(OFileMMap file, final OMMapBufferEntry[] fileEntries, final long beginOffset,
final int size) {
if (fileEntries.length == 0) {
return EMPTY_BUFFER_ENTRIES;
}
final OMMapBufferEntry lastEntry = fileEntries[fileEntries.length - 1];
if (lastEntry.beginOffset + lastEntry.size <= beginOffset) {
return EMPTY_BUFFER_ENTRIES;
}
final LastMMapEntrySearchInfo entrySearchInfo = mapEntrySearchInfo.get(file);
final int beginSearchPosition;
final int endSearchPosition;
if (entrySearchInfo == null) {
beginSearchPosition = 0;
endSearchPosition = fileEntries.length - 1;
} else {
if (entrySearchInfo.requestedPosition <= beginOffset) {
beginSearchPosition = entrySearchInfo.foundMmapIndex;
endSearchPosition = fileEntries.length - 1;
} else {
beginSearchPosition = 0;
endSearchPosition = entrySearchInfo.foundMmapIndex;
}
}
final int resultFirstPosition;
if (endSearchPosition - beginSearchPosition > BINARY_SEARCH_THRESHOLD)
resultFirstPosition = binarySearch(fileEntries, beginOffset, beginSearchPosition, endSearchPosition);
else
resultFirstPosition = linearSearch(fileEntries, beginOffset, beginSearchPosition, endSearchPosition);
if (beginSearchPosition < 0)
return EMPTY_BUFFER_ENTRIES;
int resultLastPosition = fileEntries.length - 1;
for (int i = resultFirstPosition; i <= resultLastPosition; i++) {
final OMMapBufferEntry entry = fileEntries[i];
if (entry.beginOffset + entry.size >= beginOffset + size) {
resultLastPosition = i;
break;
}
}
final int length = resultLastPosition - resultFirstPosition + 1;
final OMMapBufferEntry[] foundEntries = new OMMapBufferEntry[length];
if (length > 0) {
System.arraycopy(fileEntries, resultFirstPosition, foundEntries, 0, length);
mapEntrySearchInfo.put(file, new LastMMapEntrySearchInfo(resultFirstPosition, beginOffset));
}
return foundEntries;
} | [
"private",
"OMMapBufferEntry",
"[",
"]",
"searchAmongExisting",
"(",
"OFileMMap",
"file",
",",
"final",
"OMMapBufferEntry",
"[",
"]",
"fileEntries",
",",
"final",
"long",
"beginOffset",
",",
"final",
"int",
"size",
")",
"{",
"if",
"(",
"fileEntries",
".",
"len... | This method search in already mapped entries to find if necessary entry is already mapped and can be returned.
@param file
to search mapped entry for it.
@param fileEntries
already mapped entries.
@param beginOffset
position in file that should be mmaped.
@param size
size that should be mmaped.
@return {@code EMPTY_BUFFER_ENTRIES} if nothing found or found entries otherwise. | [
"This",
"method",
"search",
"in",
"already",
"mapped",
"entries",
"to",
"find",
"if",
"necessary",
"entry",
"is",
"already",
"mapped",
"and",
"can",
"be",
"returned",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java#L188-L245 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java | OMMapManagerNew.mapNew | private OMMapBufferEntry mapNew(final OFileMMap file, final long beginOffset) throws IOException {
return new OMMapBufferEntry(file, file.map(beginOffset, file.getFileSize() - (int) beginOffset), beginOffset,
file.getFileSize() - (int) beginOffset);
} | java | private OMMapBufferEntry mapNew(final OFileMMap file, final long beginOffset) throws IOException {
return new OMMapBufferEntry(file, file.map(beginOffset, file.getFileSize() - (int) beginOffset), beginOffset,
file.getFileSize() - (int) beginOffset);
} | [
"private",
"OMMapBufferEntry",
"mapNew",
"(",
"final",
"OFileMMap",
"file",
",",
"final",
"long",
"beginOffset",
")",
"throws",
"IOException",
"{",
"return",
"new",
"OMMapBufferEntry",
"(",
"file",
",",
"file",
".",
"map",
"(",
"beginOffset",
",",
"file",
".",... | This method maps new part of file if not all file content is mapped.
@param file
that will be mapped.
@param beginOffset
position in file from what mapping should be applied.
@return mapped entry.
@throws IOException
is thrown if mapping is unsuccessfully. | [
"This",
"method",
"maps",
"new",
"part",
"of",
"file",
"if",
"not",
"all",
"file",
"content",
"is",
"mapped",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java#L328-L331 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java | OMMapManagerNew.acquireLocksOnEntries | private void acquireLocksOnEntries(final OMMapBufferEntry[] entries, OPERATION_TYPE operationType) {
if (operationType == OPERATION_TYPE.WRITE)
for (OMMapBufferEntry entry : entries) {
entry.acquireWriteLock();
entry.setDirty();
}
else
for (OMMapBufferEntry entry : entries)
entry.acquireReadLock();
} | java | private void acquireLocksOnEntries(final OMMapBufferEntry[] entries, OPERATION_TYPE operationType) {
if (operationType == OPERATION_TYPE.WRITE)
for (OMMapBufferEntry entry : entries) {
entry.acquireWriteLock();
entry.setDirty();
}
else
for (OMMapBufferEntry entry : entries)
entry.acquireReadLock();
} | [
"private",
"void",
"acquireLocksOnEntries",
"(",
"final",
"OMMapBufferEntry",
"[",
"]",
"entries",
",",
"OPERATION_TYPE",
"operationType",
")",
"{",
"if",
"(",
"operationType",
"==",
"OPERATION_TYPE",
".",
"WRITE",
")",
"for",
"(",
"OMMapBufferEntry",
"entry",
":"... | Locks all entries.
@param entries
that will be locked.
@param operationType
determine read or write lock will be performed. | [
"Locks",
"all",
"entries",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java#L348-L357 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java | OMMapManagerNew.removeFileEntries | private void removeFileEntries(OMMapBufferEntry[] fileEntries) {
if (fileEntries != null) {
for (OMMapBufferEntry entry : fileEntries) {
removeEntry(entry);
}
}
} | java | private void removeFileEntries(OMMapBufferEntry[] fileEntries) {
if (fileEntries != null) {
for (OMMapBufferEntry entry : fileEntries) {
removeEntry(entry);
}
}
} | [
"private",
"void",
"removeFileEntries",
"(",
"OMMapBufferEntry",
"[",
"]",
"fileEntries",
")",
"{",
"if",
"(",
"fileEntries",
"!=",
"null",
")",
"{",
"for",
"(",
"OMMapBufferEntry",
"entry",
":",
"fileEntries",
")",
"{",
"removeEntry",
"(",
"entry",
")",
";"... | Removes all files entries. Flush will be performed before removing.
@param fileEntries
that will be removed. | [
"Removes",
"all",
"files",
"entries",
".",
"Flush",
"will",
"be",
"performed",
"before",
"removing",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OMMapManagerNew.java#L394-L400 | train |
soi-toolkit/soi-toolkit-mule | tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/util/FileUtil.java | FileUtil.getRelativePath | public static String getRelativePath(File file, File srcDir) {
String base = srcDir.getPath();
String filePath = file.getPath();
String relativePath = new File(base).toURI()
.relativize(new File(filePath).toURI()).getPath();
return relativePath;
} | java | public static String getRelativePath(File file, File srcDir) {
String base = srcDir.getPath();
String filePath = file.getPath();
String relativePath = new File(base).toURI()
.relativize(new File(filePath).toURI()).getPath();
return relativePath;
} | [
"public",
"static",
"String",
"getRelativePath",
"(",
"File",
"file",
",",
"File",
"srcDir",
")",
"{",
"String",
"base",
"=",
"srcDir",
".",
"getPath",
"(",
")",
";",
"String",
"filePath",
"=",
"file",
".",
"getPath",
"(",
")",
";",
"String",
"relativePa... | Returns the relative path.
@param file
@param srcDir
@return the relative path | [
"Returns",
"the",
"relative",
"path",
"."
] | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/util/FileUtil.java#L63-L71 | train |
soi-toolkit/soi-toolkit-mule | tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/util/FileUtil.java | FileUtil.copyFile | public static void copyFile(File srcFile, File destFile) {
OutputStream out = null;
InputStream in = null;
try {
if (!destFile.getParentFile().exists())
destFile.getParentFile().mkdirs();
in = new FileInputStream(srcFile);
out = new FileOutputStream(destFile);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
} | java | public static void copyFile(File srcFile, File destFile) {
OutputStream out = null;
InputStream in = null;
try {
if (!destFile.getParentFile().exists())
destFile.getParentFile().mkdirs();
in = new FileInputStream(srcFile);
out = new FileOutputStream(destFile);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"void",
"copyFile",
"(",
"File",
"srcFile",
",",
"File",
"destFile",
")",
"{",
"OutputStream",
"out",
"=",
"null",
";",
"InputStream",
"in",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"!",
"destFile",
".",
"getParentFile",
"(",
")",
"... | Copy a file to new destination.
@param srcFile
@param destFile | [
"Copy",
"a",
"file",
"to",
"new",
"destination",
"."
] | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/tools/soitoolkit-generator/soitoolkit-generator/src/main/java/org/soitoolkit/tools/generator/util/FileUtil.java#L79-L100 | train |
NetsOSS/embedded-jetty | src/main/java/eu/nets/oss/jetty/EmbeddedSpringBuilder.java | EmbeddedSpringBuilder.createSpringContextLoader | public static ContextLoaderListener createSpringContextLoader(final WebApplicationContext webApplicationContext) {
return new ContextLoaderListener() {
@SuppressWarnings("unchecked")
@Override
protected WebApplicationContext createWebApplicationContext(ServletContext sc) {
return webApplicationContext;
}
};
} | java | public static ContextLoaderListener createSpringContextLoader(final WebApplicationContext webApplicationContext) {
return new ContextLoaderListener() {
@SuppressWarnings("unchecked")
@Override
protected WebApplicationContext createWebApplicationContext(ServletContext sc) {
return webApplicationContext;
}
};
} | [
"public",
"static",
"ContextLoaderListener",
"createSpringContextLoader",
"(",
"final",
"WebApplicationContext",
"webApplicationContext",
")",
"{",
"return",
"new",
"ContextLoaderListener",
"(",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override"... | Creates a spring context loader listener
@param webApplicationContext The web application context to use
@return A context loader listener that can be used when starting jetty | [
"Creates",
"a",
"spring",
"context",
"loader",
"listener"
] | c2535867ad4887c4a43a8aa7f95b711ff54c8542 | https://github.com/NetsOSS/embedded-jetty/blob/c2535867ad4887c4a43a8aa7f95b711ff54c8542/src/main/java/eu/nets/oss/jetty/EmbeddedSpringBuilder.java#L25-L33 | train |
lightblue-platform/lightblue-migrator | migrator/src/main/java/com/redhat/lightblue/migrator/Identity.java | Identity.getFieldValue | public static JsonNode getFieldValue(JsonNode doc, String field) {
StringTokenizer tkz = new StringTokenizer(field, ". ");
JsonNode trc = doc;
while (tkz.hasMoreTokens() && trc != null) {
String tok = tkz.nextToken();
trc = trc.get(tok);
}
return trc;
} | java | public static JsonNode getFieldValue(JsonNode doc, String field) {
StringTokenizer tkz = new StringTokenizer(field, ". ");
JsonNode trc = doc;
while (tkz.hasMoreTokens() && trc != null) {
String tok = tkz.nextToken();
trc = trc.get(tok);
}
return trc;
} | [
"public",
"static",
"JsonNode",
"getFieldValue",
"(",
"JsonNode",
"doc",
",",
"String",
"field",
")",
"{",
"StringTokenizer",
"tkz",
"=",
"new",
"StringTokenizer",
"(",
"field",
",",
"\". \"",
")",
";",
"JsonNode",
"trc",
"=",
"doc",
";",
"while",
"(",
"tk... | Ooes not do array index lookup! | [
"Ooes",
"not",
"do",
"array",
"index",
"lookup!"
] | ec20748557b40d1f7851e1816d1b76dae48d2027 | https://github.com/lightblue-platform/lightblue-migrator/blob/ec20748557b40d1f7851e1816d1b76dae48d2027/migrator/src/main/java/com/redhat/lightblue/migrator/Identity.java#L75-L83 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OClusterLocal.java | OClusterLocal.getPhysicalPosition | public OPhysicalPosition getPhysicalPosition(final OPhysicalPosition iPPosition) throws IOException {
final long filePosition = iPPosition.clusterPosition * RECORD_SIZE;
acquireSharedLock();
try {
final long[] pos = fileSegment.getRelativePosition(filePosition);
final OFile f = fileSegment.files[(int) pos[0]];
long p = pos[1];
iPPosition.dataSegmentId = f.readShort(p);
iPPosition.dataSegmentPos = f.readLong(p += OBinaryProtocol.SIZE_SHORT);
iPPosition.recordType = f.readByte(p += OBinaryProtocol.SIZE_LONG);
iPPosition.recordVersion = f.readInt(p += OBinaryProtocol.SIZE_BYTE);
return iPPosition;
} finally {
releaseSharedLock();
}
} | java | public OPhysicalPosition getPhysicalPosition(final OPhysicalPosition iPPosition) throws IOException {
final long filePosition = iPPosition.clusterPosition * RECORD_SIZE;
acquireSharedLock();
try {
final long[] pos = fileSegment.getRelativePosition(filePosition);
final OFile f = fileSegment.files[(int) pos[0]];
long p = pos[1];
iPPosition.dataSegmentId = f.readShort(p);
iPPosition.dataSegmentPos = f.readLong(p += OBinaryProtocol.SIZE_SHORT);
iPPosition.recordType = f.readByte(p += OBinaryProtocol.SIZE_LONG);
iPPosition.recordVersion = f.readInt(p += OBinaryProtocol.SIZE_BYTE);
return iPPosition;
} finally {
releaseSharedLock();
}
} | [
"public",
"OPhysicalPosition",
"getPhysicalPosition",
"(",
"final",
"OPhysicalPosition",
"iPPosition",
")",
"throws",
"IOException",
"{",
"final",
"long",
"filePosition",
"=",
"iPPosition",
".",
"clusterPosition",
"*",
"RECORD_SIZE",
";",
"acquireSharedLock",
"(",
")",
... | Fills and return the PhysicalPosition object received as parameter with the physical position of logical record iPosition
@throws IOException | [
"Fills",
"and",
"return",
"the",
"PhysicalPosition",
"object",
"received",
"as",
"parameter",
"with",
"the",
"physical",
"position",
"of",
"logical",
"record",
"iPosition"
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OClusterLocal.java#L200-L220 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OClusterLocal.java | OClusterLocal.removePhysicalPosition | public void removePhysicalPosition(final long iPosition) throws IOException {
final long position = iPosition * RECORD_SIZE;
acquireExclusiveLock();
try {
final long[] pos = fileSegment.getRelativePosition(position);
final OFile file = fileSegment.files[(int) pos[0]];
final long p = pos[1] + OBinaryProtocol.SIZE_SHORT + OBinaryProtocol.SIZE_LONG + OBinaryProtocol.SIZE_BYTE;
holeSegment.pushPosition(position);
// MARK DELETED SETTING VERSION TO NEGATIVE NUMBER
final int version = file.readInt(p);
file.writeInt(p, (version + 1) * -1);
updateBoundsAfterDeletion(iPosition);
} finally {
releaseExclusiveLock();
}
} | java | public void removePhysicalPosition(final long iPosition) throws IOException {
final long position = iPosition * RECORD_SIZE;
acquireExclusiveLock();
try {
final long[] pos = fileSegment.getRelativePosition(position);
final OFile file = fileSegment.files[(int) pos[0]];
final long p = pos[1] + OBinaryProtocol.SIZE_SHORT + OBinaryProtocol.SIZE_LONG + OBinaryProtocol.SIZE_BYTE;
holeSegment.pushPosition(position);
// MARK DELETED SETTING VERSION TO NEGATIVE NUMBER
final int version = file.readInt(p);
file.writeInt(p, (version + 1) * -1);
updateBoundsAfterDeletion(iPosition);
} finally {
releaseExclusiveLock();
}
} | [
"public",
"void",
"removePhysicalPosition",
"(",
"final",
"long",
"iPosition",
")",
"throws",
"IOException",
"{",
"final",
"long",
"position",
"=",
"iPosition",
"*",
"RECORD_SIZE",
";",
"acquireExclusiveLock",
"(",
")",
";",
"try",
"{",
"final",
"long",
"[",
"... | Removes the Logical position entry. Add to the hole segment and add the minus to the version.
@throws IOException | [
"Removes",
"the",
"Logical",
"position",
"entry",
".",
"Add",
"to",
"the",
"hole",
"segment",
"and",
"add",
"the",
"minus",
"to",
"the",
"version",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OClusterLocal.java#L283-L304 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OClusterLocal.java | OClusterLocal.addPhysicalPosition | public void addPhysicalPosition(final OPhysicalPosition iPPosition) throws IOException {
final long[] pos;
final boolean recycled;
long offset;
acquireExclusiveLock();
try {
offset = holeSegment.popLastEntryPosition();
if (offset > -1) {
// REUSE THE HOLE
pos = fileSegment.getRelativePosition(offset);
recycled = true;
} else {
// NO HOLES FOUND: ALLOCATE MORE SPACE
pos = allocateRecord();
offset = fileSegment.getAbsolutePosition(pos);
recycled = false;
}
final OFile file = fileSegment.files[(int) pos[0]];
long p = pos[1];
file.writeShort(p, (short) iPPosition.dataSegmentId);
file.writeLong(p += OBinaryProtocol.SIZE_SHORT, iPPosition.dataSegmentPos);
file.writeByte(p += OBinaryProtocol.SIZE_LONG, iPPosition.recordType);
if (recycled)
// GET LAST VERSION
iPPosition.recordVersion = file.readInt(p + OBinaryProtocol.SIZE_BYTE) * -1;
else
iPPosition.recordVersion = 0;
file.writeInt(p + OBinaryProtocol.SIZE_BYTE, iPPosition.recordVersion);
iPPosition.clusterPosition = offset / RECORD_SIZE;
updateBoundsAfterInsertion(iPPosition.clusterPosition);
} finally {
releaseExclusiveLock();
}
} | java | public void addPhysicalPosition(final OPhysicalPosition iPPosition) throws IOException {
final long[] pos;
final boolean recycled;
long offset;
acquireExclusiveLock();
try {
offset = holeSegment.popLastEntryPosition();
if (offset > -1) {
// REUSE THE HOLE
pos = fileSegment.getRelativePosition(offset);
recycled = true;
} else {
// NO HOLES FOUND: ALLOCATE MORE SPACE
pos = allocateRecord();
offset = fileSegment.getAbsolutePosition(pos);
recycled = false;
}
final OFile file = fileSegment.files[(int) pos[0]];
long p = pos[1];
file.writeShort(p, (short) iPPosition.dataSegmentId);
file.writeLong(p += OBinaryProtocol.SIZE_SHORT, iPPosition.dataSegmentPos);
file.writeByte(p += OBinaryProtocol.SIZE_LONG, iPPosition.recordType);
if (recycled)
// GET LAST VERSION
iPPosition.recordVersion = file.readInt(p + OBinaryProtocol.SIZE_BYTE) * -1;
else
iPPosition.recordVersion = 0;
file.writeInt(p + OBinaryProtocol.SIZE_BYTE, iPPosition.recordVersion);
iPPosition.clusterPosition = offset / RECORD_SIZE;
updateBoundsAfterInsertion(iPPosition.clusterPosition);
} finally {
releaseExclusiveLock();
}
} | [
"public",
"void",
"addPhysicalPosition",
"(",
"final",
"OPhysicalPosition",
"iPPosition",
")",
"throws",
"IOException",
"{",
"final",
"long",
"[",
"]",
"pos",
";",
"final",
"boolean",
"recycled",
";",
"long",
"offset",
";",
"acquireExclusiveLock",
"(",
")",
";",... | Adds a new entry.
@throws IOException | [
"Adds",
"a",
"new",
"entry",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OClusterLocal.java#L333-L375 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OClusterLocal.java | OClusterLocal.setDataSegmentInternal | private void setDataSegmentInternal(final String iName) {
final int dataId = storage.getDataSegmentIdByName(iName);
config.setDataSegmentId(dataId);
storage.getConfiguration().update();
} | java | private void setDataSegmentInternal(final String iName) {
final int dataId = storage.getDataSegmentIdByName(iName);
config.setDataSegmentId(dataId);
storage.getConfiguration().update();
} | [
"private",
"void",
"setDataSegmentInternal",
"(",
"final",
"String",
"iName",
")",
"{",
"final",
"int",
"dataId",
"=",
"storage",
".",
"getDataSegmentIdByName",
"(",
"iName",
")",
";",
"config",
".",
"setDataSegmentId",
"(",
"dataId",
")",
";",
"storage",
".",... | Assigns a different data-segment id.
@param iName
Data-segment's name | [
"Assigns",
"a",
"different",
"data",
"-",
"segment",
"id",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OClusterLocal.java#L562-L566 | train |
soi-toolkit/soi-toolkit-mule | commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/log/EventLoggerFactory.java | EventLoggerFactory.getCustomEventLoggerFromRegistry | protected Object getCustomEventLoggerFromRegistry(MuleContext muleContext) {
Object obj = muleContext.getRegistry().lookupObject(
CUSTOM_EVENT_LOGGER_BEAN_NAME);
return obj;
} | java | protected Object getCustomEventLoggerFromRegistry(MuleContext muleContext) {
Object obj = muleContext.getRegistry().lookupObject(
CUSTOM_EVENT_LOGGER_BEAN_NAME);
return obj;
} | [
"protected",
"Object",
"getCustomEventLoggerFromRegistry",
"(",
"MuleContext",
"muleContext",
")",
"{",
"Object",
"obj",
"=",
"muleContext",
".",
"getRegistry",
"(",
")",
".",
"lookupObject",
"(",
"CUSTOM_EVENT_LOGGER_BEAN_NAME",
")",
";",
"return",
"obj",
";",
"}"
... | open up for testing without a live MuleContext | [
"open",
"up",
"for",
"testing",
"without",
"a",
"live",
"MuleContext"
] | e891350dbf55e6307be94d193d056bdb785b37d3 | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/log/EventLoggerFactory.java#L120-L124 | train |
wuman/orientdb-android | core/src/main/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinition.java | OCompositeIndexDefinition.addIndex | public void addIndex(final OIndexDefinition indexDefinition) {
indexDefinitions.add(indexDefinition);
if (indexDefinition instanceof OIndexDefinitionMultiValue) {
if (multiValueDefinitionIndex == -1)
multiValueDefinitionIndex = indexDefinitions.size() - 1;
else
throw new OIndexException("Composite key can not contain more than one collection item");
}
} | java | public void addIndex(final OIndexDefinition indexDefinition) {
indexDefinitions.add(indexDefinition);
if (indexDefinition instanceof OIndexDefinitionMultiValue) {
if (multiValueDefinitionIndex == -1)
multiValueDefinitionIndex = indexDefinitions.size() - 1;
else
throw new OIndexException("Composite key can not contain more than one collection item");
}
} | [
"public",
"void",
"addIndex",
"(",
"final",
"OIndexDefinition",
"indexDefinition",
")",
"{",
"indexDefinitions",
".",
"add",
"(",
"indexDefinition",
")",
";",
"if",
"(",
"indexDefinition",
"instanceof",
"OIndexDefinitionMultiValue",
")",
"{",
"if",
"(",
"multiValueD... | Add new indexDefinition in current composite.
@param indexDefinition
Index to add. | [
"Add",
"new",
"indexDefinition",
"in",
"current",
"composite",
"."
] | ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0 | https://github.com/wuman/orientdb-android/blob/ff9b17e4349f26168b2d0c4facb1a18cbfbe8cf0/core/src/main/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinition.java#L100-L109 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.