예제 #1
0
 @Override
 public Cursor findFirstOrLast(Session session, boolean first) {
   TransactionMap<Value, Value> map = getMap(session);
   Value v = first ? map.firstKey() : map.lastKey();
   if (v == null) {
     return new MVStoreCursor(session, Collections.<Value>emptyList().iterator(), 0);
   }
   long key = v.getLong();
   MVStoreCursor cursor =
       new MVStoreCursor(session, Arrays.asList((Value) ValueLong.get(key)).iterator(), key);
   cursor.next();
   return cursor;
 }
예제 #2
0
 public MVPrimaryIndex(
     Database db, MVTable table, int id, IndexColumn[] columns, IndexType indexType) {
   this.mvTable = table;
   initBaseIndex(table, id, table.getName() + "_DATA", columns, indexType);
   int[] sortTypes = new int[columns.length];
   for (int i = 0; i < columns.length; i++) {
     sortTypes[i] = SortOrder.ASCENDING;
   }
   ValueDataType keyType = new ValueDataType(null, null, null);
   ValueDataType valueType = new ValueDataType(db.getCompareMode(), db, sortTypes);
   mapName = "table." + getId();
   dataMap = mvTable.getTransaction(null).openMap(mapName, keyType, valueType);
   Value k = dataMap.lastKey();
   lastKey = k == null ? 0 : k.getLong();
 }
예제 #3
0
 @Override
 public Cursor findFirstOrLast(Session session, boolean first) {
   TransactionMap<Value, Value> map = getMap(session);
   ValueLong v = (ValueLong) (first ? map.firstKey() : map.lastKey());
   if (v == null) {
     return new MVStoreCursor(
         session, Collections.<Entry<Value, Value>>emptyList().iterator(), null);
   }
   Value value = map.get(v);
   Entry<Value, Value> e = new DataUtils.MapEntry<Value, Value>(v, value);
   @SuppressWarnings("unchecked")
   List<Entry<Value, Value>> list = Arrays.asList(e);
   MVStoreCursor c = new MVStoreCursor(session, list.iterator(), v);
   c.next();
   return c;
 }