• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gephi / graphstore / #627

23 Oct 2026 05:29PM UTC coverage: 91.711% (+0.02%) from 91.69%
#627

push

web-flow
Replace the time keys of a dynamic value without a gap (#334)

* Replace the time keys of a dynamic value without a gap

ElementImpl.updateIndex replaced a whole TimeMap or TimeSet value by
removing the times of the old value and then adding the times of the new
one. A time held by both was briefly absent from the time index, so
isDynamic() and the time bounds could see an empty or partial index.

TimeIndexStore.replace adds the times only the new value holds, then removes
the times only the old value held, so a time in both stays in the index. A
value set back after being changed in place keeps the previous remove and
add, as the old and new value are then the same instance.

TimestampSet.contains searched the whole backing array instead of the first
size entries, and missed timestamps after removals left stale copies behind
the used part.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Keep the replace tests to behavior

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>

38 of 39 new or added lines in 3 files covered. (97.44%)

12192 of 13294 relevant lines covered (91.71%)

0.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.09
/src/main/java/org/gephi/graph/impl/ElementImpl.java
1
/*
2
 * Copyright 2012-2013 Gephi Consortium
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
 * use this file except in compliance with the License. You may obtain a copy of
6
 * the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 * License for the specific language governing permissions and limitations under
14
 * the License.
15
 */
16

17
package org.gephi.graph.impl;
18

19
import java.util.List;
20
import java.util.Map;
21
import java.util.Set;
22
import org.gephi.graph.api.AttributeUtils;
23
import org.gephi.graph.api.Column;
24
import org.gephi.graph.api.ColumnIterable;
25
import org.gephi.graph.api.Element;
26
import org.gephi.graph.api.Estimator;
27
import org.gephi.graph.api.GraphView;
28
import org.gephi.graph.api.Interval;
29
import org.gephi.graph.api.TimeRepresentation;
30
import org.gephi.graph.api.types.IntervalBooleanMap;
31
import org.gephi.graph.api.types.IntervalByteMap;
32
import org.gephi.graph.api.types.IntervalCharMap;
33
import org.gephi.graph.api.types.IntervalDoubleMap;
34
import org.gephi.graph.api.types.IntervalFloatMap;
35
import org.gephi.graph.api.types.IntervalIntegerMap;
36
import org.gephi.graph.api.types.IntervalLongMap;
37
import org.gephi.graph.api.types.IntervalMap;
38
import org.gephi.graph.api.types.IntervalShortMap;
39
import org.gephi.graph.api.types.IntervalStringMap;
40
import org.gephi.graph.api.types.TimeMap;
41
import org.gephi.graph.api.types.TimeSet;
42
import org.gephi.graph.api.types.TimestampBooleanMap;
43
import org.gephi.graph.api.types.TimestampByteMap;
44
import org.gephi.graph.api.types.TimestampCharMap;
45
import org.gephi.graph.api.types.TimestampDoubleMap;
46
import org.gephi.graph.api.types.TimestampFloatMap;
47
import org.gephi.graph.api.types.TimestampIntegerMap;
48
import org.gephi.graph.api.types.TimestampLongMap;
49
import org.gephi.graph.api.types.TimestampMap;
50
import org.gephi.graph.api.types.TimestampShortMap;
51
import org.gephi.graph.api.types.TimestampStringMap;
52

53
public abstract class ElementImpl implements Element {
54

55
    // Reference to store
56
    protected final GraphStore graphStore;
57
    // Attributes
58
    protected final AttributesImpl attributes;
59

60
    public ElementImpl(Object id, GraphStore graphStore) {
1 ✔
61
        if (id == null) {
1 ✔
62
            throw new NullPointerException();
1 ✔
63
        }
64
        this.graphStore = graphStore;
1 ✔
65
        this.attributes = new AttributesImpl(getColumnStore());
1 ✔
66
        this.attributes.setId(id);
1 ✔
67
    }
1 ✔
68

69
    abstract ColumnStore getColumnStore();
70

71
    abstract TimeIndexStore getTimeIndexStore();
72

73
    abstract boolean isValid();
74

75
    abstract DefaultColumnsImpl.TableDefaultColumns getDefaultColumns();
76

77
    @Override
78
    public Object getId() {
79
        return attributes.getId();
1 ✔
80
    }
81

82
    @Override
83
    public String getLabel() {
84
        return attributes.getLabel();
1 ✔
85
    }
86

87
    @Override
88
    public void setLabel(String label) {
89
        if (GraphStoreConfiguration.ENABLE_ELEMENT_LABEL) {
90
            setAttribute(getDefaultColumns().label, label);
1 ✔
91
        }
92
    }
1 ✔
93

94
    @Override
95
    public Object getAttribute(String key) {
96
        return getAttribute(checkColumnExists(key));
1 ✔
97
    }
98

99
    @Override
100
    public Object getAttribute(Column column) {
101
        checkColumn(column);
1 ✔
102

103
        return attributes.getAttribute(column);
1 ✔
104
    }
105

106
    @Override
107
    public Object getAttribute(String key, double timestamp) {
108
        return getAttribute(checkColumnExists(key), timestamp);
1 ✔
109
    }
110

111
    @Override
112
    public Object getAttribute(Column column, double timestamp) {
113
        checkTimeRepresentationTimestamp();
1 ✔
114
        checkDouble(timestamp);
1 ✔
115
        checkColumn(column);
1 ✔
116
        checkColumnDynamic(column);
1 ✔
117
        return attributes.getAttribute(column, timestamp, null);
1 ✔
118
    }
119

120
    @Override
121
    public Object getAttribute(String key, Interval interval) {
122
        return getAttribute(checkColumnExists(key), interval);
1 ✔
123
    }
124

125
    @Override
126
    public Object getAttribute(Column column, Interval interval) {
127
        checkTimeRepresentationInterval();
1 ✔
128
        checkColumn(column);
1 ✔
129
        checkColumnDynamic(column);
1 ✔
130
        return attributes.getAttribute(column, interval, null);
1 ✔
131
    }
132

133
    @Override
134
    public Object getAttribute(String key, GraphView view) {
135
        return getAttribute(checkColumnExists(key), view);
1 ✔
136
    }
137

138
    @Override
139
    public Object getAttribute(Column column, GraphView view) {
140
        Estimator estimator = column.getEstimator();
1 ✔
141
        return getAttribute(column, view, estimator);
1 ✔
142
    }
143

144
    protected Object getAttribute(Column column, GraphView view, Estimator estimator) {
145
        checkColumn(column);
1 ✔
146

147
        if (!column.isDynamic()) {
1 ✔
148
            return getAttribute(column);
1 ✔
149
        } else {
150
            checkViewExist(view);
1 ✔
151
            Interval interval = view.getTimeInterval();
1 ✔
152
            return attributes.getAttribute(column, interval, estimator);
1 ✔
153
        }
154
    }
155

156
    @Override
157
    public Object[] getAttributes() {
158
        return attributes.getBackingArray();
1 ✔
159
    }
160

161
    @Override
162
    public Set<String> getAttributeKeys() {
163
        return getColumnStore().getColumnKeys();
1 ✔
164
    }
165

166
    @Override
167
    public ColumnIterable getAttributeColumns() {
168
        return getColumnStore();
1 ✔
169
    }
170

171
    @Override
172
    public Object removeAttribute(String key) {
173
        return removeAttribute(checkColumnExists(key));
1 ✔
174
    }
175

176
    @Override
177
    public Object removeAttribute(Column column) {
178
        checkColumn(column);
1 ✔
179
        checkReadOnlyColumn(column);
1 ✔
180

181
        Object oldValue = attributes.setAttribute(column, column.getDefaultValue());
1 ✔
182
        updateIndex(column, oldValue, column.getDefaultValue());
1 ✔
183

184
        return oldValue;
1 ✔
185
    }
186

187
    @Override
188
    public Object removeAttribute(Column column, double timestamp) {
189
        checkTimeRepresentationTimestamp();
1 ✔
190
        checkDouble(timestamp);
1 ✔
191
        return removeTimeAttribute(column, timestamp);
1 ✔
192
    }
193

194
    @Override
195
    public Object removeAttribute(String key, double timestamp) {
196
        return removeAttribute(checkColumnExists(key), timestamp);
1 ✔
197
    }
198

199
    @Override
200
    public Object removeAttribute(Column column, Interval interval) {
201
        checkTimeRepresentationInterval();
1 ✔
202
        return removeTimeAttribute(column, interval);
1 ✔
203
    }
204

205
    @Override
206
    public Object removeAttribute(String key, Interval interval) {
207
        return removeAttribute(checkColumnExists(key), interval);
1 ✔
208
    }
209

210
    private Object removeTimeAttribute(Column column, Object timeObject) {
211
        checkColumn(column);
1 ✔
212
        checkColumnDynamic(column);
1 ✔
213
        checkReadOnlyColumn(column);
1 ✔
214

215
        Object oldValue = attributes.removeTimeAttribute(column, timeObject);
1 ✔
216

217
        // TODO
218
        if (oldValue != null && isValid()) {
1 ✔
219
            TimeIndexStore timeIndexStore = getTimeIndexStore();
1 ✔
220
            if (timeIndexStore != null) {
1 ✔
221
                timeIndexStore.remove(timeObject);
1 ✔
222
            }
223
            ((ColumnImpl) column).incrementVersion(this);
1 ✔
224
        }
225
        return oldValue;
1 ✔
226
    }
227

228
    @Override
229
    public void setAttribute(String key, Object value) {
230
        setAttribute(checkColumnExists(key), value);
1 ✔
231
    }
1 ✔
232

233
    @Override
234
    public void setAttribute(Column column, Object value) {
235
        checkColumn(column);
1 ✔
236
        checkReadOnlyColumn(column);
1 ✔
237

238
        value = AttributeUtils.standardizeValue(value);
1 ✔
239
        checkType(column, value);
1 ✔
240

241
        Object oldValue = attributes.setAttribute(column, value);
1 ✔
242
        updateIndex(column, oldValue, value);
1 ✔
243
    }
1 ✔
244

245
    @Override
246
    public void setAttribute(String key, Object value, double timestamp) {
247
        setAttribute(checkColumnExists(key), value, timestamp);
1 ✔
248
    }
1 ✔
249

250
    @Override
251
    public void setAttribute(Column column, Object value, double timestamp) {
252
        checkTimeRepresentationTimestamp();
1 ✔
253
        checkDouble(timestamp);
1 ✔
254
        setTimeAttribute(column, value, timestamp);
1 ✔
255
    }
1 ✔
256

257
    @Override
258
    public void setAttribute(String key, Object value, Interval interval) {
259
        setAttribute(checkColumnExists(key), value, interval);
1 ✔
260
    }
1 ✔
261

262
    @Override
263
    public void setAttribute(Column column, Object value, Interval interval) {
264
        checkTimeRepresentationInterval();
1 ✔
265
        setTimeAttribute(column, value, interval);
1 ✔
266
    }
1 ✔
267

268
    private void setTimeAttribute(Column column, Object value, Object timeObject) {
269
        checkColumn(column);
1 ✔
270
        checkColumnDynamic(column);
1 ✔
271
        checkReadOnlyColumn(column);
1 ✔
272
        checkDynamicType(column, value);
1 ✔
273

274
        // Only a time the map did not already hold is a new reference for the time index. Passing the whole map would
275
        // re-count every time in it, as removeTimeAttribute decrements one at a time.
276
        boolean isNewTime = attributes.setAttribute(column, value, timeObject);
1 ✔
277
        updateIndex(column, null, isNewTime ? timeObject : null);
1 ✔
278
    }
1 ✔
279

280
    private void updateIndex(Column column, Object oldValue, Object newValue) {
281
        // Update index
282
        if (isValid()) {
1 ✔
283
            ColumnStore columnStore = getColumnStore();
1 ✔
284
            ColumnImpl columnImpl = (ColumnImpl) column;
1 ✔
285
            if (columnImpl.isDynamic()) {
1 ✔
286
                TimeIndexStore timeIndexStore = getTimeIndexStore();
1 ✔
287
                if (timeIndexStore != null) {
1 ✔
288
                    if (TimeMap.class.isAssignableFrom(columnImpl.getTypeClass())) {
1 ✔
289
                        if (oldValue instanceof TimeMap && newValue instanceof TimeMap && oldValue != newValue) {
1 ✔
290
                            timeIndexStore.replace((TimeMap) oldValue, (TimeMap) newValue);
1 ✔
291
                        } else {
292
                            if (oldValue instanceof TimeMap) {
1 ✔
293
                                timeIndexStore.remove((TimeMap) oldValue);
1 ✔
294
                            } else if (oldValue != null) {
1 ✔
NEW
295
                                timeIndexStore.remove(oldValue);
×
296
                            }
297
                            if (newValue instanceof TimeMap) {
1 ✔
298
                                timeIndexStore.add((TimeMap) newValue);
1 ✔
299
                            } else if (newValue != null) {
1 ✔
300
                                timeIndexStore.add(newValue);
1 ✔
301
                            }
302
                        }
303
                    } else if (TimeSet.class.isAssignableFrom(columnImpl.getTypeClass())) {
1 ✔
304
                        if (oldValue instanceof TimeSet && newValue instanceof TimeSet && oldValue != newValue) {
1 ✔
305
                            timeIndexStore.replace((TimeSet) oldValue, (TimeSet) newValue, this);
1 ✔
306
                        } else {
307
                            if (oldValue instanceof TimeSet) {
1 ✔
308
                                timeIndexStore.remove((TimeSet) oldValue, this);
1 ✔
309
                            } else if (oldValue != null) {
1 ✔
310
                                timeIndexStore.remove(oldValue, this);
1 ✔
311
                            }
312
                            if (newValue instanceof TimeSet) {
1 ✔
313
                                timeIndexStore.add((TimeSet) newValue, this);
1 ✔
314
                            } else if (newValue != null) {
1 ✔
315
                                timeIndexStore.add(newValue, this);
1 ✔
316
                            }
317
                        }
318
                    }
319
                }
320
            }
321
            if (columnStore != null) {
1 ✔
322
                columnStore.indexStore.set(column, oldValue, newValue, this);
1 ✔
323
            }
324
            columnImpl.incrementVersion(this);
1 ✔
325
        }
326
    }
1 ✔
327

328
    @Override
329
    public boolean addTimestamp(double timestamp) {
330
        checkDouble(timestamp);
1 ✔
331
        checkTimeRepresentationTimestamp();
1 ✔
332
        return addTime(timestamp);
1 ✔
333
    }
334

335
    @Override
336
    public boolean addInterval(Interval interval) {
337
        checkTimeRepresentationInterval();
1 ✔
338
        return addTime(interval);
1 ✔
339
    }
340

341
    private boolean addTime(Object timeObject) {
342
        checkEnabledTimeSet();
1 ✔
343

344
        boolean res = attributes.addTime(timeObject);
1 ✔
345
        if (res) {
1 ✔
346
            updateIndex(getDefaultColumns().timeset, null, timeObject);
1 ✔
347
        }
348
        return res;
1 ✔
349
    }
350

351
    @Override
352
    public boolean removeTimestamp(double timestamp) {
353
        checkDouble(timestamp);
1 ✔
354
        checkTimeRepresentationTimestamp();
1 ✔
355
        return removeTime(timestamp);
1 ✔
356
    }
357

358
    @Override
359
    public boolean removeInterval(Interval interval) {
360
        checkTimeRepresentationInterval();
1 ✔
361
        return removeTime(interval);
1 ✔
362
    }
363

364
    private boolean removeTime(Object timeObject) {
365
        checkEnabledTimeSet();
1 ✔
366

367
        boolean res = attributes.removeTime(timeObject);
1 ✔
368
        if (res) {
1 ✔
369
            updateIndex(getDefaultColumns().timeset, timeObject, null);
1 ✔
370
        }
371
        return res;
1 ✔
372
    }
373

374
    @Override
375
    public double[] getTimestamps() {
376
        checkTimeRepresentationTimestamp();
1 ✔
377
        checkEnabledTimeSet();
1 ✔
378
        Object res = attributes.getTimeSetArray();
1 ✔
379
        if (res == null) {
1 ✔
380
            return new double[0];
1 ✔
381
        }
382
        return (double[]) res;
1 ✔
383
    }
384

385
    @Override
386
    public Interval[] getIntervals() {
387
        checkTimeRepresentationInterval();
1 ✔
388
        checkEnabledTimeSet();
1 ✔
389
        Object res = attributes.getTimeSetArray();
1 ✔
390
        if (res == null) {
1 ✔
391
            return new Interval[0];
1 ✔
392
        }
393
        return (Interval[]) res;
1 ✔
394
    }
395

396
    @Override
397
    public Interval getTimeBounds() {
398
        checkEnabledTimeSet();
×
399
        TimeSet timeSet = attributes.getTimeSet();
×
400
        if (timeSet != null) {
×
401
            Double min = timeSet.getMinDouble();
×
402
            Double max = timeSet.getMaxDouble();
×
403
            if (min != null) {
×
404
                return new Interval(min, max);
×
405
            }
406
        }
407
        return null;
×
408
    }
409

410
    @Override
411
    public boolean hasTimestamp(double timestamp) {
412
        checkTimeRepresentationTimestamp();
1 ✔
413
        checkEnabledTimeSet();
1 ✔
414
        return attributes.hasTime(timestamp);
1 ✔
415
    }
416

417
    @Override
418
    public boolean hasInterval(Interval interval) {
419
        checkTimeRepresentationInterval();
1 ✔
420
        checkEnabledTimeSet();
1 ✔
421
        return attributes.hasTime(interval);
1 ✔
422
    }
423

424
    @Override
425
    public Iterable<Map.Entry> getAttributes(Column column) {
426
        checkColumn(column);
1 ✔
427
        checkColumnDynamicAttribute(column);
1 ✔
428

429
        return attributes.getAttributes(column);
1 ✔
430
    }
431

432
    // Called when elements are added
433
    // TODO
434
    protected void indexAttributes() {
435
        synchronized (this) {
1 ✔
436
            ColumnStore columnStore = getColumnStore();
1 ✔
437
            if (columnStore != null) {
1 ✔
438
                columnStore.indexStore.index(this);
1 ✔
439
            }
440

441
            TimeIndexStore timeIndexStore = getTimeIndexStore();
1 ✔
442
            if (timeIndexStore != null) {
1 ✔
443
                timeIndexStore.index(this);
1 ✔
444
            }
445
        }
1 ✔
446
    }
1 ✔
447

448
    @Override
449
    public void clearAttributes() {
450
        synchronized (this) {
1 ✔
451
            ColumnStore columnStore = getColumnStore();
1 ✔
452
            if (columnStore != null) {
1 ✔
453
                final int length = columnStore.length;
1 ✔
454
                final ColumnImpl[] cols = columnStore.columns;
1 ✔
455
                for (int i = 0; i < length; i++) {
1 ✔
456
                    Column c = cols[i];
1 ✔
457
                    if (!c.isProperty() && !c.isReadOnly()) {
1 ✔
458
                        removeAttribute(c);
1 ✔
459
                    }
460
                }
461
            }
462
        }
1 ✔
463
    }
1 ✔
464

465
    protected void destroyAttributes() {
466
        synchronized (this) {
1 ✔
467
            ColumnStore columnStore = getColumnStore();
1 ✔
468
            if (columnStore != null) {
1 ✔
469
                columnStore.indexStore.clear(this);
1 ✔
470
            }
471

472
            TimeIndexStore timeIndexStore = getTimeIndexStore();
1 ✔
473
            if (timeIndexStore != null) {
1 ✔
474
                timeIndexStore.clear(this);
1 ✔
475
            }
476
        }
1 ✔
477
    }
1 ✔
478

479
    @Override
480
    public int hashCode() {
481
        int hash = 7;
1 ✔
482
        hash = 29 * hash + this.getId().hashCode();
1 ✔
483
        return hash;
1 ✔
484
    }
485

486
    @Override
487
    public boolean equals(Object obj) {
488
        if (obj == null) {
1 ✔
489
            return false;
×
490
        }
491
        if (getClass() != obj.getClass()) {
1 ✔
492
            return false;
×
493
        }
494
        final ElementImpl other = (ElementImpl) obj;
1 ✔
495
        return this.getId().equals(other.getId());
1 ✔
496
    }
497

498
    protected Estimator getEstimator(Column column) {
499
        Estimator estimator = column.getEstimator();
1 ✔
500
        if (estimator == null) {
1 ✔
501
            return GraphStoreConfiguration.DEFAULT_ESTIMATOR;
×
502
        }
503
        return estimator;
1 ✔
504
    }
505

506
    protected GraphStore getGraphStore() {
507
        return graphStore;
×
508
    }
509

510
    protected void checkTimeRepresentationTimestamp() {
511
        if (!getTimeRepresentation().equals(TimeRepresentation.TIMESTAMP)) {
1 ✔
512
            throw new RuntimeException(
1 ✔
513
                    "Can't use timestamps as the configuration is set to " + getTimeRepresentation());
1 ✔
514
        }
515
    }
1 ✔
516

517
    protected void checkTimeRepresentationInterval() {
518
        if (!getTimeRepresentation().equals(TimeRepresentation.INTERVAL)) {
1 ✔
519
            throw new RuntimeException("Can't use intervals as the configuration is set to " + getTimeRepresentation());
1 ✔
520
        }
521
    }
1 ✔
522

523
    void checkEnabledTimeSet() {
524
        if (!GraphStoreConfiguration.ENABLE_ELEMENT_TIME_SET) {
525
            throw new RuntimeException("Can't call timestamp or intervals methods if they are disabled");
526
        }
527
    }
1 ✔
528

529
    void checkDouble(double timestamp) {
530
        if (Double.isInfinite(timestamp) || Double.isNaN(timestamp)) {
1 ✔
531
            throw new IllegalArgumentException("Timestamp can't be NaN or infinity");
1 ✔
532
        }
533
    }
1 ✔
534

535
    Column checkColumnExists(String key) {
536
        Column col = getColumnStore().getColumn(key);
1 ✔
537
        if (col == null) {
1 ✔
538
            throw new IllegalArgumentException("The column '" + key + "' is not found");
1 ✔
539
        }
540
        return col;
1 ✔
541
    }
542

543
    void checkColumn(Column column) {
544
        if (column.getIndex() == ColumnStore.NULL_ID) {
1 ✔
545
            throw new IllegalArgumentException("The column does not exist");
1 ✔
546
        }
547
        ColumnStore columnStore = getColumnStore();
1 ✔
548
        if (columnStore != null && columnStore.getColumnByIndex(column.getIndex()) != column) {
1 ✔
549
            throw new IllegalArgumentException("The column does not belong to the right column store");
×
550
        }
551
    }
1 ✔
552

553
    void checkReadOnlyColumn(Column column) {
554
        if (column.isReadOnly()) {
1 ✔
555
            throw new RuntimeException("Can't modify the read-only '" + column.getId() + "' column");
×
556
        }
557
    }
1 ✔
558

559
    void checkColumnDynamic(Column column) {
560
        if (!column.isDynamic()) {
1 ✔
561
            throw new IllegalArgumentException("The column is not dynamic");
1 ✔
562
        }
563
    }
1 ✔
564

565
    void checkColumnDynamicAttribute(Column column) {
566
        if (!column.isDynamicAttribute()) {
1 ✔
567
            throw new IllegalArgumentException("The column is not a dynamic attribute");
1 ✔
568
        }
569
    }
1 ✔
570

571
    void checkDynamicType(Column column, Object value) {
572
        if (value != null) {
1 ✔
573
            Class typeClass = column.getTypeClass();
1 ✔
574
            if (TimestampMap.class.isAssignableFrom(typeClass)) {
1 ✔
575
                checkTimeRepresentationTimestamp();
1 ✔
576
                if ((value instanceof Double && (!typeClass
1 ✔
577
                        .equals(TimestampDoubleMap.class))) || (value instanceof Float && !typeClass
1 ✔
578
                                .equals(TimestampFloatMap.class)) || (value instanceof Boolean && !typeClass
1 ✔
579
                                        .equals(TimestampBooleanMap.class)) || (value instanceof Integer && !typeClass
1 ✔
580
                                                .equals(TimestampIntegerMap.class)) || (value instanceof Long && !typeClass
1 ✔
581
                                                        .equals(TimestampLongMap.class)) || (value instanceof Short && !typeClass
1 ✔
582
                                                                .equals(TimestampShortMap.class)) || (value instanceof Byte && !typeClass
1 ✔
583
                                                                        .equals(TimestampByteMap.class)) || (value instanceof String && !typeClass
1 ✔
584
                                                                                .equals(TimestampStringMap.class)) || (value instanceof Character && !typeClass
1 ✔
585
                                                                                        .equals(TimestampCharMap.class))) {
1 ✔
586
                    throw new IllegalArgumentException(
×
587
                            "The object class does not match with the dynamic type (" + typeClass.getName() + ")");
×
588
                }
589
            } else if (IntervalMap.class.isAssignableFrom(typeClass)) {
1 ✔
590
                checkTimeRepresentationInterval();
1 ✔
591
                if ((value instanceof Double && (!typeClass
1 ✔
592
                        .equals(IntervalDoubleMap.class))) || (value instanceof Float && !typeClass
1 ✔
593
                                .equals(IntervalFloatMap.class)) || (value instanceof Boolean && !typeClass
1 ✔
594
                                        .equals(IntervalBooleanMap.class)) || (value instanceof Integer && !typeClass
1 ✔
595
                                                .equals(IntervalIntegerMap.class)) || (value instanceof Long && !typeClass
1 ✔
596
                                                        .equals(IntervalLongMap.class)) || (value instanceof Short && !typeClass
1 ✔
597
                                                                .equals(IntervalShortMap.class)) || (value instanceof Byte && !typeClass
1 ✔
598
                                                                        .equals(IntervalByteMap.class)) || (value instanceof String && !typeClass
1 ✔
599
                                                                                .equals(IntervalStringMap.class)) || (value instanceof Character && !typeClass
1 ✔
600
                                                                                        .equals(IntervalCharMap.class))) {
1 ✔
601
                    throw new IllegalArgumentException(
×
602
                            "The object class does not match with the dynamic type (" + typeClass.getName() + ")");
×
603
                }
604
            }
605
        }
606
    }
1 ✔
607

608
    void checkType(Column column, Object value) {
609
        if (value != null) {
1 ✔
610
            Class typeClass = column.getTypeClass();
1 ✔
611
            if (List.class.isAssignableFrom(typeClass)) {
1 ✔
612
                if (!(value instanceof List)) {
1 ✔
613
                    throw new IllegalArgumentException("The object class " + value.getClass()
×
614
                            .getName() + " does not match with the list type (" + typeClass.getName() + ")");
×
615
                }
616
            } else if (Set.class.isAssignableFrom(typeClass)) {
1 ✔
617
                if (!(value instanceof Set)) {
1 ✔
618
                    throw new IllegalArgumentException("The object class " + value.getClass()
×
619
                            .getName() + " does not match with the set type (" + typeClass.getName() + ")");
×
620
                }
621
            } else if (Map.class.isAssignableFrom(typeClass)) {
1 ✔
622
                if (!(value instanceof Map)) {
1 ✔
623
                    throw new IllegalArgumentException("The object class " + value.getClass()
×
624
                            .getName() + " does not match with the map type (" + typeClass.getName() + ")");
×
625
                }
626
            } else if (!value.getClass().equals(typeClass)) {
1 ✔
627
                throw new IllegalArgumentException("The object class " + value.getClass()
1 ✔
628
                        .getName() + " does not match with the column type (" + typeClass.getName() + ")");
1 ✔
629
            }
630
        }
631
    }
1 ✔
632

633
    void checkViewExist(final GraphView view) {
634
        if (view == null) {
1 ✔
635
            throw new NullPointerException();
1 ✔
636
        }
637
        if (view.isMainView()) {
1 ✔
638
            return;
1 ✔
639
        }
640
        if (!(view instanceof GraphViewImpl)) {
1 ✔
641
            throw new IllegalArgumentException("The view is not from this implementation");
×
642
        }
643
        // Lock-free: callers may hold the table lock or the element monitor
644
        GraphViewImpl viewImpl = (GraphViewImpl) view;
1 ✔
645
        if (viewImpl.isDestroyed() || (graphStore != null && viewImpl.graphStore != graphStore)) {
1 ✔
646
            throw new IllegalArgumentException("The view doesn't exist");
1 ✔
647
        }
648
    }
1 ✔
649

650
    TimeRepresentation getTimeRepresentation() {
651
        if (graphStore != null) {
1 ✔
652
            return graphStore.configuration.getTimeRepresentation();
1 ✔
653
        }
654
        return GraphStoreConfiguration.DEFAULT_TIME_REPRESENTATION;
×
655
    }
656
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc