예제 #1
0
 public void index(Record record) {
   final Long recordId = record.getId();
   if (record.isActive()) {
     final Record anotherRecord = records.putIfAbsent(recordId, record);
     if (anotherRecord != null) {
       record = anotherRecord;
     } else {
       size.incrementAndGet();
     }
   } else {
     remove(record);
   }
   if (indexValue != null) {
     Long newValueIndex = -1L;
     if (record.isActive() && record.hasValueData()) {
       newValueIndex = (long) record.getValueData().hashCode();
     }
     indexValue.index(newValueIndex, record);
   }
   Long[] indexValues = record.getIndexes();
   if (indexValues != null && hasIndexedAttributes) {
     byte[] indexTypes = record.getIndexTypes();
     if (indexTypes == null || indexValues.length != indexTypes.length) {
       throw new IllegalArgumentException(
           "index and types don't match " + Arrays.toString(indexTypes));
     }
     Collection<Index> indexes = mapIndexes.values();
     for (Index index : indexes) {
       if (indexValues.length > index.getAttributeIndex()) {
         Long newValue = indexValues[index.getAttributeIndex()];
         index.index(newValue, record);
       }
     }
   }
 }
 public void newRecordIndex(Long newValue, Record record) {
   long recordId = record.getId();
   ConcurrentMap<Long, Record> records = mapRecords.get(newValue);
   if (records == null) {
     records = new ConcurrentHashMap<Long, Record>(1, 0.75f, 1);
     mapRecords.put(newValue, records);
     sortedSet.add(newValue);
   }
   records.put(recordId, record);
 }
예제 #3
0
 public void remove(Record record) {
   Record existingRecord = records.remove(record.getId());
   if (existingRecord != null) {
     size.decrementAndGet();
   }
 }