# Building configuration
CC = gcc
-CPPFLAGS = -I. -I. -I../tcejdb -I/usr/lib/jvm/java-6-oracle/include -I/usr/lib/jvm/java-6-oracle/include/linux -I$(INCLUDEDIR) -I/home/tve/include -I/usr/local/include -D_UNICODE -DNDEBUG -D_GNU_SOURCE=1 -D_REENTRANT -D__EXTENSIONS__
+CPPFLAGS = -I. -I. -I../tcejdb -I/usr/lib/jvm/java-6-openjdk-amd64/include -I/usr/lib/jvm/java-6-openjdk-amd64/include/linux -I$(INCLUDEDIR) -I/home/tve/include -I/usr/local/include -D_UNICODE -DNDEBUG -D_GNU_SOURCE=1 -D_REENTRANT -D__EXTENSIONS__
CFLAGS = -std=c99 -Wall -fPIC -fsigned-char -O2
LDFLAGS = -L. -L$(LIBDIR) -L/home/tve/lib -L/usr/local/lib
LIBS = -lz -ltcejdb -lrt -lpthread -lm -lc
}
/**
- * @return <code>true</code> if decoder currently in use
+ * Returns <code>true</code> if decoder is currently in use
+ * @return <code>true</code> if decoder is currently in use
*/
public boolean isBusy() {
return input != null;
}
/**
- * @return <code>true</code> if encoder currently in use
+ * Returns <code>true</code> if encoder is currently in use
+ * @return <code>true</code> if encoder is currently in use
*/
public boolean isBusy() {
return output != null;
* BSON object.
* <p/>
* NOTE:
- * - {@link BSONObject#ID_KEY} must be valid {@link ObjectId}((@link ObjectId} instance or valid <code>byte[]</code> or <code>String</code>)
+ * {@link BSONObject#ID_KEY} must be valid {@link ObjectId} ({@link ObjectId} instance or valid <code>byte[]</code> or <code>String</code>)
*
* @author Tyutyunkov Vyacheslav (tve@softmotions.com)
* @version $Id$
}
/**
+ * Returns fields in adding order
* @return fields in adding order
*/
public List<String> fields() {
}
/**
+ * Returns id of BSON object (if specified)
* @return id of BSON object (if specified)
*/
public ObjectId getId() {
}
/**
+ * Returns value of specified field if exists, or <code>null</code> otherwise
* @return value of specified field if exists, or <code>null</code> otherwise
*/
public Object get(String key) {
}
/**
+ * Returns fields count
* @return fields count
*/
public int size() {
return false;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object o) {
if (this != o && (null == o || !(o instanceof BSONObject))) {
}
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public int hashCode() {
return data.hashCode();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
import java.io.UnsupportedEncodingException;
/**
+ * Utility class for reading BSON object data
+ *
* @author Tyutyunkov Vyacheslav (tve@softmotions.com)
* @version $Id$
*/
this.limit = limit;
}
+ /**
+ * Reads one byte from buffer
+ */
public byte read() {
ensure(1);
return result;
}
+ /**
+ * Reads 4 bytes from buffer as integer value
+ */
public int readInt() {
ensure(4);
return result;
}
+ /**
+ * Reads 8 bytes from buffer as long value
+ */
public long readLong() {
ensure(8);
return result;
}
+ /**
+ * Reads bytes from buffer
+ * @param count count of bytes to read
+ */
public byte[] readBytes(int count) {
ensure(count);
byte[] bytes = new byte[count];
return bytes;
}
+ /**
+ * Reads c-string (null-terminated) from buffer
+ */
public String readString() {
return readString(0);
}
+ /**
+ * Reads c-string from buffer with specified length
+ */
public String readString(int length) {
if (length > 0) {
ensure(length);
return s;
}
+ /**
+ * Returns <code>true</code> if any bytes available to read from buffer or <code>false</code> otherwise
+ * @return <code>true</code> if any bytes available to read from buffer or <code>false</code> otherwise
+ */
public boolean isAvailable() {
return position < limit;
}
+ /**
+ * Get sub buffer with specified length
+ */
public InputBuffer subBuffer(int limit) {
ensure(limit);
return result;
}
+ /**
+ * Checks is buffer contains needed bytes
+ */
protected void ensure(int size) {
if (size > limit - position) {
throw new BSONException("can not allocate sub buffer: not enought bytes");
}
}
+
+ /**
+ * Creates {@link InputBuffer} from byte array
+ */
public static InputBuffer createFromByteArray(byte[] data) {
return new InputBuffer(data, 0, data.length);
}
import java.io.UnsupportedEncodingException;
/**
+ * Utility class for serialize BSON object
+ *
* @author Tyutyunkov Vyacheslav (tve@softmotions.com)
* @version $Id$
*/
actualSize = 0;
}
+ /**
+ * Returns current position in output
+ * @return current position in output
+ */
public int getPosition() {
return position;
}
+ /**
+ * Sets position
+ */
public void setPosition(int position) {
this.position = position;
}
+ /**
+ * Returns actual (full) size of buffer (currently writed bytes)
+ * @return actual (full) size of buffer (currently writed bytes)
+ */
public int getActualSize() {
return actualSize;
}
+ /**
+ * Returns buffer as byte array
+ * @return buffer as byte array
+ */
public byte[] getResult() {
byte[] result = new byte[getActualSize()];
System.arraycopy(buffer, 0, result, 0, getActualSize());
return result;
}
+ /**
+ * Writes single byte to buffer
+ */
public void write(byte data) {
ensureLength(1);
buffer[position++] = data;
actualSize = Math.max(actualSize, position);
}
+ /**
+ * Writes byte array to buffer
+ */
public void write(byte[] data) {
this.write(data, 0, data.length);
}
+ /**
+ * Writes part of byte array to buffer
+ *
+ * @param data source byte array
+ * @param offset start position in source
+ * @param length count bytes to write
+ */
public void write(byte[] data, int offset, int length) {
ensureLength(length);
System.arraycopy(data, offset, buffer, position, length);
actualSize = Math.max(actualSize, position);
}
+ /**
+ * Writes integer value (4 bytes) at specified position
+ * @param position position to write
+ * @param value value
+ */
public void writeIntAt(int position, int value) {
int save = getPosition();
setPosition(position);
setPosition(save);
}
+ /**
+ * Writes integer value to buffer as 4 bytes
+ */
public void writeInt(int value) {
this.write(new byte[]{
(byte) ((value >>> 0) & 0xFF),
});
}
+ /**
+ * Writes long value to buffer as 8 bytes
+ */
public void writeLong(long value) {
this.write(new byte[]{
(byte) ((value >>> 0) & 0xFF),
});
}
+ /**
+ * Writes double value to buffers as 8 bytes
+ */
public void writeDouble(double value) {
this.writeLong(Double.doubleToRawLongBits(value));
}
+ /**
+ * Writes {@link String} to buffer as c-style string (null-terminated)
+ * @return count of writed bytes
+ */
public int writeString(String value) {
int start = getPosition();
try {
return getPosition() - start;
}
+ /**
+ * Checks internal array size to hold needed data and expand it if need.
+ */
protected void ensureLength(int need) {
if (need <= buffer.length - position) {
return;
return result;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object o) {
return this == o || null != o && o instanceof ObjectId && Arrays.equals(data, ((ObjectId) o).data);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public int hashCode() {
return Arrays.hashCode(data);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String toString() {
StringBuilder builder = new StringBuilder(34);
}
/**
+ * Returns Java flag
* @return Java flag
*/
public int getFlag() {
}
/**
+ * Returns BSON character for associated Java regex flag
* @return BSON character for associated Java regex flag
*/
public char getCharacter() {
}
/**
+ * Returns <code>true</code> if BSON supported current Java flag
* @return <code>true</code> if BSON supported current Java flag
*/
public boolean isSupported() {
super(src);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Object put(String key, Object value) {
return registerField(key, value);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public BSONQueryObject append(String key, Object value) {
super.append(key, value);
}
/**
- * BSON Query objects can not contains dedicated ObjectID
- * @return
+ * {@inheritDoc}
+ *
+ * @deprecated BSON Query objects can not contains dedicated ObjectID
*/
@Deprecated
@Override
return null;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected boolean isFieldsOrderImportant() {
return true;
}
/**
+ * Returns EJDB path
* @return EJDB path
*/
public String getPath() {
return collections.values();
}
-
+ /**
+ * {@inheritDoc}
+ */
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
return sb.toString();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected void finalize() throws Throwable {
this.close();
}
/**
+ * Returns EJDB object
* @return EJDB object
*/
public EJDB getDB() {
}
/**
+ * Returns collection name
* @return collection name
*/
public String getName() {
}
/**
+ * Returns collection exists status
* @return collection exists status
*/
public boolean isExists() {
}
/**
+ * Returns collection options {@link Options}
* @return collection options {@link Options}
*/
public Options getOptions() {
}
/**
+ * Returns indexes info
* @return indexes info
*/
public Collection<Index> getIndexes() {
protected native boolean txControl(int mode) throws EJDBException;
+ /**
+ * {@inheritDoc}
+ */
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
}
/**
- * @param compressed If true collection records will be compressed with DEFLATE compression. Default: false.
- * @param large Specifies that the size of the database can be larger than 2GB. Default: false
+ * @param compressed If <code>true</code> collection records will be compressed with DEFLATE compression. Default: <code>false</code>.
+ * @param large Specifies that the size of the database can be larger than 2GB. Default: <code>false</code>.
* @param records Estimated number of records in this collection. Default: 65535.
* @param cachedRecords Max number of cached records in shared memory segment. Default: 0
*/
return cachedRecords;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
private String file;
private int records;
+ /**
+ * Returns index name
+ */
public String getName() {
return name;
}
+ /**
+ * Returns index field path
+ */
public String getField() {
return field;
}
+ /**
+ * Returns index type
+ */
public IndexType getType() {
return type;
}
+ /**
+ * Returns index file path
+ */
public String getFile() {
return file;
}
+ /**
+ * Returns records count in index
+ */
public int getRecords() {
return records;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
}
/**
+ * Returns main BSON query object
* @return main BSON query object
*/
public BSONObject getMainQuery() {
}
/**
+ * Returns BSON objects for additional OR queries
* @return BSON objects for additional OR queries
*/
public BSONObject[] getOrQueries() {
}
/**
+ * Returns BSON hints object
* @return BSON hints object
*/
public BSONObject getQueryHints() {
}
/**
- * Make {@se http://github.com/Softmotions/ejdb/wiki/Collection-joins collection join} for select queries.
+ * Make <a href="http://github.com/Softmotions/ejdb/wiki/Collection-joins">collection join</a> for select queries.
*/
+ @SuppressWarnings("JavadocReference")
public EJDBQueryBuilder join(String fpath, String collname) {
return new Constraint("$join", new Constraint(fpath, new Constraint("$do", false))).addOperation(collname);
}
}
/**
- * Field existence matching {@link Constraint#exists(boolean = true)}
+ * Field existence matching {@link Constraint#exists(boolean)}
*/
public EJDBQueryBuilder exists() {
return this.exists(true);
*/
public native int length();
+ /**
+ * {@inheritDoc}
+ */
public Iterator<BSONObject> iterator() {
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public boolean hasNext() {
return position < this.length();
}
+ /**
+ * {@inheritDoc}
+ */
public BSONObject next() throws EJDBException {
if (!hasNext()) {
throw new NoSuchElementException();
return get(position++);
}
+ /**
+ * {@inheritDoc}
+ */
public void remove() {
throw new UnsupportedOperationException();
}
*/
public native void close() throws EJDBException;
+ /**
+ * {@inheritDoc}
+ */
@Override
protected void finalize() throws Throwable {
this.close();